@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.9.4",
4
+ "version": "0.9.6",
5
5
  "license": "Apache-2.0",
6
6
  "main": "build/index.js",
7
7
  "module": "build/index.js",
@@ -81,7 +81,8 @@
81
81
  "lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
82
82
  "prepare": "husky install && npm run build-ts && npm run build:api-models",
83
83
  "tsc:watch": "tsc --watch",
84
- "test:browser": "wtr --playwright --browsers chromium firefox webkit --coverage",
84
+ "test:browser": "wtr --playwright --browsers chromium --coverage",
85
+ "test:all": "wtr --playwright --browsers chromium firefox webkit --coverage",
85
86
  "test:browser:watch": "wtr --watch --playwright --browsers chromium",
86
87
  "test:node": "npm run build-ts && mocha",
87
88
  "test": "npm run test:node && npm run test:browser",
@@ -9,13 +9,13 @@ import { DataReader } from './DataReader.js';
9
9
  * request data. Instead, we use `JsonReader` that converts the JSON to XML so the same
10
10
  * XPath can be used for both JSON and XML.
11
11
  */
12
- export class JmesparthReader extends DataReader {
12
+ export class JmespathReader extends DataReader {
13
13
  async getValue(path: string): Promise<unknown> {
14
14
  const body = await this.readPayloadAsString();
15
15
  if (!body) {
16
16
  return undefined;
17
17
  }
18
- let obj: any;
18
+ let obj;
19
19
  try {
20
20
  obj = JSON.parse(body);
21
21
  } catch (e) {
@@ -3,7 +3,7 @@ import { IHttpRequest, HttpRequest } from '../models/HttpRequest.js';
3
3
  import { ISentRequest, SentRequest } from '../models/SentRequest.js';
4
4
  import { IHttpResponse, HttpResponse } from '../models/HttpResponse.js';
5
5
  import { IErrorResponse, ErrorResponse } from '../models/ErrorResponse.js';
6
- import { ActionRequestDataEnum, ActionResponseDataEnum, ActionSourceEnum } from '../models/http-actions/HttpActions.js';
6
+ import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from '../models/http-actions/HttpFlows.js';
7
7
  import { Headers } from '../lib/headers/Headers.js';
8
8
  import { JsonReader } from './JsonReader.js';
9
9
  import { XmlReader } from './XmlReader.js';
@@ -43,7 +43,7 @@ export class RequestDataExtractor {
43
43
  * @param path The path to the data.
44
44
  * @return Data to be processed
45
45
  */
46
- async extract(source: ActionSourceEnum, data?: ActionRequestDataEnum | ActionResponseDataEnum, path?: string): Promise<string | number | undefined> {
46
+ async extract(source: FlowSourceEnum, data?: FlowRequestDataEnum | FlowResponseDataEnum, path?: string): Promise<string | number | undefined> {
47
47
  const args = path ? path.split('.') : [];
48
48
  switch (data) {
49
49
  case 'url':
@@ -73,14 +73,14 @@ export class RequestDataExtractor {
73
73
  * @param source The source name
74
74
  * @returns The headers from the request / response
75
75
  */
76
- getHeaders(source?: ActionSourceEnum): string {
76
+ getHeaders(source?: FlowSourceEnum): string {
77
77
  if (source === 'request') {
78
78
  return this.request.headers || '';
79
79
  }
80
80
  return this.response && this.response.headers || '';
81
81
  }
82
82
 
83
- async processBody(path?: string, source?: ActionSourceEnum): Promise<string | undefined> {
83
+ async processBody(path?: string, source?: FlowSourceEnum): Promise<string | undefined> {
84
84
  const value = await this.getBody(source);
85
85
  if (!value) {
86
86
  return undefined;
@@ -104,7 +104,7 @@ export class RequestDataExtractor {
104
104
  * @param source The source name
105
105
  * @returns The headers from the request / response
106
106
  */
107
- async getBody(source?: ActionSourceEnum): Promise<string | undefined> {
107
+ async getBody(source?: FlowSourceEnum): Promise<string | undefined> {
108
108
  if (source === 'request') {
109
109
  return this.request.readPayloadAsString();
110
110
  }
@@ -38,7 +38,7 @@ export class XmlReader extends DataReader {
38
38
  }
39
39
 
40
40
  processNodeResult(result: XPathResult): unknown {
41
- const results: any[] = [];
41
+ const results: unknown[] = [];
42
42
  let next = result.iterateNext();
43
43
  while (next) {
44
44
  const value = next.textContent;
@@ -50,7 +50,21 @@ export class XmlReader extends DataReader {
50
50
  if (!results.length) {
51
51
  return undefined;
52
52
  }
53
- return results.length === 1 ? results[0] : results;
53
+
54
+ const mapped = results.map((item) => {
55
+ if (item === 'true') {
56
+ return true;
57
+ }
58
+ if (item === 'true') {
59
+ return false;
60
+ }
61
+ const typedNumber = Number(item);
62
+ if (!Number.isNaN(typedNumber)) {
63
+ return typedNumber;
64
+ }
65
+ return item;
66
+ });
67
+ return mapped.length === 1 ? mapped[0] : mapped;
54
68
  }
55
69
 
56
70
  async getDocument(): Promise<Document|undefined> {
@@ -495,6 +495,36 @@ export interface IHistoryRequestListOptions extends ContextListOptions {
495
495
  */
496
496
  export type HistoryListOptions = IHistoryRequestListOptions;
497
497
 
498
+ export interface IProjectExecutionListOptions extends ContextListOptions {
499
+ /**
500
+ * The key of the parent space.
501
+ */
502
+ space: string;
503
+
504
+ /**
505
+ * The id of the parent project
506
+ */
507
+ project: string;
508
+
509
+ /**
510
+ * The key of the application that made the records.
511
+ * This is optional and will returns results for the project made in all apps.
512
+ */
513
+ app?: string;
514
+
515
+ /**
516
+ * The key of the parent folder, if any.
517
+ * Note, when this is not provided the endpoint only returns list of logs
518
+ * created for the project.
519
+ */
520
+ parent?: string;
521
+
522
+ /**
523
+ * The user id that made that project run. Optional.
524
+ */
525
+ user?: string;
526
+ }
527
+
498
528
 
499
529
  export interface IPatchBase {
500
530
  /**
@@ -2,9 +2,9 @@
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  import { IHttpRequest } from "../../models/HttpRequest.js";
4
4
  import { IRequestLog } from '../../models/RequestLog.js';
5
+ import { IProjectExecutionLog } from "../../models/ProjectExecution.js";
5
6
  import { ContextEvent } from "../BaseEvents.js";
6
7
  import { TransportEventTypes } from "./TransportEventTypes.js";
7
- import { IProjectExecutionLog } from "../../runtime/reporters/Reporter.js";
8
8
  import { IRequestProxyInit } from "../../proxy/RequestProxy.js";
9
9
  import { IHttpProjectProxyInit, IHttpProjectStoreProxyInit } from "../../proxy/HttpProjectProxy.js";
10
10
  import { IProxyResult } from "../../proxy/Proxy.js";
@@ -73,6 +73,9 @@ export interface IPemCertificate extends ICertificate {
73
73
 
74
74
  export type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate;
75
75
 
76
+ /**
77
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
78
+ */
76
79
  export interface IPemCreateOptions {
77
80
  type: 'p12';
78
81
  /**
@@ -93,6 +96,9 @@ export interface IPemCreateOptions {
93
96
  passphrase?: string;
94
97
  }
95
98
 
99
+ /**
100
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
101
+ */
96
102
  export interface IP12CreateOptions {
97
103
  type: 'pem';
98
104
  /**
@@ -109,6 +115,9 @@ export interface IP12CreateOptions {
109
115
  passphrase?: string;
110
116
  }
111
117
 
118
+ /**
119
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
120
+ */
112
121
  export type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions;
113
122
 
114
123
  /**
@@ -3,6 +3,7 @@ import { Server, IServer } from './Server.js';
3
3
  import { IThing, Thing, Kind as ThingKind } from './Thing.js';
4
4
  import v4 from '../lib/uuid.js';
5
5
  import { ARCVariable } from './legacy/models/Variable.js';
6
+ import { IRequestAuthorization, RequestAuthorization } from './RequestAuthorization.js';
6
7
 
7
8
  export const Kind = 'Core#Environment';
8
9
 
@@ -46,7 +47,7 @@ export interface IEnvironment {
46
47
  /**
47
48
  * The security to be applied to all requests that are going to this environment.
48
49
  */
49
- security?: unknown;
50
+ authorization?: IRequestAuthorization[];
50
51
  }
51
52
 
52
53
  /**
@@ -82,7 +83,7 @@ export class Environment {
82
83
  /**
83
84
  * The security to be applied to all requests that are going to this server.
84
85
  */
85
- security?: unknown;
86
+ authorization?: RequestAuthorization[];
86
87
 
87
88
  /**
88
89
  * Creates a new Environment object from a name.
@@ -151,11 +152,15 @@ export class Environment {
151
152
  if (!Environment.isEnvironment(init)) {
152
153
  throw new Error(`Not an environment.`);
153
154
  }
154
- const { key = v4(), variables, info, server, encapsulated = false, security } = init;
155
+ const { key = v4(), variables, info, server, encapsulated = false, authorization } = init;
155
156
  this.kind = Kind;
156
157
  this.key = key;
157
158
  this.encapsulated = encapsulated;
158
- this.security = security;
159
+ if (Array.isArray(authorization)) {
160
+ this.authorization = authorization.map(i => new RequestAuthorization(i));
161
+ } else {
162
+ this.authorization = undefined;
163
+ }
159
164
  if (Array.isArray(variables)) {
160
165
  this.variables = variables.map(i => new Property(i))
161
166
  } else {
@@ -196,9 +201,8 @@ export class Environment {
196
201
  if (server) {
197
202
  result.server = server.toJSON();
198
203
  }
199
- if (this.security) {
200
- // TODO: When this is defined then call toJSON().
201
- result.security = this.security;
204
+ if (Array.isArray(this.authorization)) {
205
+ result.authorization = this.authorization.map(i => i.toJSON());
202
206
  }
203
207
  return result;
204
208
  }
@@ -66,7 +66,7 @@ export class ErrorResponse extends HttpResponse {
66
66
  /**
67
67
  * @param input The request definition used to restore the state.
68
68
  */
69
- constructor(input?: string|IErrorResponse) {
69
+ constructor(input?: string | IErrorResponse) {
70
70
  super(input);
71
71
  let init: IErrorResponse;
72
72
  if (typeof input === 'string') {
@@ -1,11 +1,10 @@
1
- import { SerializablePayload, SerializablePayloadOptions } from './SerializablePayload.js';
2
- import { Payload } from '../lib/transformers/PayloadSerializer.js';
1
+ import { ISerializablePayload, SerializablePayload, SerializablePayloadOptions } from './SerializablePayload.js';
3
2
  import { IProperty } from './Property.js';
4
3
  import { HeadersArray } from './HeadersArray.js';
5
4
 
6
5
  export const Kind = 'Core#HttpRequest';
7
6
 
8
- export interface IBaseHttpRequest {
7
+ export interface IBaseHttpRequest extends ISerializablePayload {
9
8
  /**
10
9
  * The request URL
11
10
  */
@@ -19,10 +18,6 @@ export interface IBaseHttpRequest {
19
18
  * HTTP headers string
20
19
  */
21
20
  headers?: string;
22
- /**
23
- * The request payload.
24
- */
25
- payload?: Payload;
26
21
  }
27
22
 
28
23
  /**
@@ -136,8 +131,9 @@ export class HttpRequest extends SerializablePayload {
136
131
  return true;
137
132
  }
138
133
 
139
- toJSON(): IHttpRequest {
134
+ override toJSON(): IHttpRequest {
140
135
  const result: IHttpRequest = {
136
+ ...super.toJSON(),
141
137
  kind: this.kind,
142
138
  url: this.url,
143
139
  method: this.method,
@@ -145,15 +141,9 @@ export class HttpRequest extends SerializablePayload {
145
141
  if (this.headers) {
146
142
  result.headers = this.headers;
147
143
  }
148
- if (this.payload) {
149
- result.payload = this.payload;
150
- }
151
144
  if (this.headersModel) {
152
145
  result.headersModel = this.headersModel.toJSON();
153
146
  }
154
- if (this.payloadOptions) {
155
- result.payloadOptions = { ...this.payloadOptions };
156
- }
157
147
  return result;
158
148
  }
159
149
 
@@ -1,11 +1,11 @@
1
- import { SerializablePayload } from './SerializablePayload.js';
2
- import { Payload, PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
1
+ import { ISerializablePayload, SerializablePayload } from './SerializablePayload.js';
2
+ import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
3
3
  import { HTTPResponse as LegacyHttpResponse } from './legacy/request/ArcResponse.js';
4
4
  import { Normalizer } from './legacy/Normalizer.js';
5
5
 
6
6
  export const Kind = 'Core#HttpResponse';
7
7
 
8
- export interface IHttpResponse {
8
+ export interface IHttpResponse extends ISerializablePayload {
9
9
  kind?: string;
10
10
  /**
11
11
  * The response status code
@@ -19,10 +19,6 @@ export interface IHttpResponse {
19
19
  * The response headers
20
20
  */
21
21
  headers?: string;
22
- /**
23
- * The response message
24
- */
25
- payload?: Payload;
26
22
  }
27
23
 
28
24
  export class HttpResponse extends SerializablePayload {
@@ -116,8 +112,9 @@ export class HttpResponse extends SerializablePayload {
116
112
  return true;
117
113
  }
118
114
 
119
- toJSON(): IHttpResponse {
115
+ override toJSON(): IHttpResponse {
120
116
  const result: IHttpResponse = {
117
+ ...super.toJSON(),
121
118
  kind: this.kind,
122
119
  status: this.status,
123
120
  };
@@ -127,9 +124,6 @@ export class HttpResponse extends SerializablePayload {
127
124
  if (this.headers) {
128
125
  result.headers = this.headers;
129
126
  }
130
- if (this.payload) {
131
- result.payload = this.payload;
132
- }
133
127
  return result;
134
128
  }
135
129
 
@@ -0,0 +1,227 @@
1
+ import { Core as JsonCore } from '@api-client/json'
2
+ import { IRequestLog } from "./RequestLog.js";
3
+
4
+ export const Kind = 'Core#ProjectExecution';
5
+
6
+ export interface IProjectExecutionIteration {
7
+ /**
8
+ * The index of the iteration.
9
+ */
10
+ index: number;
11
+ /**
12
+ * The list of requests executed in the iteration.
13
+ */
14
+ executed: IRequestLog[];
15
+ /**
16
+ * The variables evaluated during the run.
17
+ * These variables have values set by requests' HTTP flows.
18
+ */
19
+ variables: Record<string, string>;
20
+ /**
21
+ * Optional general error message.
22
+ */
23
+ error?: string;
24
+ }
25
+
26
+ export interface IProjectExecutionLog {
27
+ /**
28
+ * The timestamp when the execution started
29
+ */
30
+ started: number;
31
+ /**
32
+ * The timestamp when the execution ended
33
+ */
34
+ ended: number;
35
+ /**
36
+ * The execution logs for each iteration.
37
+ */
38
+ iterations: IProjectExecutionIteration[];
39
+ }
40
+
41
+ export interface IProjectExecution extends IProjectExecutionLog {
42
+ kind: typeof Kind;
43
+ /**
44
+ * The key of the execution entry. This is generated by the store. Client value is ignored.
45
+ */
46
+ key: string;
47
+
48
+ /**
49
+ * The key of the parent project.
50
+ */
51
+ project: string;
52
+
53
+ /**
54
+ * The key of the parent folder, if any.
55
+ */
56
+ parent?: string;
57
+
58
+ /**
59
+ * The application id that generated the entry.
60
+ */
61
+ app: string;
62
+
63
+ /**
64
+ * The user id that made that request.
65
+ * This is only available when the store support multi-user environment.
66
+ */
67
+ user?: string;
68
+
69
+ /**
70
+ * A timestamp of the midnight when the object was created.
71
+ */
72
+ midnight: number;
73
+ }
74
+
75
+ export class ProjectExecution implements IProjectExecution {
76
+ kind: typeof Kind = Kind;
77
+
78
+ /**
79
+ * The key of the execution entry. This is generated by the store. Client value is ignored.
80
+ */
81
+ key = '';
82
+
83
+ /**
84
+ * The key of the parent project.
85
+ */
86
+ project = '';
87
+
88
+ /**
89
+ * The key of the parent folder, if any.
90
+ */
91
+ parent?: string;
92
+
93
+ /**
94
+ * The application id that generated the entry.
95
+ */
96
+ app = '';
97
+
98
+ /**
99
+ * The user id that made that request.
100
+ * This is only available when the store support multi-user environment.
101
+ */
102
+ user?: string;
103
+
104
+ /**
105
+ * @param value The timestamp of the midnight when the request object was updated
106
+ */
107
+ set midnight(value: number | undefined) {
108
+ if (!value) {
109
+ this.midnightInternal = this.defaultMidnight();
110
+ } else {
111
+ this.midnightInternal = value;
112
+ }
113
+ }
114
+
115
+ /**
116
+ * @returns The timestamp of the midnight when the request object was updated
117
+ */
118
+ get midnight(): number {
119
+ if (this.midnightInternal) {
120
+ return this.midnightInternal;
121
+ }
122
+ return this.defaultMidnight();
123
+ }
124
+
125
+ private midnightInternal = 0;
126
+
127
+ /**
128
+ * The timestamp when the execution started
129
+ */
130
+ started = 0;
131
+
132
+ /**
133
+ * The timestamp when the execution ended
134
+ */
135
+ ended = 0;
136
+
137
+ /**
138
+ * The execution logs for each iteration.
139
+ */
140
+ iterations: IProjectExecutionIteration[] = [];
141
+
142
+
143
+ constructor(input?: string | IProjectExecution) {
144
+ let init: IProjectExecution;
145
+ if (typeof input === 'string') {
146
+ init = JSON.parse(input);
147
+ } else if (typeof input === 'object') {
148
+ init = input;
149
+ } else {
150
+ const now = Date.now();
151
+ init = {
152
+ kind: Kind,
153
+ user: '',
154
+ app: '',
155
+ key: '',
156
+ project: '',
157
+ ended: 0,
158
+ iterations: [],
159
+ midnight: 0,
160
+ started: now,
161
+ };
162
+ }
163
+ this.new(init);
164
+ }
165
+
166
+ new(init: IProjectExecution): void {
167
+ const { started = Date.now(), midnight, project, user, key, app, ended = started, iterations, parent } = init;
168
+ this.started = started;
169
+ this.ended = ended;
170
+ this.iterations = iterations.map(i => JsonCore.clone(i));
171
+ if (key) {
172
+ this.key = key;
173
+ } else {
174
+ this.key = '';
175
+ }
176
+ if (app) {
177
+ this.app = app;
178
+ } else {
179
+ this.app = '';
180
+ }
181
+ if (midnight) {
182
+ this.midnight = midnight;
183
+ }
184
+ if (project) {
185
+ this.project = project;
186
+ } else {
187
+ this.project = '';
188
+ }
189
+ if (parent) {
190
+ this.parent = parent;
191
+ } else {
192
+ this.parent = '';
193
+ }
194
+ if (user) {
195
+ this.user = user;
196
+ } else {
197
+ this.user = '';
198
+ }
199
+ }
200
+
201
+ toJSON(): IProjectExecution {
202
+ const result: IProjectExecution = {
203
+ kind: Kind,
204
+ midnight: this.midnight,
205
+ user: this.user,
206
+ key: this.key,
207
+ project: this.project,
208
+ app: this.app,
209
+ ended: this.ended,
210
+ iterations: this.iterations.map(i => JsonCore.clone(i)),
211
+ started: this.started,
212
+ };
213
+ if (this.parent) {
214
+ result.parent = this.parent;
215
+ }
216
+ return result;
217
+ }
218
+
219
+ /**
220
+ * @returns The default value for the midnight when the request was last updated.
221
+ */
222
+ defaultMidnight(): number {
223
+ const d = new Date(this.started);
224
+ d.setHours(0, 0, 0, 0);
225
+ return d.getTime();
226
+ }
227
+ }
@@ -9,6 +9,7 @@ import { Environment } from './Environment.js';
9
9
  import { Property } from './Property.js';
10
10
  import { Server } from './Server.js';
11
11
  import { UriTemplate } from '../lib/parsers/UriTemplate.js';
12
+ import { RequestAuthorization } from './RequestAuthorization.js';
12
13
 
13
14
  export const Kind = 'Core#ProjectRequest';
14
15
 
@@ -485,4 +486,57 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
485
486
  }
486
487
  return result;
487
488
  }
489
+
490
+ /**
491
+ * Reads the authorization that should be applied to the request.
492
+ *
493
+ * 1) First it returns the locally (on the request) defined authorization.
494
+ * 2) Then it returns authorization defined on the selected environment.
495
+ * 3) If has defined environment but no authorization on it, then it returns empty array.
496
+ * 4) Only if the request has no selected environment then it reads first environment
497
+ * that has authorization (from the request up to the project's root).
498
+ */
499
+ readAuthorization(): RequestAuthorization[] {
500
+ if (Array.isArray(this.authorization) && this.authorization.length) {
501
+ return this.authorization;
502
+ }
503
+ const envAuth = this.readEnvironmentAuthorization();
504
+ if (envAuth) {
505
+ return envAuth;
506
+ }
507
+ if (this.environment) {
508
+ return [];
509
+ }
510
+ const inherited = this.readEnvironmentsAuthorization();
511
+ if (inherited) {
512
+ return inherited;
513
+ }
514
+ return [];
515
+ }
516
+
517
+ /**
518
+ * @returns Authorization defined on the selected environment or undefined.
519
+ */
520
+ protected readEnvironmentAuthorization(): RequestAuthorization[] | undefined {
521
+ const selfEnv = this.getEnvironment();
522
+ if (!selfEnv) {
523
+ return undefined;
524
+ }
525
+ if (Array.isArray(selfEnv.authorization) && selfEnv.authorization.length) {
526
+ return selfEnv.authorization;
527
+ }
528
+ return undefined;
529
+ }
530
+
531
+ /**
532
+ * @returns Authorization defined on any inherited environment or undefined.
533
+ */
534
+ protected readEnvironmentsAuthorization(): RequestAuthorization[] | undefined {
535
+ const envs = this.readEnvironments();
536
+ const authEnv = envs.find(i => Array.isArray(i.authorization) && !!i.authorization.length);
537
+ if (authEnv) {
538
+ return authEnv.authorization as RequestAuthorization[];
539
+ }
540
+ return undefined;
541
+ }
488
542
  }