@api-client/core 0.9.4 → 0.9.6

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 (256) hide show
  1. package/build/browser.d.ts +14 -3
  2. package/build/browser.js +16 -2
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +15 -4
  5. package/build/index.js +17 -3
  6. package/build/index.js.map +1 -1
  7. package/build/src/data/{JmesparthReader.d.ts → JmespathReader.d.ts} +1 -1
  8. package/build/src/data/{JmesparthReader.js → JmespathReader.js} +2 -2
  9. package/build/src/data/JmespathReader.js.map +1 -0
  10. package/build/src/data/RequestDataExtractor.d.ts +5 -5
  11. package/build/src/data/RequestDataExtractor.js.map +1 -1
  12. package/build/src/data/XmlReader.js +14 -1
  13. package/build/src/data/XmlReader.js.map +1 -1
  14. package/build/src/events/BaseEvents.d.ts +25 -0
  15. package/build/src/events/Events.d.ts +1 -1
  16. package/build/src/events/transport/TransportEvents.d.ts +1 -1
  17. package/build/src/events/transport/TransportEvents.js.map +1 -1
  18. package/build/src/models/ClientCertificate.d.ts +9 -0
  19. package/build/src/models/ClientCertificate.js.map +1 -1
  20. package/build/src/models/Environment.d.ts +3 -2
  21. package/build/src/models/Environment.js +11 -6
  22. package/build/src/models/Environment.js.map +1 -1
  23. package/build/src/models/ErrorResponse.js.map +1 -1
  24. package/build/src/models/HttpRequest.d.ts +2 -7
  25. package/build/src/models/HttpRequest.js +1 -6
  26. package/build/src/models/HttpRequest.js.map +1 -1
  27. package/build/src/models/HttpResponse.d.ts +2 -7
  28. package/build/src/models/HttpResponse.js +1 -3
  29. package/build/src/models/HttpResponse.js.map +1 -1
  30. package/build/src/models/ProjectExecution.d.ts +115 -0
  31. package/build/src/models/ProjectExecution.js +148 -0
  32. package/build/src/models/ProjectExecution.js.map +1 -0
  33. package/build/src/models/ProjectRequest.d.ts +19 -0
  34. package/build/src/models/ProjectRequest.js +50 -0
  35. package/build/src/models/ProjectRequest.js.map +1 -1
  36. package/build/src/models/Request.d.ts +12 -3
  37. package/build/src/models/Request.js +14 -1
  38. package/build/src/models/Request.js.map +1 -1
  39. package/build/src/models/RequestAuthorization.js.map +1 -1
  40. package/build/src/models/RequestLog.d.ts +11 -0
  41. package/build/src/models/RequestLog.js +15 -1
  42. package/build/src/models/RequestLog.js.map +1 -1
  43. package/build/src/models/SerializablePayload.d.ts +6 -1
  44. package/build/src/models/SerializablePayload.js +10 -6
  45. package/build/src/models/SerializablePayload.js.map +1 -1
  46. package/build/src/models/http-actions/AssertionError.d.ts +36 -0
  47. package/build/src/models/http-actions/AssertionError.js +35 -0
  48. package/build/src/models/http-actions/AssertionError.js.map +1 -0
  49. package/build/src/models/http-actions/HttpAssertion.d.ts +84 -0
  50. package/build/src/models/http-actions/HttpAssertion.js +52 -0
  51. package/build/src/models/http-actions/HttpAssertion.js.map +1 -0
  52. package/build/src/models/http-actions/HttpFlows.d.ts +109 -0
  53. package/build/src/models/http-actions/HttpFlows.js +31 -0
  54. package/build/src/models/http-actions/HttpFlows.js.map +1 -0
  55. package/build/src/models/http-actions/HttpStep.d.ts +29 -0
  56. package/build/src/models/http-actions/HttpStep.js +30 -0
  57. package/build/src/models/http-actions/HttpStep.js.map +1 -0
  58. package/build/src/models/http-actions/LegacyTranslator.d.ts +8 -7
  59. package/build/src/models/http-actions/LegacyTranslator.js +18 -13
  60. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -1
  61. package/build/src/models/http-actions/steps/assertion/EqualAssertion.d.ts +76 -0
  62. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js +79 -0
  63. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +1 -0
  64. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.d.ts +36 -0
  65. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js +59 -0
  66. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +1 -0
  67. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.d.ts +28 -0
  68. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js +45 -0
  69. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +1 -0
  70. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.d.ts +18 -0
  71. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js +29 -0
  72. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +1 -0
  73. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.d.ts +18 -0
  74. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js +29 -0
  75. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +1 -0
  76. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.d.ts +28 -0
  77. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js +45 -0
  78. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +1 -0
  79. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.d.ts +36 -0
  80. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js +59 -0
  81. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +1 -0
  82. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.d.ts +28 -0
  83. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js +45 -0
  84. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +1 -0
  85. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.d.ts +36 -0
  86. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js +59 -0
  87. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +1 -0
  88. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.d.ts +76 -0
  89. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js +79 -0
  90. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +1 -0
  91. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.d.ts +28 -0
  92. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js +45 -0
  93. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +1 -0
  94. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.d.ts +18 -0
  95. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js +29 -0
  96. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +1 -0
  97. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.d.ts +29 -0
  98. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js +45 -0
  99. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +1 -0
  100. package/build/src/models/http-actions/steps/assertion/OkAssertion.d.ts +18 -0
  101. package/build/src/models/http-actions/steps/assertion/OkAssertion.js +29 -0
  102. package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +1 -0
  103. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.d.ts +35 -0
  104. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js +53 -0
  105. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +1 -0
  106. package/build/src/models/http-actions/steps/assertion/index.d.ts +15 -0
  107. package/build/src/models/http-actions/steps/assertion/index.js +16 -0
  108. package/build/src/models/http-actions/steps/assertion/index.js.map +1 -0
  109. package/build/src/models/http-actions/steps/data/DeleteCookieStep.d.ts +44 -0
  110. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js +67 -0
  111. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +1 -0
  112. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.d.ts +53 -0
  113. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js +60 -0
  114. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +1 -0
  115. package/build/src/models/http-actions/steps/data/ReadDataStep.d.ts +67 -0
  116. package/build/src/models/http-actions/steps/data/ReadDataStep.js +77 -0
  117. package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +1 -0
  118. package/build/src/models/http-actions/steps/data/ReadValueStep.d.ts +45 -0
  119. package/build/src/models/http-actions/steps/data/ReadValueStep.js +52 -0
  120. package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +1 -0
  121. package/build/src/models/http-actions/steps/data/SetCookieStep.d.ts +100 -0
  122. package/build/src/models/http-actions/steps/data/SetCookieStep.js +138 -0
  123. package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +1 -0
  124. package/build/src/models/http-actions/steps/data/SetDataStep.d.ts +77 -0
  125. package/build/src/models/http-actions/steps/data/SetDataStep.js +69 -0
  126. package/build/src/models/http-actions/steps/data/SetDataStep.js.map +1 -0
  127. package/build/src/models/http-actions/steps/data/SetVariableStep.d.ts +40 -0
  128. package/build/src/models/http-actions/steps/data/SetVariableStep.js +44 -0
  129. package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +1 -0
  130. package/build/src/models/http-actions/steps/data/index.d.ts +7 -0
  131. package/build/src/models/http-actions/steps/data/index.js +8 -0
  132. package/build/src/models/http-actions/steps/data/index.js.map +1 -0
  133. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.d.ts +18 -0
  134. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js +29 -0
  135. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +1 -0
  136. package/build/src/models/http-actions/steps/transformation/AsNumberStep.d.ts +18 -0
  137. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js +29 -0
  138. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +1 -0
  139. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.d.ts +18 -0
  140. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js +29 -0
  141. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +1 -0
  142. package/build/src/models/http-actions/steps/transformation/RoundStep.d.ts +43 -0
  143. package/build/src/models/http-actions/steps/transformation/RoundStep.js +52 -0
  144. package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +1 -0
  145. package/build/src/models/http-actions/steps/transformation/SubstringStep.d.ts +38 -0
  146. package/build/src/models/http-actions/steps/transformation/SubstringStep.js +65 -0
  147. package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +1 -0
  148. package/build/src/models/http-actions/steps/transformation/TrimStep.d.ts +20 -0
  149. package/build/src/models/http-actions/steps/transformation/TrimStep.js +30 -0
  150. package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +1 -0
  151. package/build/src/models/http-actions/steps/transformation/index.d.ts +6 -0
  152. package/build/src/models/http-actions/steps/transformation/index.js +7 -0
  153. package/build/src/models/http-actions/steps/transformation/index.js.map +1 -0
  154. package/build/src/proxy/HttpProjectProxy.d.ts +1 -1
  155. package/build/src/proxy/Proxy.d.ts +1 -1
  156. package/build/src/proxy/ProxyService.d.ts +1 -1
  157. package/build/src/proxy/RequestProxy.d.ts +7 -2
  158. package/build/src/proxy/RequestProxy.js +4 -1
  159. package/build/src/proxy/RequestProxy.js.map +1 -1
  160. package/build/src/runtime/http-runner/ConditionCheck.d.ts +10 -10
  161. package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -1
  162. package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +75 -0
  163. package/build/src/runtime/http-runner/HttpAssertionRunner.js +538 -0
  164. package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -0
  165. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +11 -6
  166. package/build/src/runtime/http-runner/HttpFlowRunner.js +24 -15
  167. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  168. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +14 -3
  169. package/build/src/runtime/http-runner/HttpRequestRunner.js +44 -0
  170. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  171. package/build/src/runtime/node/BaseRunner.d.ts +1 -1
  172. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -2
  173. package/build/src/runtime/node/ProjectParallelRunner.js +2 -2
  174. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  175. package/build/src/runtime/node/ProjectRequestRunner.js +6 -2
  176. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  177. package/build/src/runtime/node/ProjectRunner.d.ts +1 -1
  178. package/build/src/runtime/node/ProjectSerialRunner.d.ts +1 -1
  179. package/build/src/runtime/reporters/Reporter.d.ts +1 -33
  180. package/build/src/runtime/reporters/Reporter.js.map +1 -1
  181. package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +2 -0
  182. package/build/src/runtime/store/interfaces/ProjectRuns.d.ts +56 -0
  183. package/build/src/runtime/store/interfaces/ProjectRuns.js +2 -0
  184. package/build/src/runtime/store/interfaces/ProjectRuns.js.map +1 -0
  185. package/package.json +3 -2
  186. package/src/data/{JmesparthReader.ts → JmespathReader.ts} +2 -2
  187. package/src/data/RequestDataExtractor.ts +5 -5
  188. package/src/data/XmlReader.ts +16 -2
  189. package/src/events/BaseEvents.ts +30 -0
  190. package/src/events/transport/TransportEvents.ts +1 -1
  191. package/src/models/ClientCertificate.ts +9 -0
  192. package/src/models/Environment.ts +11 -7
  193. package/src/models/ErrorResponse.ts +1 -1
  194. package/src/models/HttpRequest.ts +4 -14
  195. package/src/models/HttpResponse.ts +5 -11
  196. package/src/models/ProjectExecution.ts +227 -0
  197. package/src/models/ProjectRequest.ts +54 -0
  198. package/src/models/Request.ts +23 -4
  199. package/src/models/RequestAuthorization.ts +1 -1
  200. package/src/models/RequestLog.ts +21 -1
  201. package/src/models/SerializablePayload.ts +18 -1
  202. package/src/models/http-actions/AssertionError.ts +57 -0
  203. package/src/models/http-actions/HttpAssertion.ts +89 -0
  204. package/src/models/http-actions/HttpFlows.ts +115 -0
  205. package/src/models/http-actions/HttpStep.ts +50 -0
  206. package/src/models/http-actions/LegacyTranslator.ts +42 -30
  207. package/src/models/http-actions/steps/assertion/EqualAssertion.ts +130 -0
  208. package/src/models/http-actions/steps/assertion/GreaterThanAssertion.ts +87 -0
  209. package/src/models/http-actions/steps/assertion/IncludesAssertion.ts +68 -0
  210. package/src/models/http-actions/steps/assertion/IsEmptyAssertion.ts +41 -0
  211. package/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.ts +41 -0
  212. package/src/models/http-actions/steps/assertion/LengthOfAssertion.ts +68 -0
  213. package/src/models/http-actions/steps/assertion/LessThanAssertion.ts +87 -0
  214. package/src/models/http-actions/steps/assertion/MatchesAssertion.ts +68 -0
  215. package/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.ts +85 -0
  216. package/src/models/http-actions/steps/assertion/NotEqualAssertion.ts +130 -0
  217. package/src/models/http-actions/steps/assertion/NotIncludesAssertion.ts +68 -0
  218. package/src/models/http-actions/steps/assertion/NotOkAssertion.ts +41 -0
  219. package/src/models/http-actions/steps/assertion/NotToBeAssertion.ts +69 -0
  220. package/src/models/http-actions/steps/assertion/OkAssertion.ts +41 -0
  221. package/src/models/http-actions/steps/assertion/ToBeAssertion.ts +76 -0
  222. package/src/models/http-actions/steps/data/DeleteCookieStep.ts +102 -0
  223. package/src/models/http-actions/steps/data/ReadDataSourceStep.ts +103 -0
  224. package/src/models/http-actions/steps/data/ReadDataStep.ts +128 -0
  225. package/src/models/http-actions/steps/data/ReadValueStep.ts +88 -0
  226. package/src/models/http-actions/steps/data/SetCookieStep.ts +206 -0
  227. package/src/models/http-actions/steps/data/SetDataStep.ts +124 -0
  228. package/src/models/http-actions/steps/data/SetVariableStep.ts +82 -0
  229. package/src/models/http-actions/steps/transformation/AsLowerCaseStep.ts +41 -0
  230. package/src/models/http-actions/steps/transformation/AsNumberStep.ts +41 -0
  231. package/src/models/http-actions/steps/transformation/AsUpperCaseStep.ts +41 -0
  232. package/src/models/http-actions/steps/transformation/RoundStep.ts +86 -0
  233. package/src/models/http-actions/steps/transformation/SubstringStep.ts +93 -0
  234. package/src/models/http-actions/steps/transformation/TrimStep.ts +43 -0
  235. package/src/proxy/HttpProjectProxy.ts +1 -1
  236. package/src/proxy/Proxy.ts +1 -1
  237. package/src/proxy/ProxyService.ts +1 -1
  238. package/src/proxy/RequestProxy.ts +11 -3
  239. package/src/runtime/http-runner/ConditionCheck.ts +13 -14
  240. package/src/runtime/http-runner/HttpAssertionRunner.ts +540 -0
  241. package/src/runtime/http-runner/HttpFlowRunner.ts +33 -19
  242. package/src/runtime/http-runner/HttpRequestRunner.ts +53 -5
  243. package/src/runtime/node/BaseRunner.ts +1 -1
  244. package/src/runtime/node/ProjectParallelRunner.ts +5 -5
  245. package/src/runtime/node/ProjectRequestRunner.ts +6 -2
  246. package/src/runtime/node/ProjectRunner.ts +1 -1
  247. package/src/runtime/node/ProjectRunnerWorker.ts +1 -1
  248. package/src/runtime/node/ProjectSerialRunner.ts +1 -1
  249. package/src/runtime/reporters/Reporter.ts +1 -35
  250. package/src/runtime/store/interfaces/ApiClientStore.ts +3 -0
  251. package/src/runtime/store/interfaces/ProjectRuns.ts +64 -0
  252. package/build/src/data/JmesparthReader.js.map +0 -1
  253. package/build/src/models/http-actions/HttpActions.d.ts +0 -256
  254. package/build/src/models/http-actions/HttpActions.js +0 -46
  255. package/build/src/models/http-actions/HttpActions.js.map +0 -1
  256. package/src/models/http-actions/HttpActions.ts +0 -270
