@api-client/core 0.6.29 → 0.7.0

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 (325) hide show
  1. package/build/browser.d.ts +6 -14
  2. package/build/browser.js +11 -16
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +8 -20
  5. package/build/index.js +13 -25
  6. package/build/index.js.map +1 -1
  7. package/build/src/amf/ApiSchemaValues.d.ts +2 -0
  8. package/build/src/amf/ApiSchemaValues.js +29 -23
  9. package/build/src/amf/ApiSchemaValues.js.map +1 -1
  10. package/build/src/authorization/lib/Utils.d.ts +1 -1
  11. package/build/src/cookies/CookieJar.d.ts +23 -0
  12. package/build/src/cookies/CookieJar.js +3 -0
  13. package/build/src/cookies/CookieJar.js.map +1 -0
  14. package/build/src/cookies/CookieParser.d.ts +67 -0
  15. package/build/src/cookies/CookieParser.js +316 -0
  16. package/build/src/cookies/CookieParser.js.map +1 -0
  17. package/build/src/cookies/InMemoryCookieJar.d.ts +12 -0
  18. package/build/src/cookies/InMemoryCookieJar.js +68 -0
  19. package/build/src/cookies/InMemoryCookieJar.js.map +1 -0
  20. package/build/src/cookies/Punycode.d.ts +12 -0
  21. package/build/src/cookies/Punycode.js +124 -0
  22. package/build/src/cookies/Punycode.js.map +1 -0
  23. package/build/src/data/RequestDataExtractor.d.ts +8 -7
  24. package/build/src/data/RequestDataExtractor.js +8 -10
  25. package/build/src/data/RequestDataExtractor.js.map +1 -1
  26. package/build/src/events/CustomEvent.js +5 -0
  27. package/build/src/events/CustomEvent.js.map +1 -1
  28. package/build/src/events/EventTypes.d.ts +43 -43
  29. package/build/src/events/amf/AmfEventTypes.d.ts +4 -4
  30. package/build/src/events/authorization/AuthorizationEventTypes.d.ts +4 -4
  31. package/build/src/events/cookies/CookieEventTypes.d.ts +9 -9
  32. package/build/src/events/encryption/EncryptionEventTypes.d.ts +2 -2
  33. package/build/src/events/environment/EnvironmentEventTypes.d.ts +1 -1
  34. package/build/src/events/models/ModelEventTypes.d.ts +7 -7
  35. package/build/src/events/process/ProcessEventTypes.d.ts +3 -3
  36. package/build/src/events/reporting/ReportingEventTypes.d.ts +1 -1
  37. package/build/src/events/telemetry/TelemetryEventTypes.d.ts +6 -6
  38. package/build/src/events/transport/TransportEventTypes.d.ts +6 -6
  39. package/build/src/events/transport/TransportEvents.d.ts +2 -2
  40. package/build/src/mocking/ProjectMock.d.ts +3 -2
  41. package/build/src/mocking/ProjectMock.js +3 -3
  42. package/build/src/mocking/ProjectMock.js.map +1 -1
  43. package/build/src/mocking/lib/App.d.ts +36 -0
  44. package/build/src/mocking/lib/App.js +70 -0
  45. package/build/src/mocking/lib/App.js.map +1 -0
  46. package/build/src/models/{arc/ArcProject.d.ts → AppProject.d.ts} +296 -134
  47. package/build/src/models/{arc/ArcProject.js → AppProject.js} +436 -79
  48. package/build/src/models/AppProject.js.map +1 -0
  49. package/build/src/models/AppRequest.d.ts +69 -0
  50. package/build/src/models/AppRequest.js +150 -0
  51. package/build/src/models/AppRequest.js.map +1 -0
  52. package/build/src/models/ClientCertificate.d.ts +2 -2
  53. package/build/src/models/Environment.d.ts +8 -1
  54. package/build/src/models/Environment.js +21 -0
  55. package/build/src/models/Environment.js.map +1 -1
  56. package/build/src/models/HostRule.d.ts +2 -2
  57. package/build/src/models/HttpCookie.d.ts +63 -12
  58. package/build/src/models/HttpCookie.js +178 -44
  59. package/build/src/models/HttpCookie.js.map +1 -1
  60. package/build/src/models/HttpHistory.d.ts +8 -3
  61. package/build/src/models/HttpHistory.js +3 -3
  62. package/build/src/models/HttpHistory.js.map +1 -1
  63. package/build/src/models/HttpProject.d.ts +34 -1
  64. package/build/src/models/HttpProject.js +104 -8
  65. package/build/src/models/HttpProject.js.map +1 -1
  66. package/build/src/models/ProjectFolder.d.ts +2 -0
  67. package/build/src/models/ProjectFolder.js +14 -0
  68. package/build/src/models/ProjectFolder.js.map +1 -1
  69. package/build/src/models/ProjectItem.d.ts +2 -0
  70. package/build/src/models/ProjectItem.js +20 -0
  71. package/build/src/models/ProjectItem.js.map +1 -1
  72. package/build/src/models/ProjectParent.js.map +1 -1
  73. package/build/src/models/ProjectRequest.d.ts +3 -2
  74. package/build/src/models/ProjectRequest.js.map +1 -1
  75. package/build/src/models/Property.d.ts +2 -2
  76. package/build/src/models/Property.js +2 -2
  77. package/build/src/models/Property.js.map +1 -1
  78. package/build/src/models/Request.d.ts +16 -8
  79. package/build/src/models/Request.js +20 -15
  80. package/build/src/models/Request.js.map +1 -1
  81. package/build/src/models/RequestAuthorization.js.map +1 -1
  82. package/build/src/models/RequestUiMeta.d.ts +0 -14
  83. package/build/src/models/RequestUiMeta.js +1 -10
  84. package/build/src/models/RequestUiMeta.js.map +1 -1
  85. package/build/src/models/Server.d.ts +1 -2
  86. package/build/src/models/Server.js.map +1 -1
  87. package/build/src/models/http-actions/HttpActions.d.ts +256 -0
  88. package/build/src/models/http-actions/HttpActions.js +46 -0
  89. package/build/src/models/http-actions/HttpActions.js.map +1 -0
  90. package/build/src/models/http-actions/LegacyTranslator.d.ts +17 -0
  91. package/build/src/models/http-actions/LegacyTranslator.js +222 -0
  92. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -0
  93. package/build/src/models/store/Backend.d.ts +136 -1
  94. package/build/src/models/store/File.d.ts +1 -1
  95. package/build/src/models/store/File.js +2 -0
  96. package/build/src/models/store/File.js.map +1 -1
  97. package/build/src/models/store/User.d.ts +3 -3
  98. package/build/src/runtime/http-engine/CoreEngine.d.ts +2 -0
  99. package/build/src/runtime/http-engine/CoreEngine.js +1 -0
  100. package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
  101. package/build/src/runtime/http-engine/HttpEngine.d.ts +13 -0
  102. package/build/src/runtime/http-engine/HttpEngine.js +39 -31
  103. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  104. package/build/src/runtime/{actions/ConditionRunner.d.ts → http-runner/ConditionCheck.d.ts} +2 -2
  105. package/build/src/runtime/{actions/ConditionRunner.js → http-runner/ConditionCheck.js} +2 -2
  106. package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -0
  107. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +62 -0
  108. package/build/src/runtime/http-runner/HttpFlowRunner.js +217 -0
  109. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -0
  110. package/build/src/runtime/{node/RequestFactory.d.ts → http-runner/HttpRequestRunner.d.ts} +40 -54
  111. package/build/src/runtime/http-runner/HttpRequestRunner.js +316 -0
  112. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -0
  113. package/build/src/runtime/http-runner/HttpRuntimeEnvironment.d.ts +25 -0
  114. package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js +2 -0
  115. package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js.map +1 -0
  116. package/build/src/runtime/http-runner/RequestAuthorizationProcessor.d.ts +56 -0
  117. package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js +143 -0
  118. package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js.map +1 -0
  119. package/build/src/runtime/http-runner/RequestCookiesProcessor.d.ts +24 -0
  120. package/build/src/runtime/http-runner/RequestCookiesProcessor.js +65 -0
  121. package/build/src/runtime/http-runner/RequestCookiesProcessor.js.map +1 -0
  122. package/build/src/runtime/node/InteropInterfaces.d.ts +21 -6
  123. package/build/src/runtime/node/ProjectParallelRunner.js +3 -1
  124. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  125. package/build/src/runtime/node/ProjectRequestRunner.d.ts +24 -10
  126. package/build/src/runtime/node/ProjectRequestRunner.js +116 -45
  127. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  128. package/build/src/runtime/node/ProjectRunner.d.ts +5 -7
  129. package/build/src/runtime/node/ProjectRunner.js +30 -14
  130. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  131. package/build/src/runtime/node/ProjectRunnerWorker.js +3 -0
  132. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
  133. package/build/src/runtime/reporters/Reporter.d.ts +5 -0
  134. package/build/src/runtime/reporters/Reporter.js.map +1 -1
  135. package/build/src/runtime/store/FilesSdk.js +4 -4
  136. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  137. package/build/src/runtime/store/HistorySdk.js +1 -1
  138. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  139. package/build/src/runtime/store/HttpClientSdk.d.ts +167 -0
  140. package/build/src/runtime/store/HttpClientSdk.js +624 -0
  141. package/build/src/runtime/store/HttpClientSdk.js.map +1 -0
  142. package/build/src/runtime/store/RouteBuilder.d.ts +17 -2
  143. package/build/src/runtime/store/RouteBuilder.js +60 -3
  144. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  145. package/build/src/runtime/store/Sdk.d.ts +5 -0
  146. package/build/src/runtime/store/Sdk.js +5 -0
  147. package/build/src/runtime/store/Sdk.js.map +1 -1
  148. package/build/src/runtime/store/SharedSdk.js +1 -1
  149. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  150. package/build/src/runtime/store/UsersSdk.js +1 -1
  151. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  152. package/package.json +2 -2
  153. package/src/amf/ApiSchemaValues.ts +41 -33
  154. package/src/cookies/CookieJar.ts +26 -0
  155. package/src/cookies/CookieParser.ts +327 -0
  156. package/src/cookies/InMemoryCookieJar.ts +70 -0
  157. package/src/cookies/Punycode.ts +133 -0
  158. package/src/data/RequestDataExtractor.ts +14 -15
  159. package/src/events/CustomEvent.ts +4 -0
  160. package/src/mocking/ProjectMock.ts +4 -3
  161. package/src/mocking/lib/App.ts +101 -0
  162. package/src/models/{arc/ArcProject.ts → AppProject.ts} +671 -225
  163. package/src/models/AppRequest.ts +176 -0
  164. package/src/models/ClientCertificate.ts +2 -2
  165. package/src/models/Environment.ts +24 -2
  166. package/src/models/HostRule.ts +2 -2
  167. package/src/models/HttpCookie.ts +210 -48
  168. package/src/models/HttpHistory.ts +12 -5
  169. package/src/models/HttpProject.ts +113 -10
  170. package/src/models/ProjectFolder.ts +16 -0
  171. package/src/models/ProjectItem.ts +18 -0
  172. package/src/models/ProjectParent.ts +4 -1
  173. package/src/models/ProjectRequest.ts +4 -3
  174. package/src/models/Property.ts +4 -4
  175. package/src/models/Request.ts +29 -19
  176. package/src/models/RequestAuthorization.ts +4 -4
  177. package/src/models/RequestUiMeta.ts +1 -21
  178. package/src/models/Server.ts +1 -2
  179. package/src/models/http-actions/HttpActions.ts +270 -0
  180. package/src/models/http-actions/LegacyTranslator.ts +223 -0
  181. package/src/models/store/Backend.ts +148 -2
  182. package/src/models/store/File.ts +3 -1
  183. package/src/models/store/User.ts +3 -3
  184. package/src/runtime/http-engine/CoreEngine.ts +3 -2
  185. package/src/runtime/http-engine/HttpEngine.ts +48 -30
  186. package/src/runtime/{actions/ConditionRunner.ts → http-runner/ConditionCheck.ts} +3 -3
  187. package/src/runtime/http-runner/HttpFlowRunner.ts +232 -0
  188. package/src/runtime/http-runner/HttpRequestRunner.ts +353 -0
  189. package/src/runtime/http-runner/HttpRuntimeEnvironment.ts +27 -0
  190. package/src/runtime/http-runner/RequestAuthorizationProcessor.ts +144 -0
  191. package/src/runtime/http-runner/RequestCookiesProcessor.ts +74 -0
  192. package/src/runtime/node/InteropInterfaces.ts +24 -6
  193. package/src/runtime/node/ProjectParallelRunner.ts +4 -2
  194. package/src/runtime/node/ProjectRequestRunner.ts +130 -60
  195. package/src/runtime/node/ProjectRunner.ts +37 -22
  196. package/src/runtime/node/ProjectRunnerWorker.ts +3 -0
  197. package/src/runtime/reporters/Reporter.ts +5 -0
  198. package/src/runtime/store/FilesSdk.ts +4 -4
  199. package/src/runtime/store/HistorySdk.ts +1 -1
  200. package/src/runtime/store/HttpClientSdk.ts +629 -0
  201. package/src/runtime/store/RouteBuilder.ts +75 -3
  202. package/src/runtime/store/Sdk.ts +6 -0
  203. package/src/runtime/store/SharedSdk.ts +1 -1
  204. package/src/runtime/store/UsersSdk.ts +1 -1
  205. package/build/src/lib/cookies/Cookie.d.ts +0 -123
  206. package/build/src/lib/cookies/Cookie.js +0 -257
  207. package/build/src/lib/cookies/Cookie.js.map +0 -1
  208. package/build/src/lib/cookies/Cookies.d.ts +0 -90
  209. package/build/src/lib/cookies/Cookies.js +0 -310
  210. package/build/src/lib/cookies/Cookies.js.map +0 -1
  211. package/build/src/lib/cookies/Utils.d.ts +0 -47
  212. package/build/src/lib/cookies/Utils.js +0 -163
  213. package/build/src/lib/cookies/Utils.js.map +0 -1
  214. package/build/src/mocking/lib/Arc.d.ts +0 -10
  215. package/build/src/mocking/lib/Arc.js +0 -31
  216. package/build/src/mocking/lib/Arc.js.map +0 -1
  217. package/build/src/models/RequestActions.d.ts +0 -65
  218. package/build/src/models/RequestActions.js +0 -114
  219. package/build/src/models/RequestActions.js.map +0 -1
  220. package/build/src/models/actions/Action.d.ts +0 -75
  221. package/build/src/models/actions/Action.js +0 -188
  222. package/build/src/models/actions/Action.js.map +0 -1
  223. package/build/src/models/actions/ActionView.d.ts +0 -15
  224. package/build/src/models/actions/ActionView.js +0 -33
  225. package/build/src/models/actions/ActionView.js.map +0 -1
  226. package/build/src/models/actions/Condition.d.ts +0 -81
  227. package/build/src/models/actions/Condition.js +0 -185
  228. package/build/src/models/actions/Condition.js.map +0 -1
  229. package/build/src/models/actions/ConditionView.d.ts +0 -17
  230. package/build/src/models/actions/ConditionView.js +0 -34
  231. package/build/src/models/actions/ConditionView.js.map +0 -1
  232. package/build/src/models/actions/Enums.d.ts +0 -26
  233. package/build/src/models/actions/Enums.js +0 -31
  234. package/build/src/models/actions/Enums.js.map +0 -1
  235. package/build/src/models/actions/RunnableAction.d.ts +0 -59
  236. package/build/src/models/actions/RunnableAction.js +0 -106
  237. package/build/src/models/actions/RunnableAction.js.map +0 -1
  238. package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +0 -44
  239. package/build/src/models/actions/runnable/DeleteCookieAction.js +0 -92
  240. package/build/src/models/actions/runnable/DeleteCookieAction.js.map +0 -1
  241. package/build/src/models/actions/runnable/Runnable.d.ts +0 -8
  242. package/build/src/models/actions/runnable/Runnable.js +0 -4
  243. package/build/src/models/actions/runnable/Runnable.js.map +0 -1
  244. package/build/src/models/actions/runnable/SetCookieAction.d.ts +0 -87
  245. package/build/src/models/actions/runnable/SetCookieAction.js +0 -176
  246. package/build/src/models/actions/runnable/SetCookieAction.js.map +0 -1
  247. package/build/src/models/actions/runnable/SetVariableAction.d.ts +0 -31
  248. package/build/src/models/actions/runnable/SetVariableAction.js +0 -63
  249. package/build/src/models/actions/runnable/SetVariableAction.js.map +0 -1
  250. package/build/src/models/actions/runnable/index.d.ts +0 -7
  251. package/build/src/models/actions/runnable/index.js +0 -2
  252. package/build/src/models/actions/runnable/index.js.map +0 -1
  253. package/build/src/models/arc/ArcHttpRequest.d.ts +0 -39
  254. package/build/src/models/arc/ArcHttpRequest.js +0 -106
  255. package/build/src/models/arc/ArcHttpRequest.js.map +0 -1
  256. package/build/src/models/arc/ArcProject.js.map +0 -1
  257. package/build/src/runtime/actions/ActionRunner.d.ts +0 -17
  258. package/build/src/runtime/actions/ActionRunner.js +0 -74
  259. package/build/src/runtime/actions/ActionRunner.js.map +0 -1
  260. package/build/src/runtime/actions/ConditionRunner.js.map +0 -1
  261. package/build/src/runtime/actions/RunnableCondition.d.ts +0 -27
  262. package/build/src/runtime/actions/RunnableCondition.js +0 -50
  263. package/build/src/runtime/actions/RunnableCondition.js.map +0 -1
  264. package/build/src/runtime/actions/runnable/ActionRunnable.d.ts +0 -13
  265. package/build/src/runtime/actions/runnable/ActionRunnable.js +0 -13
  266. package/build/src/runtime/actions/runnable/ActionRunnable.js.map +0 -1
  267. package/build/src/runtime/actions/runnable/DeleteCookieRunnable.d.ts +0 -7
  268. package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +0 -36
  269. package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +0 -1
  270. package/build/src/runtime/actions/runnable/SetCookieRunnable.d.ts +0 -10
  271. package/build/src/runtime/actions/runnable/SetCookieRunnable.js +0 -89
  272. package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +0 -1
  273. package/build/src/runtime/actions/runnable/SetVariableRunnable.d.ts +0 -10
  274. package/build/src/runtime/actions/runnable/SetVariableRunnable.js +0 -49
  275. package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +0 -1
  276. package/build/src/runtime/modules/BasicAuthCache.d.ts +0 -39
  277. package/build/src/runtime/modules/BasicAuthCache.js +0 -122
  278. package/build/src/runtime/modules/BasicAuthCache.js.map +0 -1
  279. package/build/src/runtime/modules/ExecutionResponse.d.ts +0 -4
  280. package/build/src/runtime/modules/ExecutionResponse.js +0 -6
  281. package/build/src/runtime/modules/ExecutionResponse.js.map +0 -1
  282. package/build/src/runtime/modules/ModulesRegistry.d.ts +0 -93
  283. package/build/src/runtime/modules/ModulesRegistry.js +0 -69
  284. package/build/src/runtime/modules/ModulesRegistry.js.map +0 -1
  285. package/build/src/runtime/modules/RequestAuthorization.d.ts +0 -6
  286. package/build/src/runtime/modules/RequestAuthorization.js +0 -110
  287. package/build/src/runtime/modules/RequestAuthorization.js.map +0 -1
  288. package/build/src/runtime/modules/RequestCookies.d.ts +0 -17
  289. package/build/src/runtime/modules/RequestCookies.js +0 -134
  290. package/build/src/runtime/modules/RequestCookies.js.map +0 -1
  291. package/build/src/runtime/node/RequestFactory.js +0 -406
  292. package/build/src/runtime/node/RequestFactory.js.map +0 -1
  293. package/build/src/runtime/node/VariablesStore.d.ts +0 -9
  294. package/build/src/runtime/node/VariablesStore.js +0 -19
  295. package/build/src/runtime/node/VariablesStore.js.map +0 -1
  296. package/src/lib/cookies/Cookie.ts +0 -312
  297. package/src/lib/cookies/Cookies.ts +0 -326
  298. package/src/lib/cookies/Utils.ts +0 -168
  299. package/src/mocking/lib/Arc.ts +0 -34
  300. package/src/models/RequestActions.ts +0 -161
  301. package/src/models/actions/Action.ts +0 -213
  302. package/src/models/actions/ActionView.ts +0 -40
  303. package/src/models/actions/Condition.ts +0 -207
  304. package/src/models/actions/ConditionView.ts +0 -42
  305. package/src/models/actions/Enums.ts +0 -29
  306. package/src/models/actions/RunnableAction.ts +0 -144
  307. package/src/models/actions/runnable/DeleteCookieAction.ts +0 -113
  308. package/src/models/actions/runnable/Runnable.ts +0 -9
  309. package/src/models/actions/runnable/SetCookieAction.ts +0 -216
  310. package/src/models/actions/runnable/SetVariableAction.ts +0 -81
  311. package/src/models/arc/ArcHttpRequest.ts +0 -121
  312. package/src/models/arc/readme.md +0 -3
  313. package/src/runtime/actions/ActionRunner.ts +0 -83
  314. package/src/runtime/actions/RunnableCondition.ts +0 -56
  315. package/src/runtime/actions/runnable/ActionRunnable.ts +0 -19
  316. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +0 -39
  317. package/src/runtime/actions/runnable/SetCookieRunnable.ts +0 -92
  318. package/src/runtime/actions/runnable/SetVariableRunnable.ts +0 -53
  319. package/src/runtime/modules/BasicAuthCache.ts +0 -129
  320. package/src/runtime/modules/ExecutionResponse.ts +0 -4
  321. package/src/runtime/modules/ModulesRegistry.ts +0 -136
  322. package/src/runtime/modules/RequestAuthorization.ts +0 -106
  323. package/src/runtime/modules/RequestCookies.ts +0 -146
  324. package/src/runtime/node/RequestFactory.ts +0 -432
  325. package/src/runtime/node/VariablesStore.ts +0 -25
