@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
@@ -0,0 +1,176 @@
1
+ import { IRequest, Request } from "./Request.js";
2
+ import { HttpRequest, IHttpRequest } from "./HttpRequest.js";
3
+ import { Thing } from "./Thing.js";
4
+
5
+ export const Kind = 'Core#AppRequest';
6
+
7
+ export interface IAppRequest extends IRequest {
8
+ kind: typeof Kind;
9
+ key: string;
10
+ /**
11
+ * The application id that created this request.
12
+ */
13
+ app: string;
14
+ /**
15
+ * May be used internally by the application that generated this entry
16
+ * to distinguish between different types of requests.
17
+ */
18
+ type?: string;
19
+ }
20
+
21
+ /**
22
+ * An App request is an HTTP request that has been generated by an application that is
23
+ * not related to a concept of project.
24
+ * You can think of it as a stand-alone request definition in an application.
25
+ * In HttpClient this represents a history entry. Another application can use it to stor a request data
26
+ * without any additional structure.
27
+ */
28
+ export class AppRequest extends Request {
29
+ kind = Kind;
30
+
31
+ /**
32
+ * The identifier of the request.
33
+ * The key is related to the `created` property. It should be the `new Date(created).toJSON()` value.
34
+ */
35
+ key = '';
36
+
37
+ /**
38
+ * The application id that created this request.
39
+ */
40
+ app = '';
41
+
42
+ /**
43
+ * May be used internally by the application that generated this entry
44
+ * to distinguish between different types of requests.
45
+ */
46
+ type?: string;
47
+
48
+ /**
49
+ * Creates a project request from an URL.
50
+ *
51
+ * @param url The Request URL. This is required.
52
+ * @param app The application id that generated this request. This is a required argument, even though, typings marks it as optional.
53
+ */
54
+ static fromUrl(url: string, app?: string): AppRequest {
55
+ if (!app) {
56
+ throw new Error(`The app argument is required.`);
57
+ }
58
+ const d = new Date();
59
+ const now: number = d.getTime();
60
+ const request = new AppRequest({
61
+ key: d.toJSON(),
62
+ kind: Kind,
63
+ created: now,
64
+ updated: now,
65
+ expects: HttpRequest.fromBaseValues({ url, method: 'GET' }).toJSON(),
66
+ info: Thing.fromName(url).toJSON(),
67
+ app,
68
+ });
69
+ return request;
70
+ }
71
+
72
+ /**
73
+ * Creates a project request from a name.
74
+ *
75
+ * @param name The Request name.
76
+ * @param app The application id that generated this request. This is a required argument, even though, typings marks it as optional.
77
+ */
78
+ static fromName(name: string, app?: string): AppRequest {
79
+ if (!app) {
80
+ throw new Error(`The app argument is required.`);
81
+ }
82
+ const d = new Date();
83
+ const now: number = d.getTime();
84
+ const request = new AppRequest({
85
+ key: d.toJSON(),
86
+ kind: Kind,
87
+ created: now,
88
+ updated: now,
89
+ expects: new HttpRequest().toJSON(),
90
+ info: Thing.fromName(name).toJSON(),
91
+ app,
92
+ });
93
+ return request;
94
+ }
95
+
96
+ /**
97
+ * Creates a request from an HttpRequest definition.
98
+ *
99
+ * @param info The request data.
100
+ * @param app The application id that generated this request. This is a required argument, even though, typings marks it as optional.
101
+ */
102
+ static fromHttpRequest(info: IHttpRequest, app?: string): AppRequest {
103
+ if (!app) {
104
+ throw new Error(`The app argument is required.`);
105
+ }
106
+ const d = new Date();
107
+ const now: number = d.getTime();
108
+ const request = new AppRequest({
109
+ key: d.toJSON(),
110
+ kind: Kind,
111
+ created: now,
112
+ updated: now,
113
+ expects: HttpRequest.fromBaseValues({ method: info.method, url: info.url, headers: info.headers, payload: info.payload }).toJSON(),
114
+ info: Thing.fromName(info.url).toJSON(),
115
+ app,
116
+ });
117
+ return request;
118
+ }
119
+
120
+ /**
121
+ * Creates a request for a schema of a Request.
122
+ * @param app The application id that generated this request.
123
+ */
124
+ static fromRequest(request: IRequest, app: string): AppRequest {
125
+ const d = new Date(request.created || Date.now());
126
+ const now: number = d.getTime();
127
+ const init: IAppRequest = {
128
+ ...request,
129
+ key: d.toJSON(),
130
+ kind: Kind,
131
+ created: now,
132
+ app,
133
+ };
134
+ const result = new AppRequest(init);
135
+ return result;
136
+ }
137
+
138
+ constructor(input?: string | IAppRequest) {
139
+ super(input);
140
+
141
+ let init: IAppRequest | undefined;
142
+ if (typeof input === 'string') {
143
+ init = JSON.parse(input);
144
+ } else if (typeof input === 'object') {
145
+ init = input;
146
+ }
147
+ if (init) {
148
+ this.key = init.key;
149
+ this.app = init.app;
150
+ }
151
+ if (!this.key) {
152
+ this.key = new Date(this.created || Date.now()).toJSON();
153
+ }
154
+ this.kind = Kind;
155
+ }
156
+
157
+ new(init: IAppRequest): void {
158
+ super.new(init);
159
+
160
+ const { key, app } = init;
161
+ this.key = key || new Date(init.created || Date.now()).toJSON();
162
+ this.kind = Kind;
163
+ this.app = app;
164
+ }
165
+
166
+ toJSON(): IAppRequest {
167
+ const request = super.toJSON();
168
+ const result: IAppRequest = {
169
+ ...request,
170
+ key: this.key,
171
+ kind: Kind,
172
+ app: this.app,
173
+ };
174
+ return result;
175
+ }
176
+ }
@@ -37,11 +37,11 @@ export interface ICertificate {
37
37
  */
38
38
  key: string;
39
39
  /**
40
- * Custom name of the certificate.
40
+ * The custom name of the certificate.
41
41
  */
42
42
  name: string;
43
43
  /**
44
- * Timestamp when the certificate was inserted into the data store.
44
+ * The timestamp when the certificate was inserted into the data store.
45
45
  * Required when returning a result. Auto-generated when inserting, if missing.
46
46
  */
47
47
  created?: number;
@@ -4,6 +4,8 @@ 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
6
 
7
+ export const Kind = 'Core#Environment';
8
+
7
9
  export interface IEnvironmentCloneOptions {
8
10
  /**
9
11
  * By default it revalidates (re-creates) keys in the environment.
@@ -47,8 +49,6 @@ export interface IEnvironment {
47
49
  security?: unknown;
48
50
  }
49
51
 
50
- export const Kind = 'Core#Environment';
51
-
52
52
  /**
53
53
  * An environment is applied to a project or a folder.
54
54
  * It consists of a list of variables and a server configuration.
@@ -277,4 +277,26 @@ export class Environment {
277
277
  }
278
278
  return copy;
279
279
  }
280
+
281
+ /**
282
+ * Creates a map of variables from this environment.
283
+ *
284
+ * @param readStrategy The read strategy. When `lastWins` (default) then a variable with the same name overwrites the previously set variable. The `firstWins` stops overwriting values once a variable is set.
285
+ * @returns An object containing variables defined in this environment
286
+ */
287
+ variablesMap(readStrategy: 'lastWins' | 'firstWins' = 'lastWins'): Record<string, string> {
288
+ const result: Record<string, string> = {};
289
+ const { variables=[] } = this
290
+ variables.forEach((item) => {
291
+ const { enabled, name, value } = item;
292
+ if (!enabled || !name || value === undefined) {
293
+ return;
294
+ }
295
+ if (readStrategy === 'firstWins' && name in result) {
296
+ return;
297
+ }
298
+ result[name] = value as string;
299
+ });
300
+ return result;
301
+ }
280
302
  }
@@ -17,11 +17,11 @@ export interface IHostRule {
17
17
  */
18
18
  from: string;
19
19
  /**
20
- * replacement value
20
+ * The replacement value
21
21
  */
22
22
  to: string;
23
23
  /**
24
- * if false the rule is ignored
24
+ * When false the rule is ignored
25
25
  */
26
26
  enabled?: boolean;
27
27
  /**
@@ -1,8 +1,31 @@
1
1
  import { ARCCookie as LegacyARCCookie } from './legacy/models/Cookies.js';
2
- import { Cookie as ParserCookie } from '../lib/cookies/Cookie.js';
3
2
 
4
3
  export type CookieSameSiteType = 'unspecified' | 'no_restriction' | 'lax' | 'strict';
5
4
  export type CookieChangeReason = 'explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite';
5
+ // eslint-disable-next-line no-control-regex
6
+ const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
7
+
8
+ export interface IElectronCookie {
9
+ name: string;
10
+ value: string;
11
+ /**
12
+ * The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains.
13
+ */
14
+ domain?: string;
15
+ /**
16
+ * Whether the cookie is a host-only cookie; this will only be true if no domain was passed.
17
+ */
18
+ hostOnly?: boolean;
19
+ /**
20
+ * The path of the cookie.
21
+ */
22
+ path?: string;
23
+ secure?: boolean;
24
+ httpOnly?: boolean;
25
+ session?: boolean;
26
+ expirationDate?: number;
27
+ sameSite?: CookieSameSiteType;
28
+ }
6
29
 
7
30
  export interface IHttpCookieChangeRecord {
8
31
  /**
@@ -70,7 +93,7 @@ export interface IHttpCookie {
70
93
  * The Same Site policy applied to this cookie. Can be `unspecified`, `no_restriction`, `lax` or `strict`.
71
94
  * @default unspecified
72
95
  */
73
- sameSite: CookieSameSiteType;
96
+ sameSite?: CookieSameSiteType;
74
97
  }
75
98
 
76
99
  export class HttpCookie {
@@ -82,11 +105,6 @@ export class HttpCookie {
82
105
  * The value of the cookie.
83
106
  */
84
107
  value = '';
85
- /**
86
- * The domain of the cookie; this will be normalized with a preceding dot so that
87
- * it's also valid for subdomains.
88
- */
89
- domain?: string;
90
108
  /**
91
109
  * Whether the cookie is a host-only cookie; this will only be `true` if no domain
92
110
  * was passed.
@@ -108,17 +126,110 @@ export class HttpCookie {
108
126
  * Whether the cookie is a session cookie or a persistent cookie with an expiration
109
127
  * date.
110
128
  */
111
- session?: boolean;
129
+ session?: boolean = true;
130
+ /**
131
+ * The Same Site policy applied to this cookie. Can be `unspecified`, `no_restriction`, `lax` or `strict`.
132
+ * @default unspecified
133
+ */
134
+ sameSite: CookieSameSiteType = 'unspecified';
135
+
136
+ protected _domain?: string;
137
+ protected _maxAge?: number;
138
+ protected _expirationDate?: number | undefined;
139
+
140
+ /**
141
+ * @param max The max age value
142
+ */
143
+ set maxAge(max: number | undefined) {
144
+ const typedMax = Number(max);
145
+ if (Number.isNaN(typedMax)) {
146
+ return;
147
+ }
148
+
149
+ this._maxAge = typedMax;
150
+ if (typedMax <= 0) {
151
+ // see http://stackoverflow.com/a/11526569/1127848
152
+ // and https://tools.ietf.org/html/rfc6265#section-5.2.2
153
+ this._expirationDate = -8640000000000000;
154
+ } else {
155
+ let now = Date.now();
156
+ now += typedMax * 1000;
157
+ this._expirationDate = now;
158
+ }
159
+ this.session = false;
160
+ }
161
+
162
+ /**
163
+ * @return Returns a value of maxAge property
164
+ */
165
+ get maxAge(): number | undefined {
166
+ return this._maxAge;
167
+ }
168
+
112
169
  /**
113
170
  * The expiration date of the cookie as the number of seconds since the UNIX epoch.
114
171
  * Not provided for session cookies.
115
172
  */
116
- expirationDate?: number;
173
+ set expirationDate(expires: number | Date | string | undefined) {
174
+ this.setExpirationTime(expires);
175
+ }
176
+
177
+ get expirationDate(): number | undefined {
178
+ return this._expirationDate;
179
+ }
180
+
117
181
  /**
118
- * The Same Site policy applied to this cookie. Can be `unspecified`, `no_restriction`, `lax` or `strict`.
119
- * @default unspecified
182
+ * The domain of the cookie; this will be normalized with a preceding dot so that
183
+ * it's also valid for subdomains.
120
184
  */
121
- sameSite: CookieSameSiteType = 'unspecified';
185
+ set domain(domain: string | undefined) {
186
+ this._domain = domain;
187
+ if (!domain) {
188
+ this.hostOnly = false;
189
+ } else {
190
+ this.hostOnly = true;
191
+ }
192
+ }
193
+
194
+ get domain(): string | undefined {
195
+ return this._domain;
196
+ }
197
+
198
+ // get samesite(): CookieSameSiteType | undefined {
199
+ // return this.sameSite;
200
+ // }
201
+
202
+ set samesite(value: CookieSameSiteType | undefined) {
203
+ this.sameSite = value || 'unspecified';
204
+ }
205
+
206
+ // get httponly(): boolean | undefined {
207
+ // return this.httpOnly;
208
+ // }
209
+
210
+ set httponly(value: boolean | undefined) {
211
+ this.httpOnly = value;
212
+ }
213
+
214
+ // get hostonly(): boolean | undefined {
215
+ // return this.hostOnly;
216
+ // }
217
+
218
+ set hostonly(value: boolean | undefined) {
219
+ this.hostOnly = value;
220
+ }
221
+
222
+ // get ['max-age'](): number | undefined {
223
+ // return this.maxAge;
224
+ // }
225
+
226
+ set ['max-age'](value: number | undefined) {
227
+ this.maxAge = value;
228
+ }
229
+
230
+ set expires(value: string | number | Date | undefined) {
231
+ this.expirationDate = value;
232
+ }
122
233
 
123
234
  static fromLegacy(old: LegacyARCCookie): HttpCookie {
124
235
  const init: IHttpCookie = {
@@ -150,7 +261,7 @@ export class HttpCookie {
150
261
  return new HttpCookie(init);
151
262
  }
152
263
 
153
- static fromValue(name: string, value: string = ''): HttpCookie {
264
+ static fromValue(name: string, value = ''): HttpCookie {
154
265
  const init: IHttpCookie = {
155
266
  name,
156
267
  value,
@@ -159,37 +270,6 @@ export class HttpCookie {
159
270
  return new HttpCookie(init);
160
271
  }
161
272
 
162
- static fromCookieParser(cookie: ParserCookie): HttpCookie {
163
- const { name, value, sameSite='unspecified' } = cookie;
164
- const init: IHttpCookie = {
165
- name,
166
- value,
167
- sameSite,
168
- };
169
- if (typeof cookie.domain === 'string') {
170
- init.domain = cookie.domain;
171
- }
172
- if (typeof cookie.path === 'string') {
173
- init.path = cookie.path;
174
- }
175
- if (typeof cookie.expires === 'number') {
176
- init.expirationDate = cookie.expires;
177
- }
178
- if (typeof cookie.hostOnly === 'boolean') {
179
- init.hostOnly = cookie.hostOnly;
180
- }
181
- if (typeof cookie.httpOnly === 'boolean') {
182
- init.httpOnly = cookie.httpOnly;
183
- }
184
- if (typeof cookie.secure === 'boolean') {
185
- init.secure = cookie.secure;
186
- }
187
- if (typeof cookie.persistent === 'boolean') {
188
- init.session = !cookie.persistent;
189
- }
190
- return new HttpCookie(init);
191
- }
192
-
193
273
  constructor(input?: string|IHttpCookie) {
194
274
  let init: IHttpCookie;
195
275
  if (typeof input === 'string') {
@@ -213,10 +293,27 @@ export class HttpCookie {
213
293
  sameSite = 'unspecified',
214
294
  domain, expirationDate, hostOnly, httpOnly, path, secure, session
215
295
  } = init;
296
+ if (name && !fieldContentRegExp.test(name)) {
297
+ throw new TypeError('Argument `name` is invalid');
298
+ }
299
+ if (value && !fieldContentRegExp.test(value)) {
300
+ throw new TypeError('Argument `value` is invalid');
301
+ }
216
302
  this.name = name;
217
303
  this.value = value;
218
304
  this.sameSite = sameSite;
305
+ if (typeof path === 'string') {
306
+ if (!fieldContentRegExp.test(path)) {
307
+ throw new TypeError('Option `path` is invalid');
308
+ }
309
+ this.path = path;
310
+ } else {
311
+ this.path = undefined;
312
+ }
219
313
  if (domain) {
314
+ if (!fieldContentRegExp.test(domain)) {
315
+ throw new TypeError('Option `domain` is invalid');
316
+ }
220
317
  this.domain = domain;
221
318
  } else {
222
319
  this.domain = undefined;
@@ -244,13 +341,41 @@ export class HttpCookie {
244
341
  if (typeof session === 'boolean') {
245
342
  this.session = session;
246
343
  } else {
247
- this.session = undefined;
344
+ this.session = !this.expirationDate;
248
345
  }
249
- if (typeof path === 'string') {
250
- this.path = path;
346
+ }
347
+
348
+ /**
349
+ * Sets value for `expirationDate` property.
350
+ * @param expires The value as string, date, or a number
351
+ */
352
+ setExpirationTime(expires: Date | string | number | undefined): void {
353
+ let value: number | undefined;
354
+ const typedNumber = Number(expires);
355
+ if (!Number.isNaN(typedNumber)) {
356
+ value = typedNumber;
357
+ } else if (expires instanceof Date) {
358
+ value = expires.getTime();
359
+ } else if (typeof expires === 'string') {
360
+ const tmp = new Date(expires);
361
+ if (tmp.toString() === 'Invalid Date') {
362
+ value = 0;
363
+ } else {
364
+ value = tmp.getTime();
365
+ }
251
366
  } else {
252
- this.path = undefined;
367
+ value = undefined;
253
368
  }
369
+ this._expirationDate = value;
370
+ this.session = !value;
371
+ }
372
+
373
+ /**
374
+ * @return Cookie's `name=value` string.
375
+ */
376
+ toString(): string {
377
+ const { name, value } = this;
378
+ return `${name}=${value}`;
254
379
  }
255
380
 
256
381
  toJSON(): IHttpCookie {
@@ -282,4 +407,41 @@ export class HttpCookie {
282
407
  }
283
408
  return result;
284
409
  }
410
+
411
+ /**
412
+ * Returns a Cookie as a HTTP header string.
413
+ * @return Cookie string as a HTTP header value
414
+ */
415
+ toHeader(): string {
416
+ let header = this.toString();
417
+ let expires;
418
+ if (this._expirationDate) {
419
+ expires = new Date(this._expirationDate);
420
+ if (expires.toString() === 'Invalid Date') {
421
+ expires = new Date(0);
422
+ }
423
+ }
424
+ if (expires) {
425
+ header += `; expires=${expires.toUTCString()}`;
426
+ }
427
+ const { path, domain, httpOnly, sameSite, secure } = this;
428
+ if (path) {
429
+ header += `; path=${path}`;
430
+ }
431
+ if (domain) {
432
+ header += `; domain=${domain}`;
433
+ }
434
+ if (httpOnly) {
435
+ header += `; httpOnly=${httpOnly}`;
436
+ }
437
+ switch (sameSite) {
438
+ case 'lax': header += `; SameSite=Lax`; break;
439
+ case 'no_restriction': header += `; SameSite=None`; break;
440
+ case 'strict': header += `; SameSite=Strict`; break;
441
+ }
442
+ if (secure || sameSite === 'strict') {
443
+ header += `; Secure`;
444
+ }
445
+ return header;
446
+ }
285
447
  }
@@ -11,6 +11,8 @@ export interface IHttpHistory {
11
11
  * In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
12
12
  *
13
13
  * Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
14
+ *
15
+ * @readonly
14
16
  */
15
17
  key?: string;
16
18
  /**
@@ -27,9 +29,12 @@ export interface IHttpHistory {
27
29
  app?: string;
28
30
  /**
29
31
  * The user id that made that request.
30
- * Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
32
+ * Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id, making it a read-only
33
+ * value.
34
+ *
35
+ * @readonly
31
36
  */
32
- user: string;
37
+ user?: string;
33
38
  /**
34
39
  * The optional request id in the project that generated this log.
35
40
  */
@@ -80,13 +85,15 @@ export interface IHttpHistoryBulkAdd {
80
85
 
81
86
  /**
82
87
  * An HTTP history is an object containing an information of a request and response
83
- * made with the application.
88
+ * made by an application.
84
89
  *
85
90
  * Note, history object are not mutable. Can only be created or deleted.
86
91
  */
87
92
  export class HttpHistory {
88
- [createdSymbol]: number;
89
- [midnightSymbol]: number;
93
+ [createdSymbol] = 0;
94
+
95
+ [midnightSymbol] = 0;
96
+
90
97
  kind = Kind;
91
98
  /**
92
99
  * The data store key. Only present when the object was already inserted into the data store.