@@ -13,7 +13,8 @@ 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 { IHttpActionFlow } from './http-actions/HttpActions.js';
16
+ import { IHttpFlow } from './http-actions/HttpFlows.js';
17
+ import { IHttpAssertion } from './http-actions/HttpAssertion.js';
17
18
  import { LegacyTranslator } from './http-actions/LegacyTranslator.js';
18
19
 
19
20
  export const Kind = 'Core#Request';
@@ -63,7 +64,7 @@ export interface IRequest {
63
64
  * Http action flows.
64
65
  * In ARC this was "actions",
65
66
  */
66
- flows?: IHttpActionFlow[];
67
+ flows?: IHttpFlow[];
67
68
  /**
68
69
  * The certificate to use with the request.
69
70
  * Note, the certificate defined on the certificate authorization
@@ -71,6 +72,11 @@ export interface IRequest {
71
72
  * this certificate and update the configuration.
72
73
  */
73
74
  clientCertificate?: HttpCertificate;
75
+
76
+ /**
77
+ * The list of assertions (tests) to perform after the response is ready.
78
+ */
79
+ assertions?: IHttpAssertion[];
74
80
  }
75
81
 
76
82
  export class Request {
@@ -102,7 +108,7 @@ export class Request {
102
108
  * Http action flows.
103
109
  * In ARC this was "actions",
104
110
  */
105
- flows?: IHttpActionFlow[];
111
+ flows?: IHttpFlow[];
106
112
  /**
107
113
  * The certificate to use with the request.
108
114
  * Note, the certificate defined on the certificate authorization
@@ -111,6 +117,11 @@ export class Request {
111
117
  */
112
118
  clientCertificate?: Certificate;
113
119
 
120
+ /**
121
+ * The list of assertions (tests) to perform after the response is ready.
122
+ */
123
+ assertions?: IHttpAssertion[];
124
+
114
125
  /**
115
126
  * Creates a request from an URL.
116
127
  *
@@ -340,7 +351,7 @@ export class Request {
340
351
  }
341
352
 
342
353
  new(init: IRequest): void {
343
- const { expects, log, updated, created = Date.now(), midnight, config, authorization, flows, clientCertificate, info } = init;
354
+ const { expects, log, updated, created = Date.now(), midnight, config, authorization, flows, clientCertificate, info, assertions } = init;
344
355
  if (expects) {
345
356
  this.expects = new HttpRequest(expects);
346
357
  } else {
@@ -383,6 +394,11 @@ export class Request {
383
394
  } else {
384
395
  this.flows = undefined;
385
396
  }
397
+ if (Array.isArray(assertions)) {
398
+ this.assertions = assertions.map(i => JsonCore.clone(i));
399
+ } else {
400
+ this.assertions = undefined;
401
+ }
386
402
  if (clientCertificate) {
387
403
  this.clientCertificate = new Certificate(clientCertificate);
388
404
  } else {
@@ -411,6 +427,9 @@ export class Request {
411
427
  if (Array.isArray(this.flows)) {
412
428
  result.flows = this.flows.map(i => JsonCore.clone(i))
413
429
  }
430
+ if (Array.isArray(this.assertions)) {
431
+ result.assertions = this.assertions.map(i => JsonCore.clone(i))
432
+ }
414
433
  if (this.clientCertificate) {
415
434
  result.clientCertificate = this.clientCertificate.toJSON();
416
435
  }
@@ -64,7 +64,7 @@ export class RequestAuthorization {
64
64
  }
65
65
  return new RequestAuthorization({
66
66
  kind: Kind,
67
- config: (info.config as any),
67
+ config: info.config as IAuthorizationSettingsUnion,
68
68
  enabled: true,
69
69
  type: info.type as AuthorizationType,
70
70
  valid: info.valid,
@@ -4,6 +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
8
 
8
9
  export const Kind = 'Core#ResponseLog';
9
10
 
@@ -32,6 +33,11 @@ export interface IRequestLog {
32
33
  * Optional request ID defined on an HTTP project that triggered this log.
33
34
  */
34
35
  requestId?: string;
36
+ /**
37
+ * The assertions result performed on the response.
38
+ * Note, Error response can also be passed through tests.
39
+ */
40
+ assertions?: AssertionResult[];
35
41
  }
36
42
 
37
43
  /**
@@ -60,6 +66,12 @@ export class RequestLog {
60
66
  */
61
67
  requestId?: string;
62
68
 
69
+ /**
70
+ * The assertions result performed on the response.
71
+ * Note, Error response can also be passed through tests.
72
+ */
73
+ assertions?: AssertionResult[];
74
+
63
75
  static fromRequest(request: ISentRequest): RequestLog {
64
76
  return new RequestLog({
65
77
  kind: Kind,
@@ -96,7 +108,7 @@ export class RequestLog {
96
108
  * Creates a new response clearing anything that is so far defined.
97
109
  */
98
110
  new(init: IRequestLog): void {
99
- const { request, response, redirects, size, requestId } = init;
111
+ const { request, response, redirects, size, requestId, assertions } = init;
100
112
  this.kind = Kind;
101
113
  if (request) {
102
114
  this.request = new SentRequest(request);
@@ -125,6 +137,11 @@ export class RequestLog {
125
137
  } else {
126
138
  this.requestId = undefined;
127
139
  }
140
+ if (Array.isArray(assertions) && assertions.length) {
141
+ this.assertions = assertions.map(i => ({ ...i }));
142
+ } else {
143
+ this.assertions = undefined;
144
+ }
128
145
  }
129
146
 
130
147
  toJSON(): IRequestLog {
@@ -146,6 +163,9 @@ export class RequestLog {
146
163
  if (this.requestId) {
147
164
  result.requestId = this.requestId;
148
165
  }
166
+ if (Array.isArray(this.assertions) && this.assertions.length) {
167
+ result.assertions = this.assertions.map(i => ({ ...i }));
168
+ }
149
169
  return result;
150
170
  }
151
171
 
@@ -14,7 +14,7 @@ export interface SerializablePayloadOptions {
14
14
  mime?: string;
15
15
  }
16
16
 
17
- export class SerializablePayload {
17
+ export interface ISerializablePayload {
18
18
  /**
19
19
  * The serialized payload message.
20
20
  */
@@ -24,6 +24,12 @@ export class SerializablePayload {
24
24
  * Optional meta of the payload
25
25
  */
26
26
  payloadOptions?: SerializablePayloadOptions;
27
+ }
28
+
29
+ export class SerializablePayload implements ISerializablePayload {
30
+ payload?: Payload;
31
+
32
+ payloadOptions?: SerializablePayloadOptions;
27
33
 
28
34
  /**
29
35
  * The payload in its original format.
@@ -90,4 +96,15 @@ export class SerializablePayload {
90
96
  const decoder = new TextDecoder();
91
97
  return decoder.decode(dataView);
92
98
  }
99
+
100
+ toJSON(): ISerializablePayload {
101
+ const result: ISerializablePayload = {};
102
+ if (this.payload) {
103
+ result.payload = this.payload;
104
+ }
105
+ if (this.payloadOptions) {
106
+ result.payloadOptions = { ...this.payloadOptions };
107
+ }
108
+ return result;
109
+ }
93
110
  }
@@ -0,0 +1,57 @@
1
+ export interface IAssertionError {
2
+ /**
3
+ * Set with assertions to show the actual value at the time of testing.
4
+ */
5
+ actual?: unknown;
6
+ /**
7
+ * Set with assertions to show the expected value at the time of testing.
8
+ */
9
+ expected?: unknown;
10
+ /**
11
+ * The operator used to make the assertion.
12
+ */
13
+ operator?: string;
14
+ /**
15
+ * The error message, if any.
16
+ * Assertions usually don't set error messages. Instead they set other fields.
17
+ */
18
+ message?: string;
19
+ }
20
+
21
+ export class AssertionError extends Error {
22
+ /**
23
+ * Set with assertions to show the actual value at the time of testing.
24
+ */
25
+ actual: unknown;
26
+ /**
27
+ * Set with assertions to show the expected value at the time of testing.
28
+ */
29
+ expected: unknown;
30
+ /**
31
+ * The operator used to make the assertion.
32
+ */
33
+ operator: string;
34
+
35
+ code = 'ERR_ASSERTION';
36
+
37
+ constructor(options: IAssertionError = {}) {
38
+ super(options.message || 'Unspecified AssertionError');
39
+ this.name = 'AssertionError';
40
+ this.actual = options.actual;
41
+ this.expected = options.expected;
42
+ this.operator = options.operator || '[unknown]';
43
+ }
44
+
45
+ toJSON(): IAssertionError {
46
+ const result: IAssertionError = {};
47
+ if (this.message) {
48
+ result.message = this.message;
49
+ }
50
+ result.actual = this.actual;
51
+ result.expected = this.expected;
52
+ if (this.operator) {
53
+ result.operator = this.operator;
54
+ }
55
+ return result;
56
+ }
57
+ }
@@ -0,0 +1,89 @@
1
+ import { IAssertionError } from "./AssertionError.js";
2
+ import { IHttpStep } from "./HttpStep.js";
3
+
4
+ export enum AssertionEnum {
5
+ equal = "equal",
6
+ notEqual = "not-equal",
7
+ greaterThan = "greater-than",
8
+ greaterThanEqual = "greater-than-equal",
9
+ lessThan = "less-than",
10
+ lessThanEqual = "less-than-equal",
11
+ contains = "contains",
12
+ regex = "regex",
13
+ ok = 'ok',
14
+ notOk = 'notOk',
15
+ toBe = 'toBe',
16
+ notToBe = 'notToBe',
17
+ }
18
+
19
+ export enum TransformationEnum {
20
+ /**
21
+ * Transformation of the data that reads a value from the given path.
22
+ * For example, for a body it can be xpath for XML or JSON path for JSON data.
23
+ */
24
+ readValue = 'readValue',
25
+ /**
26
+ * Transforms the value from the previous step to a number.
27
+ */
28
+ asNumber = 'asNumber',
29
+ /**
30
+ * Rounds the input value to a nearest numeric value.
31
+ * If the value is not a number it tries to convert it to a number. When it
32
+ * can't ba casted to a number then the transformation throws an error.
33
+ */
34
+ round = 'round',
35
+ /**
36
+ * Transforms the value to a lowercase value.
37
+ */
38
+ toLowerCase = 'toLowerCase',
39
+ /**
40
+ * Transforms the value to a uppercase value.
41
+ */
42
+ toUpperCase = 'toUpperCase',
43
+ /**
44
+ * Trims the string value.
45
+ */
46
+ trim = 'trim',
47
+ /**
48
+ * Transforms the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
49
+ *
50
+ * `substring(indexStart, indexEnd)`
51
+ */
52
+ substring = 'substring',
53
+ }
54
+
55
+ export interface IHttpAssertion {
56
+ /**
57
+ * The description of the assertion reported to the UI.
58
+ */
59
+ description?: string;
60
+
61
+ /**
62
+ * The list of steps to perform. This is an ordered list of action tasks.
63
+ * Each step is described by the `kind` property which tells the runner what action to perform.
64
+ */
65
+ steps: IHttpStep[];
66
+ /**
67
+ * Whether the assertions is enabled. By default it is enabled. It is only not enabled when this is set to false.
68
+ */
69
+ enabled?: boolean;
70
+ }
71
+
72
+ /**
73
+ * An object representing a result of running a single assertion.
74
+ */
75
+ export interface AssertionResult {
76
+ /**
77
+ * Indicates whether assertion result is positive (not failed) or negative (failed).
78
+ */
79
+ ok: boolean;
80
+ /**
81
+ * The description of the association.
82
+ */
83
+ description: string;
84
+ /**
85
+ * This is always set when `ok` is false.
86
+ * This is also never set when `ok` is true.
87
+ */
88
+ error?: IAssertionError;
89
+ }
@@ -0,0 +1,115 @@
1
+ import { AssertionEnum } from './HttpAssertion.js';
2
+ import { IHttpStep } from './HttpStep.js';
3
+
4
+ export enum FlowSourceEnum {
5
+ /**
6
+ * The request object.
7
+ */
8
+ request = 'request',
9
+ /**
10
+ * The response object.
11
+ */
12
+ response = 'response',
13
+ /**
14
+ * A variable from the current environment.
15
+ */
16
+ variable = 'variable',
17
+ }
18
+
19
+ export enum FlowRequestDataEnum {
20
+ url = "url",
21
+ method = "method",
22
+ headers = "headers",
23
+ body = "body"
24
+ }
25
+
26
+ export enum FlowResponseDataEnum {
27
+ url = "url",
28
+ status = "status",
29
+ statusText = "statusText",
30
+ headers = "headers",
31
+ body = "body"
32
+ }
33
+
34
+ /**
35
+ * A flow represents a series of actions to be performed one-by-one after the HTTP request is sent or when the response
36
+ * is ready.
37
+ */
38
+ export interface IHttpFlow {
39
+ /**
40
+ * The description of the flow
41
+ */
42
+ description?: string;
43
+ /**
44
+ * Describes when the flow is executed.
45
+ * The `request` means the flow is executed before the request is sent to the HTTP engine.
46
+ * The `response` means the flow is executed after the response has been received in full, but before reporting
47
+ * the response to the UI.
48
+ */
49
+ trigger: 'request' | 'response';
50
+ /**
51
+ * The ordered list of actions to execute.
52
+ */
53
+ actions: IHttpAction[];
54
+ }
55
+
56
+ /**
57
+ * Describes a single action in a flow.
58
+ * An action can have a condition that is checked against the current context.
59
+ * Action is not executed when the condition is not meet.
60
+ *
61
+ * Each action has one or more steps (when 0 items then the action is ignored). Each step performs a task.
62
+ * The result of a task is passed to the next step as an input. The result of a task may be `void`, `null`, or `undefined` which is treated as `void`.
63
+ */
64
+ export interface IHttpAction {
65
+ /**
66
+ * The description of the action
67
+ */
68
+ description?: string;
69
+ /**
70
+ * A condition to check before performing the action.
71
+ */
72
+ condition?: IHttpCondition;
73
+ /**
74
+ * The list of steps to perform. This is an ordered list of action tasks.
75
+ * Each step is described by the `kind` property which tells the runner what action to perform.
76
+ */
77
+ steps: IHttpStep[];
78
+ }
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
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The action that can be taken on the data.
3
+ */
4
+ export interface IHttpStep {
5
+ /**
6
+ * The kind of the action to perform.
7
+ */
8
+ kind: string;
9
+ /**
10
+ * Whether the step is disabled in the flow.
11
+ */
12
+ enabled?: boolean;
13
+ }
14
+
15
+ export abstract class HttpStep {
16
+ /**
17
+ * The kind of the action to perform.
18
+ */
19
+ kind = '';
20
+
21
+ /**
22
+ * Whether the step is disabled in the flow.
23
+ */
24
+ enabled?: boolean;
25
+
26
+ new(init: IHttpStep): void {
27
+ const { kind, enabled } = init;
28
+ this.kind = kind;
29
+ if (typeof enabled === 'boolean') {
30
+ this.enabled = enabled
31
+ } else {
32
+ this.enabled = undefined;
33
+ }
34
+ }
35
+
36
+ toJSON(): IHttpStep {
37
+ const result: IHttpStep = {
38
+ kind: this.kind,
39
+ }
40
+ if (typeof this.enabled === 'boolean') {
41
+ result.enabled = this.enabled;
42
+ }
43
+ return result;
44
+ }
45
+
46
+ /**
47
+ * A function that returns true when the step is valid and can be executed.
48
+ */
49
+ abstract checkValidity(): boolean;
50
+ }
@@ -1,18 +1,30 @@
1
1
  import { RequestActions as LegacyRequestActions } from '../../models/legacy/request/ArcRequest.js';
2
- import { RunnableAction as LegacyRunnable, Condition as LegacyCondition, Action as LegacyAction, SetCookieConfig, SetVariableConfig, DeleteCookieConfig, DataSourceConfiguration } from '../../models/legacy/actions/Actions.js';
3
- import { IHttpActionFlow, IHttpAction, IHttpCondition, ActionSourceEnum, ActionRequestDataEnum, ActionResponseDataEnum, ActionOperatorEnum, IActionStep, ISetDataStep, SetDataStepKind, IReadDataStep, ReadDataStepKind, ISetCookieStep, SetCookieStepKind, IDeleteCookieStep, DeleteCookieStepKind } from './HttpActions.js';
2
+ import {
3
+ RunnableAction as LegacyRunnable, Condition as LegacyCondition, Action as LegacyAction,
4
+ SetCookieConfig, SetVariableConfig, DeleteCookieConfig, DataSourceConfiguration
5
+ } from '../../models/legacy/actions/Actions.js';
6
+ import {
7
+ IHttpFlow, IHttpAction, IHttpCondition, FlowSourceEnum, FlowRequestDataEnum,
8
+ FlowResponseDataEnum,
9
+ } from './HttpFlows.js';
4
10
  import { AmfNamespace } from '../../amf/definitions/Namespace.js';
11
+ import { AssertionEnum } from './HttpAssertion.js';
12
+ import { IHttpStep } from './HttpStep.js';
13
+ import { IReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js';
14
+ import { ISetDataStep, SetDataStepKind } from './steps/data/SetDataStep.js';
15
+ import { ISetCookieStep, SetCookieStepKind } from './steps/data/SetCookieStep.js';
16
+ import { DeleteCookieStepKind, IDeleteCookieStep } from './steps/data/DeleteCookieStep.js';
5
17
 
6
18
  /**
7
19
  * Allows to translate the old ARC actions into Action flows.
8
20
  */
9
21
  export class LegacyTranslator {
10
- static translate(action: LegacyRequestActions): IHttpActionFlow[] {
22
+ static translate(action: LegacyRequestActions): IHttpFlow[] {
11
23
  const { request, response } = action;
12
- const result: IHttpActionFlow[] = [];
24
+ const result: IHttpFlow[] = [];
13
25
 
14
26
  if (Array.isArray(request) && request.length) {
15
- const flow: IHttpActionFlow = {
27
+ const flow: IHttpFlow = {
16
28
  trigger: 'request',
17
29
  actions: this._translateRunnables(request),
18
30
  };
@@ -20,7 +32,7 @@ export class LegacyTranslator {
20
32
  }
21
33
 
22
34
  if (Array.isArray(response) && response.length) {
23
- const flow: IHttpActionFlow = {
35
+ const flow: IHttpFlow = {
24
36
  trigger: 'response',
25
37
  actions: this._translateRunnables(response),
26
38
  };
@@ -66,16 +78,16 @@ export class LegacyTranslator {
66
78
  }
67
79
  if (type) {
68
80
  switch (type) {
69
- case 'request': result.source = ActionSourceEnum.request; break;
70
- case 'response': result.source = ActionSourceEnum.response; break;
81
+ case 'request': result.source = FlowSourceEnum.request; break;
82
+ case 'response': result.source = FlowSourceEnum.response; break;
71
83
  }
72
84
  }
73
85
  if (type && source) {
74
86
  if (type === 'request') {
75
- result.data = source as ActionRequestDataEnum;
87
+ result.data = source as FlowRequestDataEnum;
76
88
  }
77
89
  if (type === 'response') {
78
- result.data = source as ActionResponseDataEnum;
90
+ result.data = source as FlowResponseDataEnum;
79
91
  }
80
92
  }
81
93
  if (predictedValue) {
@@ -83,20 +95,20 @@ export class LegacyTranslator {
83
95
  }
84
96
  if (operator) {
85
97
  switch (operator) {
86
- case 'contains': result.operator = ActionOperatorEnum.contains; break;
87
- case 'equal': result.operator = ActionOperatorEnum.equal; break;
88
- case 'greater-than': result.operator = ActionOperatorEnum.greaterThan; break;
89
- case 'greater-than-equal': result.operator = ActionOperatorEnum.greaterThanEqual; break;
90
- case 'less-than': result.operator = ActionOperatorEnum.lessThan; break;
91
- case 'less-than-equal': result.operator = ActionOperatorEnum.lessThanEqual; break;
92
- case 'not-equal': result.operator = ActionOperatorEnum.notEqual; break;
93
- case 'regex': result.operator = ActionOperatorEnum.regex; break;
98
+ case 'contains': result.operator = AssertionEnum.contains; break;
99
+ case 'equal': result.operator = AssertionEnum.equal; break;
100
+ case 'greater-than': result.operator = AssertionEnum.greaterThan; break;
101
+ case 'greater-than-equal': result.operator = AssertionEnum.greaterThanEqual; break;
102
+ case 'less-than': result.operator = AssertionEnum.lessThan; break;
103
+ case 'less-than-equal': result.operator = AssertionEnum.lessThanEqual; break;
104
+ case 'not-equal': result.operator = AssertionEnum.notEqual; break;
105
+ case 'regex': result.operator = AssertionEnum.regex; break;
94
106
  }
95
107
  }
96
108
  return result;
97
109
  }
98
110
 
99
- protected static _translateAction(item: LegacyAction): IActionStep[] {
111
+ protected static _translateAction(item: LegacyAction): IHttpStep[] {
100
112
  switch (item.name) {
101
113
  case 'set-cookie': return this._translateSetCookieAction(item);
102
114
  case 'set-variable': return this._translateSetVariableAction(item);
@@ -105,10 +117,10 @@ export class LegacyTranslator {
105
117
  }
106
118
  }
107
119
 
108
- protected static _translateSetCookieAction(item: LegacyAction): IActionStep[] {
120
+ protected static _translateSetCookieAction(item: LegacyAction): IHttpStep[] {
109
121
  const legacy = item.config as SetCookieConfig;
110
122
 
111
- const steps: IActionStep[] = [];
123
+ const steps: IHttpStep[] = [];
112
124
  const ds = this._translateDataSource(legacy.source);
113
125
  steps.push(ds);
114
126
 
@@ -142,10 +154,10 @@ export class LegacyTranslator {
142
154
  return steps;
143
155
  }
144
156
 
145
- protected static _translateSetVariableAction(item: LegacyAction): IActionStep[] {
157
+ protected static _translateSetVariableAction(item: LegacyAction): IHttpStep[] {
146
158
  const legacy = item.config as SetVariableConfig;
147
159
 
148
- const steps: IActionStep[] = [];
160
+ const steps: IHttpStep[] = [];
149
161
  const ds = this._translateDataSource(legacy.source);
150
162
  steps.push(ds);
151
163
 
@@ -161,10 +173,10 @@ export class LegacyTranslator {
161
173
  return steps;
162
174
  }
163
175
 
164
- protected static _translateDeleteCookieAction(item: LegacyAction): IActionStep[] {
176
+ protected static _translateDeleteCookieAction(item: LegacyAction): IHttpStep[] {
165
177
  const legacy = item.config as DeleteCookieConfig;
166
178
 
167
- const steps: IActionStep[] = [];
179
+ const steps: IHttpStep[] = [];
168
180
 
169
181
  const action: IDeleteCookieStep = {
170
182
  kind: DeleteCookieStepKind,
@@ -183,7 +195,7 @@ export class LegacyTranslator {
183
195
  return steps;
184
196
  }
185
197
 
186
- protected static _translateDataSource(source: DataSourceConfiguration): IActionStep {
198
+ protected static _translateDataSource(source: DataSourceConfiguration): IHttpStep {
187
199
  if (source.value) {
188
200
  const dataSet: ISetDataStep = {
189
201
  kind: SetDataStepKind,
@@ -206,16 +218,16 @@ export class LegacyTranslator {
206
218
  }
207
219
  if (type) {
208
220
  switch (type) {
209
- case 'request': result.source = ActionSourceEnum.request; break;
210
- case 'response': result.source = ActionSourceEnum.response; break;
221
+ case 'request': result.source = FlowSourceEnum.request; break;
222
+ case 'response': result.source = FlowSourceEnum.response; break;
211
223
  }
212
224
  }
213
225
  if (type && legacySource) {
214
226
  if (type === 'request') {
215
- result.data = legacySource as ActionRequestDataEnum;
227
+ result.data = legacySource as FlowRequestDataEnum;
216
228
  }
217
229
  if (type === 'response') {
218
- result.data = legacySource as ActionResponseDataEnum;
230
+ result.data = legacySource as FlowResponseDataEnum;
219
231
  }
220
232
  }
221
233
  return result;