@@ -1,20 +1,21 @@
1
1
  import { EventEmitter } from 'events';
2
- import { Environment } from '../../models/Environment.js';
2
+ import { Environment, Kind as EnvironmentKind } from '../../models/Environment.js';
3
3
  import { Logger } from '../../lib/logging/Logger.js';
4
4
  import { IRequestLog, RequestLog } from '../../models/RequestLog.js';
5
5
  import { Property } from '../../models/Property.js';
6
6
  import { ProjectFolder, Kind as ProjectFolderKind } from '../../models/ProjectFolder.js';
7
- import { ProjectRequest } from '../../models/ProjectRequest.js';
7
+ import { ProjectRequest, Kind as ProjectRequestKind } from '../../models/ProjectRequest.js';
8
8
  import { IHttpRequest } from '../../models/HttpRequest.js';
9
9
  import { HttpProject } from '../../models/HttpProject.js';
10
10
  import { SentRequest } from '../../models/SentRequest.js';
11
11
  import { ErrorResponse } from '../../models/ErrorResponse.js';
12
- import { VariablesStore } from './VariablesStore.js';
13
12
  import { VariablesProcessor } from '../variables/VariablesProcessor.js';
14
- import { RequestFactory } from './RequestFactory.js';
15
- import { EventTypes } from '../../events/EventTypes.js';
16
- import { ProjectRunnerOptions, ProjectRunnerRunOptions, RunResult } from './InteropInterfaces.js';
13
+ import { IProjectExecutionResult, IRequestRunnerOptions, IRequestRunnerRunOptions, IRunResult } from './InteropInterfaces.js';
17
14
  import { State } from './enums.js';
