@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,168 +0,0 @@
1
- import { Cookie } from './Cookie.js';
2
-
3
- /**
4
- * Gets the path for a domain as defined in
5
- * https://tools.ietf.org/html/rfc6265#section-5.1.4
6
- *
7
- * @param urlValue A url to extract path from.
8
- */
9
- export function getPath(urlValue: string): string {
10
- let url = urlValue;
11
- const defaultValue = '/';
12
- if (!url) {
13
- return defaultValue;
14
- }
15
- let index = url.indexOf('/', 8); // after `http(s)://` string
16
- if (index === -1) {
17
- return defaultValue;
18
- }
19
- url = url.substr(index);
20
- if (!url || url[0] !== '/') {
21
- return defaultValue;
22
- }
23
- // removed query string
24
- index = url.indexOf('?');
25
- if (index !== -1) {
26
- url = url.substr(0, index);
27
- }
28
- // removes hash string
29
- index = url.indexOf('#');
30
- if (index !== -1) {
31
- url = url.substr(0, index);
32
- }
33
- index = url.indexOf('/', 1);
34
- if (index === -1) {
35
- return defaultValue;
36
- }
37
- index = url.lastIndexOf('/');
38
- if (index !== 0) {
39
- url = url.substr(0, index);
40
- }
41
- return url;
42
- }
43
-
44
- /**
45
- * Checks if `domain` of the request url (defined as `this.url`)
46
- * matches domain defined in a cookie.
47
- * This follows algorithm defined in https://tools.ietf.org/html/rfc6265#section-5.1.3
48
- *
49
- * Note: If `cookieDomain` is not set it returns false, while
50
- * (according to the spec) it should be set to `domain` and pass the test.
51
- * Because this function only check if domains matches it will not
52
- * override domain.
53
- * Cookie domain should be filled before calling this function.
54
- *
55
- * Note: This function will return false if the `this.url` was not set.
56
- *
57
- * @param cookieDomain A domain received in the cookie.
58
- * @param uri
59
- * @return True if domains matches.
60
- */
61
- export function matchesDomain(cookieDomain: string, uri: URL): boolean {
62
- if (!uri) {
63
- return false;
64
- }
65
- let domain = uri.hostname;
66
- domain = domain && domain.toLowerCase && domain.toLowerCase();
67
- // eslint-disable-next-line no-param-reassign
68
- cookieDomain =
69
- cookieDomain && cookieDomain.toLowerCase && cookieDomain.toLowerCase();
70
- if (!cookieDomain) {
71
- return false;
72
- }
73
- if (domain === cookieDomain) {
74
- return true;
75
- }
76
- if (cookieDomain[0] === '.') {
77
- const parts = domain.split('.');
78
- if (parts.length > 1) {
79
- parts.shift();
80
- domain = parts.join('.');
81
- }
82
- }
83
- const index = cookieDomain.indexOf(domain);
84
- if (index === -1) {
85
- return false;
86
- }
87
- if (cookieDomain.substr(index - 1, index) !== '.') {
88
- return false;
89
- }
90
- return true;
91
- }
92
-
93
- /**
94
- * Checks if paths mach as defined in
95
- * https://tools.ietf.org/html/rfc6265#section-5.1.4
96
- *
97
- * Note: This function will return false if the `this.url` was not set.
98
- *
99
- * @param cookiePath Path from the cookie.
100
- * @param uri
101
- * @param url
102
- * @return True when paths matches.
103
- */
104
- export function matchesPath(cookiePath: string, uri: URL, url: string): boolean {
105
- if (!uri) {
106
- return false;
107
- }
108
- if (!cookiePath) {
109
- return true;
110
- }
111
- const hostPath = getPath(url);
112
- if (hostPath === cookiePath) {
113
- return true;
114
- }
115
- // const index = cookiePath.indexOf(hostPath);
116
- const index = hostPath.indexOf(cookiePath);
117
- if (index === 0 && cookiePath[cookiePath.length - 1] === '/') {
118
- return true;
119
- }
120
- if (index === 0 && cookiePath.indexOf('/', 1) === -1) {
121
- return true;
122
- }
123
-
124
- if (index === 0) {
125
- // eslint-disable-next-line no-plusplus
126
- for (let i = 0, len = hostPath.length; i < len; i++) {
127
- if (cookiePath.indexOf(hostPath[i]) === -1 && hostPath[i] === '/') {
128
- return true;
129
- }
130
- }
131
- }
132
- return false;
133
- }
134
-
135
- /**
136
- * Clients must fill `path` and `domain` attribute if not set by the
137
- * server to match current request url.
138
- *
139
- * @param uri HTTP request url parsed by the URL class.
140
- * @param url The HTTP request url.
141
- * @param cookies Parsed cookies
142
- */
143
- export function fillCookieAttributes(uri: URL, url: string, cookies: Cookie[]): void {
144
- if (!uri) {
145
- return;
146
- }
147
- let domain = uri.hostname;
148
- if (!domain) {
149
- return;
150
- }
151
- domain = domain.toLowerCase();
152
- const path = getPath(url);
153
- cookies.forEach((cookie) => {
154
- if (!cookie.path) {
155
- // eslint-disable-next-line no-param-reassign
156
- cookie.path = path;
157
- }
158
- const cDomain = cookie.domain;
159
- if (!cDomain) {
160
- // eslint-disable-next-line no-param-reassign
161
- cookie.domain = domain;
162
- // point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
163
- // eslint-disable-next-line no-param-reassign
164
- cookie.hostOnly = true;
165
- }
166
- return cookie;
167
- });
168
- }
@@ -1,34 +0,0 @@
1
- import { Types, IDataMockInit, IHttpRequestInit } from '@pawel-up/data-mock';
2
- import { IArcHttpRequest, Kind as ArcHttpRequestKind } from '../../models/arc/ArcHttpRequest.js';
3
- import { Request } from './Request.js';
4
-
5
- export class Arc {
6
- protected request: Request;
7
- protected types: Types;
8
-
9
- constructor(init: IDataMockInit={}) {
10
- this.request = new Request(init);
11
- this.types = new Types(init.seed);
12
- // this.lorem = new Lorem(init);
13
- // this.time = new Time(init);
14
- // this.http = new Http(init);
15
- // this.response = new Response(init);
16
- }
17
-
18
- arcRequest(init?: IHttpRequestInit): IArcHttpRequest {
19
- const request = this.request.request(init);
20
- return {
21
- key: this.types.uuid(),
22
- ...request,
23
- kind: ArcHttpRequestKind,
24
- };
25
- }
26
-
27
- arcRequests(size = 25, init?: IHttpRequestInit): IArcHttpRequest[] {
28
- const result: IArcHttpRequest[] = [];
29
- for (let i = 0; i < size; i++) {
30
- result.push(this.arcRequest(init));
31
- }
32
- return result;
33
- }
34
- }
@@ -1,161 +0,0 @@
1
- import { IRunnableAction, RunnableAction, Kind as RunnableActionKind } from './actions/RunnableAction.js';
2
- import { RequestActions as LegacyRequestActions } from './legacy/request/ArcRequest.js';
3
-
4
- export interface IRequestActions {
5
- /**
6
- * Actions to be executed before the request is sent to the transport library.
7
- */
8
- request?: IRunnableAction[];
9
- /**
10
- * Actions to be executed after the response is fully received but before it is reported back to the application.
11
- */
12
- response?: IRunnableAction[];
13
- }
14
-
15
- export class RequestActions {
16
- /**
17
- * Actions to be executed before the request is sent to the transport library.
18
- */
19
- request?: RunnableAction[];
20
- /**
21
- * Actions to be executed after the response is fully received but before it is reported back to the application.
22
- */
23
- response?: RunnableAction[];
24
-
25
- static fromLegacy(action: LegacyRequestActions): RequestActions {
26
- const { request, response } = action;
27
- const init: IRequestActions = {};
28
- if (Array.isArray(request) && request.length) {
29
- init.request = request.map(i => RunnableAction.fromLegacy(i).toJSON());
30
- }
31
- if (Array.isArray(response) && response.length) {
32
- init.response = response.map(i => RunnableAction.fromLegacy(i).toJSON());
33
- }
34
- return new RequestActions(init);
35
- }
36
-
37
- static isLegacy(input: unknown): boolean {
38
- const { request=[], response=[] } = input as RequestActions;
39
- if (!request.length && !response.length) {
40
- return false;
41
- }
42
- if (request[0]) {
43
- const r = request[0];
44
- if (r.kind === RunnableActionKind) {
45
- return false;
46
- }
47
- }
48
- if (response[0]) {
49
- const r = response[0];
50
- if (r.kind === RunnableActionKind) {
51
- return false;
52
- }
53
- }
54
- return true;
55
- }
56
-
57
- /**
58
- * @param input The request actions definition used to restore the state.
59
- */
60
- constructor(input?: string | IRequestActions) {
61
- let init: IRequestActions;
62
- if (typeof input === 'string') {
63
- init = JSON.parse(input);
64
- } else if (typeof input === 'object') {
65
- init = input;
66
- } else {
67
- init = {};
68
- }
69
- this.new(init);
70
- }
71
-
72
- /**
73
- * Creates a new request actions clearing anything that is so far defined.
74
- */
75
- new(init: IRequestActions): void {
76
- const { request, response } = init;
77
- if (request) {
78
- this.request = request.map(i => new RunnableAction(i));
79
- } else {
80
- this.request = undefined;
81
- }
82
- if (response) {
83
- this.response = response.map(i => new RunnableAction(i));
84
- } else {
85
- this.response = undefined;
86
- }
87
- }
88
-
89
- toJSON(): IRequestActions {
90
- const result: IRequestActions = {};
91
- if (this.request) {
92
- result.request = this.request.map(i => i.toJSON());
93
- }
94
- if (this.response) {
95
- result.response = this.response.map(i => i.toJSON());
96
- }
97
- return result;
98
- }
99
-
100
- /**
101
- * Adds a request action to the list of actions.
102
- * If the list does not exist it's created by this method.
103
- *
104
- * @param action The schema of the action.
105
- * @returns Created instance of the action.
106
- */
107
- addRequestAction(action: IRunnableAction): RunnableAction;
108
- /**
109
- * Adds a request action to the list of actions.
110
- * If the list does not exist it's created by this method.
111
- *
112
- * @param action The instance of the action.
113
- * @returns The same instance of the action.
114
- */
115
- addRequestAction(action: RunnableAction): RunnableAction;
116
-
117
- addRequestAction(action: RunnableAction | IRunnableAction): RunnableAction {
118
- if (!Array.isArray(this.request)) {
119
- this.request = [];
120
- }
121
- let finalAction: RunnableAction;
122
- if (action instanceof RunnableAction) {
123
- finalAction = action;
124
- } else {
125
- finalAction = new RunnableAction(action);
126
- }
127
- this.request.push(finalAction);
128
- return finalAction;
129
- }
130
-
131
- /**
132
- * Adds a request action to the list of actions.
133
- * If the list does not exist it's created by this method.
134
- *
135
- * @param action The schema of the action.
136
- * @returns Created instance of the action.
137
- */
138
- addResponseAction(action: IRunnableAction): RunnableAction;
139
- /**
140
- * Adds a response action to the list of actions.
141
- * If the list does not exist it's created by this method.
142
- *
143
- * @param action The instance of the action.
144
- * @returns The same instance of the action.
145
- */
146
- addResponseAction(action: RunnableAction): RunnableAction;
147
-
148
- addResponseAction(action: RunnableAction | IRunnableAction): RunnableAction {
149
- if (!Array.isArray(this.response)) {
150
- this.response = [];
151
- }
152
- let finalAction: RunnableAction;
153
- if (action instanceof RunnableAction) {
154
- finalAction = action;
155
- } else {
156
- finalAction = new RunnableAction(action);
157
- }
158
- this.response.push(finalAction);
159
- return finalAction;
160
- }
161
- }
@@ -1,213 +0,0 @@
1
- import { IActions } from './runnable/index.js';
2
- import { Runnable, IRunnable } from './runnable/Runnable.js';
3
- import { Kind as DeleteCookieKind, DeleteCookieAction, IDeleteCookieAction } from './runnable/DeleteCookieAction.js';
4
- import { Kind as SetCookieKind, SetCookieAction, ISetCookieAction } from './runnable/SetCookieAction.js';
5
- import { Kind as SetVariableKind, SetVariableAction, ISetVariableAction } from './runnable/SetVariableAction.js';
6
- import { Action as LegacyAction, SetCookieConfig, SetVariableConfig, DeleteCookieConfig } from '../legacy/actions/Actions.js';
7
-
8
- export const Kind = 'Core#Action';
9
-
10
- /**
11
- * An interface representing a single action.
12
- */
13
- export interface IAction {
14
- kind?: typeof Kind;
15
- /**
16
- * Action name.
17
- */
18
- name?: string;
19
- /**
20
- * Whether the action is enabled.
21
- * An action is enabled by default.
22
- * @default true
23
- */
24
- enabled?: boolean;
25
- /**
26
- * Action priority. The higher number the higher priority of execution.
27
- */
28
- priority?: number;
29
- /**
30
- * The action configuration. The schema depends on the action type.
31
- */
32
- config?: unknown;
33
- /**
34
- * Whether or not the action is executed synchronously to request / response
35
- */
36
- sync?: boolean;
37
- /**
38
- * Whether or not the request should fail when the action fails.
39
- */
40
- failOnError?: boolean;
41
- }
42
-
43
- export class Action {
44
- kind = Kind;
45
- /**
46
- * Action name.
47
- */
48
- name?: string;
49
- /**
50
- * Whether the action is enabled.
51
- */
52
- enabled?: boolean;
53
- /**
54
- * Action priority. The higher number the higher priority of execution.
55
- */
56
- priority?: number;
57
- /**
58
- * Action configuration
59
- */
60
- config?: Runnable;
61
- /**
62
- * Whether or not the action is executed synchronously to request / response
63
- */
64
- sync?: boolean;
65
- /**
66
- * Whether or not the request should fail when the action fails.
67
- */
68
- failOnError?: boolean;
69
-
70
- static fromLegacy(item: LegacyAction): Action {
71
- const { priority, config, enabled, failOnError, name, sync } = item;
72
- let newConfig: IRunnable | undefined;
73
- switch (name) {
74
- case 'set-cookie': newConfig = SetCookieAction.fromLegacy(config as SetCookieConfig).toJSON(); break;
75
- case 'set-variable': newConfig = SetVariableAction.fromLegacy(config as SetVariableConfig); break;
76
- case 'delete-cookie': newConfig = DeleteCookieAction.fromLegacy(config as DeleteCookieConfig); break;
77
- }
78
-
79
- const init: IAction = {
80
- kind: Kind,
81
- priority,
82
- };
83
- if (typeof enabled === 'boolean') {
84
- init.enabled = enabled;
85
- }
86
- if (typeof failOnError === 'boolean') {
87
- init.failOnError = failOnError;
88
- }
89
- if (typeof sync === 'boolean') {
90
- init.sync = sync;
91
- }
92
- if (typeof name === 'string') {
93
- init.name = name;
94
- }
95
- if (newConfig) {
96
- init.config = newConfig;
97
- }
98
- return new Action(init);
99
- }
100
-
101
- /**
102
- * Creates a default configuration of an action
103
- */
104
- static defaultAction(): Action {
105
- const init: IAction = {
106
- name: 'New action',
107
- failOnError: false,
108
- priority: 0,
109
- sync: false,
110
- enabled: true,
111
- };
112
- return new Action(init);
113
- }
114
-
115
- constructor(input?: string | IAction) {
116
- let init: IAction;
117
- if (typeof input === 'string') {
118
- init = JSON.parse(input);
119
- } else if (typeof input === 'object') {
120
- init = input;
121
- } else {
122
- init = {
123
- kind: Kind,
124
- };
125
- }
126
- this.new(init);
127
- }
128
-
129
- new(init: IAction): void {
130
- const { name, enabled, priority, sync, failOnError, config } = init;
131
- this.kind = Kind;
132
- if (name) {
133
- this.name = name;
134
- } else {
135
- this.name = undefined;
136
- }
137
- if (typeof enabled === 'boolean') {
138
- this.enabled = enabled;
139
- } else {
140
- this.enabled = undefined;
141
- }
142
- if (typeof sync === 'boolean') {
143
- this.sync = sync;
144
- } else {
145
- this.sync = undefined;
146
- }
147
- if (typeof failOnError === 'boolean') {
148
- this.failOnError = failOnError;
149
- } else {
150
- this.failOnError = undefined;
151
- }
152
- if (typeof priority === 'number') {
153
- this.priority = priority;
154
- } else {
155
- this.priority = undefined;
156
- }
157
- if (config) {
158
- this.setConfig(config);
159
- } else {
160
- this.config = undefined;
161
- }
162
- }
163
-
164
- toJSON(): IAction {
165
- const result: IAction = {
166
- kind: Kind,
167
- };
168
- if (this.name) {
169
- result.name = this.name;
170
- }
171
- if (this.config) {
172
- result.config = this.config.toJSON() as IActions;
173
- }
174
- if (typeof this.enabled === 'boolean') {
175
- result.enabled = this.enabled;
176
- }
177
- if (typeof this.sync === 'boolean') {
178
- result.sync = this.sync;
179
- }
180
- if (typeof this.failOnError === 'boolean') {
181
- result.failOnError = this.failOnError;
182
- }
183
- if (typeof this.priority === 'number') {
184
- result.priority = this.priority;
185
- }
186
- return result;
187
- }
188
-
189
- setConfig(config: unknown): void {
190
- const { kind } = config as IRunnable;
191
- switch (kind) {
192
- case DeleteCookieKind: this.config = new DeleteCookieAction(config as IDeleteCookieAction); break;
193
- case SetCookieKind: this.config = new SetCookieAction(config as ISetCookieAction); break;
194
- case SetVariableKind: this.config = new SetVariableAction(config as ISetVariableAction); break;
195
- default: throw new Error(`Unknown action config.`)
196
- }
197
- }
198
-
199
- /**
200
- * The sort function for actions to sort them for the execution order.
201
- */
202
- static sortActions(a: Action, b: Action): number {
203
- const { priority: p1=0 } = a;
204
- const { priority: p2=0 } = b;
205
- if (p1 > p2) {
206
- return 1;
207
- }
208
- if (p2 > p1) {
209
- return -1;
210
- }
211
- return 0;
212
- }
213
- }
@@ -1,40 +0,0 @@
1
- export interface IActionView {
2
- /**
3
- * Whether the action is "opened" in the editor UI.
4
- */
5
- opened?: boolean;
6
- }
7
-
8
- export class ActionView {
9
- /**
10
- * Whether the action is "opened" in the editor UI.
11
- */
12
- opened?: boolean;
13
-
14
- constructor(input?: string|IActionView) {
15
- let init: IActionView;
16
- if (typeof input === 'string') {
17
- init = JSON.parse(input);
18
- } else if (typeof input === 'object') {
19
- init = input;
20
- } else {
21
- init = {
22
- opened: false,
23
- };
24
- }
25
- this.new(init);
26
- }
27
-
28
- new(init: IActionView): void {
29
- const { opened=false } = init;
30
- this.opened = opened;
31
- }
32
-
33
- toJSON(): IActionView {
34
- const result: IActionView = {};
35
- if (typeof this.opened === 'boolean') {
36
- result.opened = this.opened;
37
- }
38
- return result;
39
- }
40
- }