15
+ import { HttpRequestRunner } from '../http-runner/HttpRequestRunner.js';
16
+ import { CookieJar } from '../../cookies/CookieJar.js';
17
+ import { AppProject, AppProjectFolder, AppProjectFolderKind, AppProjectItem, AppProjectRequest, AppProjectRequestKind } from '../../models/AppProject.js';
18
+ import { ProjectItem } from '../../models/ProjectItem.js';
18
19
 
19
20
  export interface ProjectRequestRunner {
20
21
  /**
@@ -51,9 +52,12 @@ export interface ProjectRequestRunner {
51
52
  * Requests are executed in order defined in the folder.
52
53
  */
53
54
  export class ProjectRequestRunner extends EventEmitter {
54
- eventTarget: EventTarget;
55
55
  logger?: Logger;
56
- project: HttpProject;
56
+ project: HttpProject | AppProject;
57
+ /**
58
+ * An instance of a cookie jar (store) to put/read cookies.
59
+ */
60
+ cookies?: CookieJar;
57
61
 
58
62
  protected masterEnvironment?: Environment;
59
63
  protected extraVariables?: Record<string, string>;
@@ -69,13 +73,13 @@ export class ProjectRequestRunner extends EventEmitter {
69
73
  return this._state;
70
74
  }
71
75
 
72
- constructor(project: HttpProject, opts: ProjectRunnerOptions = {}) {
76
+ constructor(project: HttpProject | AppProject, opts: IRequestRunnerOptions = {}) {
73
77
  super();
74
78
  this.project = project;
75
79
  this.logger = opts.logger;
76
- this.eventTarget = opts.eventTarget || new EventTarget();
77
80
  this.masterEnvironment = opts.environment;
78
81
  this.extraVariables = opts.variables;
82
+ this.cookies = opts.cookies;
79
83
  }
80
84
 
81
85
  /**
@@ -83,16 +87,104 @@ export class ProjectRequestRunner extends EventEmitter {
83
87
  * @param options Run options.
84
88
  * @returns A promise with the run result.
85
89
  */
86
- async run(options?: ProjectRunnerRunOptions): Promise<RunResult[]> {
87
- this._state = State.Running as State;
90
+ async run(options: IRequestRunnerRunOptions = {}): Promise<IProjectExecutionResult> {
88
91
  const { project } = this;
89
- const executed: RunResult[] = [];
90
- for (const request of project.requestIterator(options)) {
91
- const info = await this._runItem(request);
92
- executed.push(info);
92
+ const root = options.parent ? project.findFolder(options.parent) : project;
93
+ if (!root) {
94
+ throw new Error(`The parent folder not found: ${options.parent}.`);
95
+ }
96
+ const variables = await this.getVariables(root);
97
+ const executed: IRunResult[] = [];
98
+ for await (const result of this.runIterator(options, variables)) {
99
+ executed.push(result);
100
+ }
101
+ return {
102
+ items: executed,
103
+ variables,
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Creates an async iterator that allows to iterate over execution results.
109
+ * The result is yielded after the request is executed.
110
+ *
111
+ * @param options The iterator configuration.
112
+ */
113
+ protected async * runIterator(options: IRequestRunnerRunOptions = {}, variables?: Record<string, string>): AsyncGenerator<IRunResult> {
114
+ const { project } = this;
115
+ const root = options.parent ? project.findFolder(options.parent) : project;
116
+ if (!root) {
117
+ throw new Error(`The parent folder not found: ${options.parent}.`);
118
+ }
119
+
120
+ this._state = State.Running as State;
121
+ const envVariables = variables || await this.getVariables(root);
122
+ const { items } = root;
123
+ const it = this._runIterator(items, envVariables, options);
124
+ for await (const request of it) {
125
+ yield request;
126
+ }
127
+ }
128
+
129
+ protected async * _runIterator(items: (ProjectItem | AppProjectItem)[], variables: Record<string, string>, options: IRequestRunnerRunOptions): AsyncGenerator<IRunResult> {
130
+ for (const item of items) {
131
+ const current = item.getItem();
132
+ if (!current) {
133
+ continue;
134
+ }
135
+ if (current.kind === AppProjectRequestKind || current.kind === ProjectRequestKind) {
136
+ if (Array.isArray(options.ignore) && options.ignore.includes(current.key)) {
137
+ continue;
138
+ }
139
+ if (Array.isArray(options.requests) && !options.requests.includes(current.key) && !options.requests.includes(current.info.name || '')) {
140
+ continue;
141
+ }
142
+ const info = await this._runItem(current as AppProjectRequest | ProjectRequest, variables);
143
+ yield info;
144
+ } else if (current.kind === ProjectFolderKind || current.kind === AppProjectFolderKind) {
145
+ if (!options.recursive) {
146
+ continue;
147
+ }
148
+ const parent = current as ProjectFolder | AppProjectFolder;
149
+ // make a copy so the variables executed in the encapsulated environment won't leak out to the current environment.
150
+ let encapsulated = false;
151
+ // we restore the `baseUri` after exiting the folder.
152
+ const currentBaseUri = variables.baseUri;
153
+ const { items: parentItems } = parent;
154
+ const envItem = (parentItems as (ProjectItem | AppProjectItem)[]).find(i => i.kind === EnvironmentKind);
155
+ let parentVariables: Record<string, string> = {};
156
+ let childVariables = variables;
157
+ if (envItem) {
158
+ const parentEnv = envItem.getItem() as Environment | undefined;
159
+ if (parentEnv) {
160
+ encapsulated = parentEnv.encapsulated;
161
+ parentVariables = await this.applyVariables([parentEnv]);
162
+ if (encapsulated) {
163
+ childVariables = parentVariables;
164
+ } else {
165
+ childVariables = { ...childVariables, ...parentVariables };
166
+ }
167
+ }
168
+ }
169
+
170
+ const it = this._runIterator(parentItems, childVariables, options);
171
+ for await (const request of it) {
172
+ yield request;
173
+ }
174
+ if (!encapsulated) {
175
+ // now we set the variables set on children to the main variables object, except for these
176
+ // declared on the child environments, so these won't leak to other folders.
177
+ // However, variables set by a request in a folder always is propagated to the main environment.
178
+ const ignore: string[] = Object.keys(parentVariables);
179
+ Object.keys(childVariables).forEach((key) => {
180
+ if (!ignore.includes(key)) {
181
+ variables[key] = childVariables[key]
182
+ }
183
+ });
184
+ }
185
+ variables.baseUri = currentBaseUri;
186
+ }
93
187
  }
94
- this._state = State.Idle;
95
- return executed;
96
188
  }
97
189
 
98
190
  /**
@@ -116,46 +208,33 @@ export class ProjectRequestRunner extends EventEmitter {
116
208
  * }
117
209
  * ```
118
210
  */
119
- async* [Symbol.asyncIterator](): AsyncGenerator<RunResult> {
120
- const { project } = this;
121
- this._state = State.Running as State;
122
- for (const request of project.requestIterator({ recursive: true })) {
123
- const info = await this._runItem(request);
124
- yield info;
211
+ async* [Symbol.asyncIterator](): AsyncGenerator<IRunResult> {
212
+ for await (const result of this.runIterator({ recursive: true })) {
213
+ yield result;
125
214
  }
126
- this._state = State.Idle;
127
215
  }
128
216
 
129
- private async _runItem(request: ProjectRequest): Promise<RunResult> {
217
+ private async _runItem(request: ProjectRequest | AppProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
130
218
  if (this._state === State.Aborted) {
131
219
  throw new Error(`The execution has been aborted.`);
132
220
  }
133
- const folder = request.getParent();
134
- const parent = folder || this.project;
135
- let variables: Record<string, string>;
136
- if (VariablesStore.has(parent)) {
137
- variables = VariablesStore.get(parent);
138
- } else {
139
- variables = await this.getVariables(parent);
140
- VariablesStore.set(parent, variables);
141
- }
142
221
  const info = await this.execute(request, variables);
222
+ const folder = request.getParent();
143
223
  if (folder && folder !== this.project) {
144
224
  info.parent = folder.key;
145
225
  }
146
226
  return info;
147
227
  }
148
228
 
149
- protected async execute(request: ProjectRequest, variables: Record<string, string>): Promise<RunResult> {
229
+ protected async execute(request: ProjectRequest | AppProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
150
230
  const config = request.getConfig();
151
- const factory = new RequestFactory(this.eventTarget);
152
-
231
+ const factory = new HttpRequestRunner();
153
232
  factory.variables = variables;
154
233
  if (request.authorization) {
155
234
  factory.authorization = request.authorization.map(i => i.toJSON());
156
235
  }
157
- if (request.actions) {
158
- factory.actions = request.actions.toJSON();
236
+ if (request.flows) {
237
+ factory.flows = request.flows;
159
238
  }
160
239
  if (request.clientCertificate) {
161
240
  factory.certificates = [request.clientCertificate.toJSON()];
@@ -166,30 +245,23 @@ export class ProjectRequestRunner extends EventEmitter {
166
245
  if (this.logger) {
167
246
  factory.logger = this.logger;
168
247
  }
169
- const info: RunResult = {
248
+ if (this.cookies) {
249
+ factory.cookies = this.cookies;
250
+ }
251
+ const info: IRunResult = {
170
252
  key: request.key,
171
253
  };
172
254
  const requestData = request.expects.toJSON();
173
255
  requestData.url = this.prepareRequestUrl(requestData.url, variables);
174
256
 
175
- function variableHandler(e: CustomEvent): void {
176
- if (e.defaultPrevented) {
177
- return;
178
- }
179
- const { name, value } = e.detail;
180
- variables[name] = value;
181
- e.preventDefault();
182
- e.detail.result = Promise.resolve();
183
- }
184
-
185
- this.eventTarget.addEventListener(EventTypes.Environment.set, variableHandler as any);
186
-
187
257
  try {
188
258
  // Below replaces the single call to the `run()` function of the factory to
189
259
  // report via the events a request object that has evaluated with the Jexl library.
190
- const requestCopy = await factory.processRequestVariables(requestData);
260
+ const requestCopy = await factory.applyVariables(requestData);
261
+ await factory.applyAuthorization(requestCopy);
262
+ await factory.applyCookies(requestCopy);
191
263
  this.emit('request', request.key, { ...requestCopy });
192
- await factory.processRequestLogic(requestCopy);
264
+ await factory.runRequestFlows(requestCopy);
193
265
  const result = await factory.executeRequest(requestCopy);
194
266
  result.requestId = request.key;
195
267
  await factory.processResponse(result);
@@ -205,19 +277,17 @@ export class ProjectRequestRunner extends EventEmitter {
205
277
  const log = RequestLog.fromRequestResponse(sent.toJSON(), response.toJSON()).toJSON();
206
278
  this.emit('error', request.key, log, info.errorMessage);
207
279
  }
208
-
209
- this.eventTarget.removeEventListener(EventTypes.Environment.set, variableHandler as any);
210
280
  return info;
211
281
  }
212
282
 
213
- protected async getVariables(parent: HttpProject | ProjectFolder): Promise<Record<string, string>> {
283
+ protected async getVariables(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Record<string, string>> {
214
284
  if (this.masterEnvironment) {
215
285
  return this.applyVariables([this.masterEnvironment]);
216
286
  }
217
287
  return this.createEnvironment(parent);
218
288
  }
219
289
 
220
- protected async createEnvironment(parent: HttpProject | ProjectFolder): Promise<Record<string, string>> {
290
+ protected async createEnvironment(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Record<string, string>> {
221
291
  const envs = await this.readEnvironments(parent);
222
292
  return this.applyVariables(envs);
223
293
  }
@@ -225,7 +295,7 @@ export class ProjectRequestRunner extends EventEmitter {
225
295
  /**
226
296
  * Reads the list of the environments to apply to this runtime.
227
297
  */
228
- protected async readEnvironments(parent: HttpProject | ProjectFolder): Promise<Environment[]> {
298
+ protected async readEnvironments(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Environment[]> {
229
299
  const folderKey = parent.kind === ProjectFolderKind ? (parent as ProjectFolder).key : undefined;
230
300
  return this.project.readEnvironments({ parent: folderKey });
231
301
  }
@@ -9,8 +9,9 @@ import { ProjectRequestRunner } from './ProjectRequestRunner.js';
9
9
  import { IProjectExecutionIteration, IProjectExecutionLog } from '../reporters/Reporter.js';
10
10
  import { pathExists, readJson } from '../../lib/fs/Fs.js';
11
11
  import { BaseRunner } from './BaseRunner.js';
12
- import { IProjectRunnerOptions } from './InteropInterfaces.js';
12
+ import { IProjectRunnerOptions, IRequestRunnerOptions } from './InteropInterfaces.js';
13
13
  import { State } from './enums.js';
14
+ import { AppProject } from '../../models/AppProject.js';
14
15
 
15
16
  type ProjectParent = HttpProject | ProjectFolder;
16
17
 
@@ -89,7 +90,7 @@ export abstract class ProjectRunner extends BaseRunner {
89
90
  /**
90
91
  * The HTTP project to run requests from.
91
92
  */
92
- project?: HttpProject;
93
+ project?: HttpProject | AppProject;
93
94
  /**
94
95
  * The execution options for the project.
95
96
  */
@@ -102,10 +103,6 @@ export abstract class ProjectRunner extends BaseRunner {
102
103
  * The selected environment to apply to the requests.
103
104
  */
104
105
  environment?: Environment;
105
- /**
106
- * The events target instance for events dispatched by the request factory.
107
- */
108
- target = new EventTarget();
109
106
  /**
110
107
  * This is used with `--iterations`. The index of the current iteration.
111
108
  */
@@ -262,6 +259,28 @@ export abstract class ProjectRunner extends BaseRunner {
262
259
  return env;
263
260
  }
264
261
 
262
+ protected async getProjectRunnerOptions(): Promise<IRequestRunnerOptions> {
263
+ const { environment, options } = this;
264
+ if (!options) {
265
+ throw new Error(`Run configure() first.`);
266
+ }
267
+ const result: IRequestRunnerOptions = {
268
+ variables: this.prepareVariables(),
269
+ };
270
+ if (environment) {
271
+ result.environment = environment;
272
+ }
273
+ if (options.logger) {
274
+ result.logger = options.logger;
275
+ } else {
276
+ result.logger = new DummyLogger();
277
+ }
278
+ if (options.cookies) {
279
+ result.cookies = options.cookies;
280
+ }
281
+ return result;
282
+ }
283
+
265
284
  /**
266
285
  * Runs the requests from the project as configured.
267
286
  */
@@ -269,39 +288,35 @@ export abstract class ProjectRunner extends BaseRunner {
269
288
  if (this._state === State.Aborted) {
270
289
  throw new Error(`The execution has been aborted.`);
271
290
  }
272
- const { environment, project, options, hasIterations, index, noEmit } = this;
291
+ const { project, options, hasIterations, index, noEmit } = this;
273
292
  if (!options || !project) {
274
293
  throw new Error(`Run configure() first.`);
275
294
  }
276
295
  if (!noEmit) {
277
296
  this.emit('before-iteration', index, hasIterations);
278
297
  }
279
-
280
- const runner = new ProjectRequestRunner(project, {
281
- environment,
282
- logger: options.logger ? options.logger : new DummyLogger(),
283
- eventTarget: this.target,
284
- variables: this.getSystemVariables(),
285
- });
298
+ const runnerOptions = await this.getProjectRunnerOptions();
299
+ const runner = new ProjectRequestRunner(project, runnerOptions);
286
300
  this._runner = runner;
287
-
288
301
  runner.on('request', this._requestHandler);
289
302
  runner.on('response', this._responseHandler);
290
303
  runner.on('error', this._errorHandler);
291
304
  this.currentIteration = {
292
305
  index: this.index,
293
306
  executed: [],
307
+ variables: {},
294
308
  };
295
309
  try {
296
- await runner.run({
297
- parent: options.parent,
298
- requests: options.request,
299
- ignore: options.ignore,
300
- recursive: options.recursive
310
+ const info = await runner.run({
311
+ parent: options.parent,
312
+ requests: options.request,
313
+ ignore: options.ignore,
314
+ recursive: options.recursive
301
315
  });
316
+ this.currentIteration.variables = info.variables;
302
317
  } catch (e) {
303
318
  const cause = e as Error;
304
- console.error(e);
319
+ this.options?.logger?.error(e);
305
320
  this.currentIteration.error = cause.message || 'Unknown error ocurred';
306
321
  // ...
307
322
  }
@@ -343,7 +358,7 @@ export abstract class ProjectRunner extends BaseRunner {
343
358
  /**
344
359
  * @returns Reads the system variables based on the library configuration.
345
360
  */
346
- protected getSystemVariables(): Record<string, string> {
361
+ protected prepareVariables(): Record<string, string> {
347
362
  const result: Record<string, string> = {};
348
363
  const { options } = this;
349
364
  if (!options) {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  /* eslint-disable no-unused-vars */
2
3
  import process from 'process';
3
4
  import cluster from 'cluster';
@@ -8,6 +9,7 @@ import { IProjectParallelWorkerOptions } from './InteropInterfaces.js';
8
9
  import { sleep } from '../../lib/timers/Timers.js';
9
10
  import { ProjectRunner } from './ProjectRunner.js';
10
11
  import { State } from './enums.js';
12
+ import { InMemoryCookieJar } from '../../cookies/InMemoryCookieJar.js';
11
13
 
12
14
  class ProjectExeWorker extends ProjectRunner {
13
15
  initialize(): void {
@@ -25,6 +27,7 @@ class ProjectExeWorker extends ProjectRunner {
25
27
  }
26
28
 
27
29
  async run(options: IProjectParallelWorkerOptions): Promise<void> {
30
+ options.cookies = new InMemoryCookieJar();
28
31
  try {
29
32
  await this.configure(new HttpProject(options.project), options);
30
33
  await this.execute();
@@ -11,6 +11,11 @@ export interface IProjectExecutionIteration {
11
11
  * The list of requests executed in the iteration.
12
12
  */
13
13
  executed: IRequestLog[];
14
+ /**
15
+ * The variables evaluated during the run.
16
+ * These variables have values set by requests' HTTP flows.
17
+ */
18
+ variables: Record<string, string>;
14
19
  /**
15
20
  * Optional general error message.
16
21
  */
@@ -73,7 +73,7 @@ export class FilesSdk extends SdkBase {
73
73
  } catch (e) {
74
74
  throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
75
75
  }
76
- if (!Array.isArray(data.data)) {
76
+ if (!Array.isArray(data.items)) {
77
77
  throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
78
78
  }
79
79
  return data;
@@ -241,7 +241,7 @@ export class FilesSdk extends SdkBase {
241
241
  */
242
242
  async readBulk(keys: string[], request: ISdkRequestOptions = {}): Promise<IListResponse<IFile|undefined>> {
243
243
  const token = request.token || this.sdk.token;
244
- const url = this.sdk.getUrl(RouteBuilder.filesBulk());
244
+ const url = this.sdk.getUrl(RouteBuilder.filesBatch());
245
245
  const body = JSON.stringify(keys);
246
246
  const result = await this.sdk.http.post(url.toString(), { token, body });
247
247
  this.inspectCommonStatusCodes(result.status, result.body);
@@ -264,7 +264,7 @@ export class FilesSdk extends SdkBase {
264
264
  } catch (e) {
265
265
  throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
266
266
  }
267
- if (!Array.isArray(data.data)) {
267
+ if (!Array.isArray(data.items)) {
268
268
  throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
269
269
  }
270
270
  return data;
@@ -408,7 +408,7 @@ export class FilesSdk extends SdkBase {
408
408
  } catch (e) {
409
409
  throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
410
410
  }
411
- if (!Array.isArray(data.data)) {
411
+ if (!Array.isArray(data.items)) {
412
412
  throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
413
413
  }
414
414
  return data;
@@ -91,7 +91,7 @@ export class HistorySdk extends SdkBase {
91
91
  } catch (e) {
92
92
  throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
93
93
  }
94
- if (!Array.isArray(data.data)) {
94
+ if (!Array.isArray(data.items)) {
95
95
  throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
96
96
  }
97
97
  return data;