@api-client/core 0.3.12 → 0.4.2

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 (347) hide show
  1. package/build/browser.d.ts +10 -8
  2. package/build/browser.js +11 -7
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +12 -11
  5. package/build/index.js +9 -9
  6. package/build/index.js.map +1 -1
  7. package/build/src/data/JmesparthReader.d.ts +1 -1
  8. package/build/src/data/JmesparthReader.js +1 -1
  9. package/build/src/events/models/ProjectEvents.d.ts +1 -1
  10. package/build/src/events/models/ProjectEvents.js +1 -2
  11. package/build/src/events/models/ProjectEvents.js.map +1 -1
  12. package/build/src/lib/transformers/PayloadSerializer.d.ts +2 -2
  13. package/build/src/lib/transformers/PayloadSerializer.js +3 -3
  14. package/build/src/lib/transformers/PayloadSerializer.js.map +1 -1
  15. package/build/src/mocking/ProjectMock.d.ts +1 -1
  16. package/build/src/mocking/lib/Request.d.ts +2 -2
  17. package/build/src/mocking/lib/Request.js +3 -2
  18. package/build/src/mocking/lib/Request.js.map +1 -1
  19. package/build/src/mocking/lib/Response.d.ts +6 -6
  20. package/build/src/mocking/lib/Response.js +6 -6
  21. package/build/src/mocking/lib/Response.js.map +1 -1
  22. package/build/src/mocking/lib/User.js +3 -0
  23. package/build/src/mocking/lib/User.js.map +1 -1
  24. package/build/src/models/AuthorizationData.d.ts +2 -2
  25. package/build/src/models/AuthorizationData.js +2 -2
  26. package/build/src/models/ClientCertificate.d.ts +1 -1
  27. package/build/src/models/Environment.d.ts +3 -3
  28. package/build/src/models/Environment.js +3 -3
  29. package/build/src/models/Environment.js.map +1 -1
  30. package/build/src/models/ErrorResponse.d.ts +1 -1
  31. package/build/src/models/ErrorResponse.js +1 -1
  32. package/build/src/models/HostRule.d.ts +4 -4
  33. package/build/src/models/HostRule.js +4 -4
  34. package/build/src/models/HostRule.js.map +1 -1
  35. package/build/src/models/HttpHistory.d.ts +30 -1
  36. package/build/src/models/HttpHistory.js +1 -1
  37. package/build/src/models/HttpHistory.js.map +1 -1
  38. package/build/src/models/HttpProject.d.ts +41 -6
  39. package/build/src/models/HttpProject.js +52 -4
  40. package/build/src/models/HttpProject.js.map +1 -1
  41. package/build/src/models/HttpProjectListItem.d.ts +1 -1
  42. package/build/src/models/HttpProjectListItem.js +1 -1
  43. package/build/src/models/HttpProjectListItem.js.map +1 -1
  44. package/build/src/models/HttpRequest.d.ts +2 -2
  45. package/build/src/models/HttpRequest.js +2 -2
  46. package/build/src/models/HttpRequest.js.map +1 -1
  47. package/build/src/models/HttpResponse.d.ts +2 -2
  48. package/build/src/models/HttpResponse.js +3 -3
  49. package/build/src/models/HttpResponse.js.map +1 -1
  50. package/build/src/models/License.d.ts +3 -3
  51. package/build/src/models/License.js +3 -3
  52. package/build/src/models/License.js.map +1 -1
  53. package/build/src/models/ProjectFolder.d.ts +2 -2
  54. package/build/src/models/ProjectFolder.js +3 -3
  55. package/build/src/models/ProjectFolder.js.map +1 -1
  56. package/build/src/models/ProjectItem.d.ts +1 -1
  57. package/build/src/models/ProjectItem.js +2 -2
  58. package/build/src/models/ProjectItem.js.map +1 -1
  59. package/build/src/models/ProjectRequest.d.ts +2 -2
  60. package/build/src/models/ProjectRequest.js +1 -1
  61. package/build/src/models/ProjectRequest.js.map +1 -1
  62. package/build/src/models/ProjectSchema.d.ts +2 -2
  63. package/build/src/models/ProjectSchema.js +1 -1
  64. package/build/src/models/ProjectSchema.js.map +1 -1
  65. package/build/src/models/Property.d.ts +4 -4
  66. package/build/src/models/Property.js +4 -4
  67. package/build/src/models/Property.js.map +1 -1
  68. package/build/src/models/Provider.d.ts +3 -3
  69. package/build/src/models/Provider.js +3 -3
  70. package/build/src/models/Provider.js.map +1 -1
  71. package/build/src/models/Request.d.ts +2 -2
  72. package/build/src/models/Request.js +3 -3
  73. package/build/src/models/Request.js.map +1 -1
  74. package/build/src/models/RequestActions.d.ts +2 -4
  75. package/build/src/models/RequestActions.js +2 -4
  76. package/build/src/models/RequestActions.js.map +1 -1
  77. package/build/src/models/RequestAuthorization.d.ts +3 -5
  78. package/build/src/models/RequestAuthorization.js +2 -4
  79. package/build/src/models/RequestAuthorization.js.map +1 -1
  80. package/build/src/models/RequestConfig.d.ts +3 -5
  81. package/build/src/models/RequestConfig.js +1 -3
  82. package/build/src/models/RequestConfig.js.map +1 -1
  83. package/build/src/models/RequestLog.d.ts +14 -8
  84. package/build/src/models/RequestLog.js +18 -7
  85. package/build/src/models/RequestLog.js.map +1 -1
  86. package/build/src/models/RequestTime.d.ts +4 -6
  87. package/build/src/models/RequestTime.js +2 -4
  88. package/build/src/models/RequestTime.js.map +1 -1
  89. package/build/src/models/RequestUiMeta.d.ts +5 -5
  90. package/build/src/models/RequestUiMeta.js +2 -2
  91. package/build/src/models/RequestUiMeta.js.map +1 -1
  92. package/build/src/models/RequestsSize.d.ts +1 -3
  93. package/build/src/models/RequestsSize.js +1 -3
  94. package/build/src/models/RequestsSize.js.map +1 -1
  95. package/build/src/models/{ArcResponse.d.ts → Response.d.ts} +7 -9
  96. package/build/src/models/{ArcResponse.js → Response.js} +4 -6
  97. package/build/src/models/Response.js.map +1 -0
  98. package/build/src/models/ResponseAuthorization.d.ts +3 -3
  99. package/build/src/models/ResponseAuthorization.js +3 -3
  100. package/build/src/models/ResponseAuthorization.js.map +1 -1
  101. package/build/src/models/ResponseRedirect.d.ts +3 -5
  102. package/build/src/models/ResponseRedirect.js +1 -3
  103. package/build/src/models/ResponseRedirect.js.map +1 -1
  104. package/build/src/models/RevisionInfo.d.ts +1 -1
  105. package/build/src/models/RevisionInfo.js +1 -1
  106. package/build/src/models/RevisionInfo.js.map +1 -1
  107. package/build/src/models/SentRequest.d.ts +2 -4
  108. package/build/src/models/SentRequest.js +1 -3
  109. package/build/src/models/SentRequest.js.map +1 -1
  110. package/build/src/models/Server.d.ts +3 -3
  111. package/build/src/models/Server.js +3 -3
  112. package/build/src/models/Server.js.map +1 -1
  113. package/build/src/models/Thing.d.ts +3 -3
  114. package/build/src/models/Thing.js +3 -3
  115. package/build/src/models/Thing.js.map +1 -1
  116. package/build/src/models/Url.d.ts +2 -4
  117. package/build/src/models/Url.js +2 -4
  118. package/build/src/models/Url.js.map +1 -1
  119. package/build/src/models/User.d.ts +2 -1
  120. package/build/src/models/User.js +1 -1
  121. package/build/src/models/User.js.map +1 -1
  122. package/build/src/models/WebApi.d.ts +1 -1
  123. package/build/src/models/WebApi.js +1 -1
  124. package/build/src/models/WebApi.js.map +1 -1
  125. package/build/src/models/WebApiIndex.d.ts +1 -1
  126. package/build/src/models/WebApiIndex.js +1 -1
  127. package/build/src/models/WebApiIndex.js.map +1 -1
  128. package/build/src/models/Workspace.d.ts +4 -4
  129. package/build/src/models/Workspace.js +4 -4
  130. package/build/src/models/Workspace.js.map +1 -1
  131. package/build/src/models/actions/Action.d.ts +2 -2
  132. package/build/src/models/actions/Action.js +1 -1
  133. package/build/src/models/actions/Action.js.map +1 -1
  134. package/build/src/models/actions/Condition.d.ts +2 -2
  135. package/build/src/models/actions/Condition.js +1 -1
  136. package/build/src/models/actions/Condition.js.map +1 -1
  137. package/build/src/models/actions/RunnableAction.d.ts +1 -1
  138. package/build/src/models/actions/RunnableAction.js +1 -1
  139. package/build/src/models/actions/RunnableAction.js.map +1 -1
  140. package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +2 -2
  141. package/build/src/models/actions/runnable/DeleteCookieAction.js +1 -1
  142. package/build/src/models/actions/runnable/DeleteCookieAction.js.map +1 -1
  143. package/build/src/models/actions/runnable/SetCookieAction.d.ts +2 -2
  144. package/build/src/models/actions/runnable/SetCookieAction.js +1 -1
  145. package/build/src/models/actions/runnable/SetCookieAction.js.map +1 -1
  146. package/build/src/models/actions/runnable/SetVariableAction.d.ts +2 -2
  147. package/build/src/models/actions/runnable/SetVariableAction.js +1 -1
  148. package/build/src/models/actions/runnable/SetVariableAction.js.map +1 -1
  149. package/build/src/models/transformers/ImportUtils.d.ts +1 -1
  150. package/build/src/models/transformers/ImportUtils.js +1 -1
  151. package/build/src/models/transformers/PostmanBackupTransformer.js +2 -1
  152. package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -1
  153. package/build/src/models/transformers/PostmanV21Transformer.js +2 -1
  154. package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
  155. package/build/src/models/transformers/PostmanV2Transformer.js +2 -1
  156. package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
  157. package/build/src/runtime/actions/RunnableCondition.d.ts +6 -7
  158. package/build/src/runtime/actions/RunnableCondition.js +4 -5
  159. package/build/src/runtime/actions/RunnableCondition.js.map +1 -1
  160. package/build/src/runtime/http-engine/{ArcEngine.d.ts → CoreEngine.d.ts} +3 -3
  161. package/build/src/runtime/http-engine/{ArcEngine.js → CoreEngine.js} +8 -8
  162. package/build/src/runtime/http-engine/CoreEngine.js.map +1 -0
  163. package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
  164. package/build/src/runtime/http-engine/HttpEngine.js +3 -20
  165. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  166. package/build/src/runtime/modules/BasicAuthCache.js +2 -5
  167. package/build/src/runtime/modules/BasicAuthCache.js.map +1 -1
  168. package/build/src/runtime/modules/RequestCookies.d.ts +1 -1
  169. package/build/src/runtime/modules/RequestCookies.js +3 -2
  170. package/build/src/runtime/modules/RequestCookies.js.map +1 -1
  171. package/build/src/runtime/node/InteropInterfaces.d.ts +115 -0
  172. package/build/src/runtime/node/InteropInterfaces.js +2 -0
  173. package/build/src/runtime/node/InteropInterfaces.js.map +1 -0
  174. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -7
  175. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  176. package/build/src/runtime/node/ProjectRequestRunner.d.ts +17 -49
  177. package/build/src/runtime/node/ProjectRequestRunner.js +39 -10
  178. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  179. package/build/src/runtime/node/ProjectRunner.d.ts +1 -59
  180. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  181. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
  182. package/build/src/runtime/node/RequestFactory.d.ts +1 -1
  183. package/build/src/runtime/node/RequestFactory.js +3 -3
  184. package/build/src/runtime/node/RequestFactory.js.map +1 -1
  185. package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -1
  186. package/build/src/runtime/reporters/Reporter.js.map +1 -1
  187. package/build/src/runtime/store/AuthSdk.d.ts +28 -0
  188. package/build/src/runtime/store/AuthSdk.js +123 -0
  189. package/build/src/runtime/store/AuthSdk.js.map +1 -0
  190. package/build/src/runtime/store/BackendSdk.d.ts +8 -0
  191. package/build/src/runtime/store/BackendSdk.js +25 -0
  192. package/build/src/runtime/store/BackendSdk.js.map +1 -0
  193. package/build/src/runtime/store/HistorySdk.d.ts +48 -0
  194. package/build/src/runtime/store/HistorySdk.js +142 -0
  195. package/build/src/runtime/store/HistorySdk.js.map +1 -0
  196. package/build/src/runtime/store/Http.d.ts +14 -0
  197. package/build/src/runtime/store/Http.js +4 -0
  198. package/build/src/runtime/store/Http.js.map +1 -0
  199. package/build/src/runtime/store/HttpNode.d.ts +16 -0
  200. package/build/src/runtime/store/HttpNode.js +95 -0
  201. package/build/src/runtime/store/HttpNode.js.map +1 -0
  202. package/build/src/runtime/store/HttpWeb.d.ts +15 -0
  203. package/build/src/runtime/store/HttpWeb.js +83 -0
  204. package/build/src/runtime/store/HttpWeb.js.map +1 -0
  205. package/build/src/runtime/store/ProjectsSdk.d.ts +43 -0
  206. package/build/src/runtime/store/ProjectsSdk.js +144 -0
  207. package/build/src/runtime/store/ProjectsSdk.js.map +1 -0
  208. package/build/src/runtime/store/RouteBuilder.d.ts +42 -0
  209. package/build/src/runtime/store/RouteBuilder.js +75 -0
  210. package/build/src/runtime/store/RouteBuilder.js.map +1 -0
  211. package/build/src/runtime/store/Sdk.d.ts +79 -0
  212. package/build/src/runtime/store/Sdk.js +117 -0
  213. package/build/src/runtime/store/Sdk.js.map +1 -0
  214. package/build/src/runtime/store/SdkBase.d.ts +45 -0
  215. package/build/src/runtime/store/SdkBase.js +40 -0
  216. package/build/src/runtime/store/SdkBase.js.map +1 -0
  217. package/build/src/runtime/store/SpacesSdk.d.ts +50 -0
  218. package/build/src/runtime/store/SpacesSdk.js +185 -0
  219. package/build/src/runtime/store/SpacesSdk.js.map +1 -0
  220. package/build/src/runtime/store/StoreSdkNode.d.ts +10 -0
  221. package/build/src/runtime/store/StoreSdkNode.js +11 -0
  222. package/build/src/runtime/store/StoreSdkNode.js.map +1 -0
  223. package/build/src/runtime/store/StoreSdkWeb.d.ts +10 -0
  224. package/build/src/runtime/store/StoreSdkWeb.js +11 -0
  225. package/build/src/runtime/store/StoreSdkWeb.js.map +1 -0
  226. package/build/src/runtime/store/UsersSdk.d.ts +18 -0
  227. package/build/src/runtime/store/UsersSdk.js +88 -0
  228. package/build/src/runtime/store/UsersSdk.js.map +1 -0
  229. package/build/src/runtime/store/WsClient.d.ts +24 -0
  230. package/build/src/runtime/store/WsClient.js +4 -0
  231. package/build/src/runtime/store/WsClient.js.map +1 -0
  232. package/build/src/runtime/store/WsClientNode.d.ts +24 -0
  233. package/build/src/runtime/store/WsClientNode.js +66 -0
  234. package/build/src/runtime/store/WsClientNode.js.map +1 -0
  235. package/build/src/runtime/store/WsClientWeb.d.ts +23 -0
  236. package/build/src/runtime/store/WsClientWeb.js +73 -0
  237. package/build/src/runtime/store/WsClientWeb.js.map +1 -0
  238. package/package.json +6 -8
  239. package/readme.md +5 -5
  240. package/src/data/JmesparthReader.ts +1 -1
  241. package/src/events/models/ProjectEvents.ts +2 -2
  242. package/src/events/readme.md +1 -1
  243. package/src/lib/transformers/PayloadSerializer.ts +3 -3
  244. package/src/mocking/ProjectMock.ts +1 -1
  245. package/src/mocking/lib/Request.ts +5 -5
  246. package/src/mocking/lib/Response.ts +10 -10
  247. package/src/mocking/lib/User.ts +2 -1
  248. package/src/models/AuthorizationData.ts +2 -2
  249. package/src/models/ClientCertificate.ts +1 -1
  250. package/src/models/Environment.ts +4 -4
  251. package/src/models/ErrorResponse.ts +1 -1
  252. package/src/models/HostRule.ts +5 -5
  253. package/src/models/HttpHistory.ts +31 -1
  254. package/src/models/HttpProject.ts +87 -7
  255. package/src/models/HttpProjectListItem.ts +1 -1
  256. package/src/models/HttpRequest.ts +2 -2
  257. package/src/models/HttpResponse.ts +3 -3
  258. package/src/models/License.ts +4 -4
  259. package/src/models/ProjectFolder.ts +3 -3
  260. package/src/models/ProjectItem.ts +2 -2
  261. package/src/models/ProjectRequest.ts +2 -2
  262. package/src/models/ProjectSchema.ts +2 -2
  263. package/src/models/Property.ts +5 -5
  264. package/src/models/Provider.ts +4 -4
  265. package/src/models/README.md +2 -2
  266. package/src/models/Request.ts +4 -4
  267. package/src/models/RequestActions.ts +2 -4
  268. package/src/models/RequestAuthorization.ts +3 -5
  269. package/src/models/RequestConfig.ts +3 -5
  270. package/src/models/RequestLog.ts +25 -11
  271. package/src/models/RequestTime.ts +4 -6
  272. package/src/models/RequestUiMeta.ts +5 -5
  273. package/src/models/RequestsSize.ts +1 -3
  274. package/src/models/{ArcResponse.ts → Response.ts} +12 -14
  275. package/src/models/ResponseAuthorization.ts +4 -4
  276. package/src/models/ResponseRedirect.ts +3 -5
  277. package/src/models/RevisionInfo.ts +1 -1
  278. package/src/models/SentRequest.ts +2 -4
  279. package/src/models/Server.ts +4 -4
  280. package/src/models/Thing.ts +4 -4
  281. package/src/models/Url.ts +2 -4
  282. package/src/models/User.ts +2 -1
  283. package/src/models/WebApi.ts +1 -1
  284. package/src/models/WebApiIndex.ts +1 -1
  285. package/src/models/Workspace.ts +5 -5
  286. package/src/models/actions/Action.ts +2 -2
  287. package/src/models/actions/Condition.ts +2 -2
  288. package/src/models/actions/RunnableAction.ts +1 -1
  289. package/src/models/actions/runnable/DeleteCookieAction.ts +2 -2
  290. package/src/models/actions/runnable/SetCookieAction.ts +2 -2
  291. package/src/models/actions/runnable/SetVariableAction.ts +2 -2
  292. package/src/models/transformers/ImportUtils.ts +1 -1
  293. package/src/models/transformers/PostmanBackupTransformer.ts +2 -1
  294. package/src/models/transformers/PostmanV21Transformer.ts +2 -1
  295. package/src/models/transformers/PostmanV2Transformer.ts +2 -1
  296. package/src/runtime/actions/RunnableCondition.ts +6 -7
  297. package/src/runtime/http-engine/{ArcEngine.ts → CoreEngine.ts} +7 -7
  298. package/src/runtime/http-engine/HttpEngine.ts +5 -24
  299. package/src/runtime/modules/BasicAuthCache.ts +2 -6
  300. package/src/runtime/modules/RequestCookies.ts +6 -5
  301. package/src/runtime/node/InteropInterfaces.ts +121 -0
  302. package/src/runtime/node/ProjectParallelRunner.ts +2 -9
  303. package/src/runtime/node/ProjectRequestRunner.ts +42 -61
  304. package/src/runtime/node/ProjectRunner.ts +1 -60
  305. package/src/runtime/node/ProjectRunnerWorker.ts +2 -1
  306. package/src/runtime/node/RequestFactory.ts +3 -3
  307. package/src/runtime/reporters/ProjectRunCliReporter.ts +2 -2
  308. package/src/runtime/reporters/Reporter.ts +4 -4
  309. package/src/runtime/store/AuthSdk.ts +126 -0
  310. package/src/runtime/store/BackendSdk.ts +25 -0
  311. package/src/runtime/store/HistorySdk.ts +157 -0
  312. package/src/runtime/store/Http.ts +18 -0
  313. package/src/runtime/store/HttpNode.ts +100 -0
  314. package/src/runtime/store/HttpWeb.ts +89 -0
  315. package/src/runtime/store/ProjectsSdk.ts +147 -0
  316. package/src/runtime/store/RouteBuilder.ts +89 -0
  317. package/src/runtime/store/Sdk.ts +131 -0
  318. package/src/runtime/store/SdkBase.ts +72 -0
  319. package/src/runtime/store/SpacesSdk.ts +190 -0
  320. package/src/runtime/store/StoreSdkNode.ts +13 -0
  321. package/src/runtime/store/StoreSdkWeb.ts +13 -0
  322. package/src/runtime/store/UsersSdk.ts +89 -0
  323. package/src/runtime/store/WsClient.ts +28 -0
  324. package/src/runtime/store/WsClientNode.ts +68 -0
  325. package/src/runtime/store/WsClientWeb.ts +75 -0
  326. package/build/src/models/ArcResponse.js.map +0 -1
  327. package/build/src/models/HistoryIndex.d.ts +0 -43
  328. package/build/src/models/HistoryIndex.js +0 -53
  329. package/build/src/models/HistoryIndex.js.map +0 -1
  330. package/build/src/models/HistoryRequest.d.ts +0 -13
  331. package/build/src/models/HistoryRequest.js +0 -25
  332. package/build/src/models/HistoryRequest.js.map +0 -1
  333. package/build/src/runtime/http-engine/ArcEngine.js.map +0 -1
  334. package/build/src/runtime/http-engine/NodeEngine.d.ts +0 -154
  335. package/build/src/runtime/http-engine/NodeEngine.js +0 -766
  336. package/build/src/runtime/http-engine/NodeEngine.js.map +0 -1
  337. package/build/src/runtime/http-engine/NodeEngineDirect.d.ts +0 -113
  338. package/build/src/runtime/http-engine/NodeEngineDirect.js +0 -449
  339. package/build/src/runtime/http-engine/NodeEngineDirect.js.map +0 -1
  340. package/build/src/runtime/store/StoreSdk.d.ts +0 -279
  341. package/build/src/runtime/store/StoreSdk.js +0 -840
  342. package/build/src/runtime/store/StoreSdk.js.map +0 -1
  343. package/src/models/HistoryIndex.ts +0 -76
  344. package/src/models/HistoryRequest.ts +0 -28
  345. package/src/runtime/http-engine/NodeEngine.ts +0 -792
  346. package/src/runtime/http-engine/NodeEngineDirect.ts +0 -482
  347. package/src/runtime/store/StoreSdk.ts +0 -895
@@ -0,0 +1,131 @@
1
+ import { IListOptions } from '../../models/Backend.js';
2
+ import { Http } from './Http.js';
3
+ import { WsClient } from './WsClient.js';
4
+ import { AuthSdk } from './AuthSdk.js';
5
+ import { BackendSdk } from './BackendSdk.js';
6
+ import { SpacesSdk } from './SpacesSdk.js';
7
+ import { ProjectsSdk } from './ProjectsSdk.js';
8
+ import { UsersSdk } from './UsersSdk.js';
9
+ import { HistorySdk } from './HistorySdk.js';
10
+
11
+ const baseUriSymbol = Symbol('baseUri');
12
+
13
+ /**
14
+ * NodeJS API for API Client's net-store module.
15
+ */
16
+ export abstract class Sdk {
17
+ /**
18
+ * The token to use with requests. Can be overwritten with each API call.
19
+ */
20
+ token?: string;
21
+ /**
22
+ * The user authentication features.
23
+ */
24
+ auth = new AuthSdk(this);
25
+ /**
26
+ * The store information features
27
+ */
28
+ store = new BackendSdk(this);
29
+ /**
30
+ * The user spaces features.
31
+ */
32
+ space = new SpacesSdk(this);
33
+ /**
34
+ * The user projects features.
35
+ */
36
+ project = new ProjectsSdk(this);
37
+ /**
38
+ * Reads user information.
39
+ */
40
+ user = new UsersSdk(this);
41
+ /**
42
+ * The HTTP(S) requests.
43
+ */
44
+ abstract http: Http;
45
+ /**
46
+ * The web socket requests.
47
+ */
48
+ abstract ws: WsClient;
49
+ /**
50
+ * The history data.
51
+ */
52
+ history = new HistorySdk(this);
53
+
54
+
55
+ [baseUriSymbol] = '';
56
+
57
+ /**
58
+ * @returns The base URI to the store.
59
+ */
60
+ get baseUri(): string {
61
+ return this[baseUriSymbol];
62
+ }
63
+
64
+ /**
65
+ * @param value The base URI to the store.
66
+ */
67
+ set baseUri(value: string) {
68
+ if (!value) {
69
+ throw new Error(`Invalid value for the baseUri`);
70
+ }
71
+ let url: URL;
72
+ try {
73
+ url = new URL(value);
74
+ } catch (e) {
75
+ throw new Error(`Invalid baseUri: Not an URL`);
76
+ }
77
+ this[baseUriSymbol] = url.origin;
78
+ const { pathname } = url;
79
+ if (pathname && pathname !== '/') {
80
+ this.basePath = pathname;
81
+ } else {
82
+ this.basePath = undefined;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * @param baseUri The base URI to the store.
88
+ * @param basePath The base path (the router prefix) for the server.
89
+ */
90
+ constructor(baseUri: string, public basePath?: string) {
91
+ this.baseUri = baseUri;
92
+ }
93
+
94
+ /**
95
+ * Creates a full URL for a path.
96
+ * This adds the server's base path and the passed path to the configured base URL.
97
+ * @param path The path to the endpoint, without the base path.
98
+ */
99
+ getUrl(path='/'): URL {
100
+ const { baseUri, basePath='' } = this;
101
+ let userPath = path;
102
+ if (basePath && userPath.startsWith(basePath)) {
103
+ userPath = userPath.substring(basePath.length);
104
+ }
105
+ return new URL(`${basePath}${userPath}`, baseUri);
106
+ }
107
+
108
+ /**
109
+ * Appends list options to the query parameters.
110
+ * @param url The URL object to the API endpoint
111
+ * @param options The list options, if any
112
+ */
113
+ appendListOptions(url: URL, options: IListOptions = {}): void {
114
+ const { searchParams } = url;
115
+ if (options.cursor) {
116
+ searchParams.set('cursor', options.cursor);
117
+ } else {
118
+ if (typeof options.limit === 'number') {
119
+ searchParams.set('limit', String(options.limit));
120
+ }
121
+ if (options.query) {
122
+ searchParams.set('query', options.query);
123
+ }
124
+ if (Array.isArray(options.queryField)) {
125
+ options.queryField.forEach((field) => {
126
+ searchParams.append('queryField', field);
127
+ });
128
+ }
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,72 @@
1
+ import { Headers } from '../../lib/headers/Headers.js';
2
+ import { Sdk } from './Sdk.js';
3
+
4
+ export interface IStoreRequestOptions {
5
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
6
+ headers?: Record<string, string>,
7
+ body?: string | Buffer;
8
+ /**
9
+ * Adds the token to the headers.
10
+ */
11
+ token?: string;
12
+ }
13
+
14
+ export interface IStoreResponse {
15
+ status: number;
16
+ headers: Headers;
17
+ body?: string;
18
+ }
19
+
20
+ export interface IStoreTokenInfo {
21
+ /**
22
+ * The token to use.
23
+ */
24
+ token: string;
25
+ /**
26
+ * The timestamp when the token expires.
27
+ * Note, clients may have a different date than the store.
28
+ *
29
+ * May not be set when the token does not expire.
30
+ */
31
+ expires?: number;
32
+ }
33
+
34
+ export const E_INVALID_JSON = 'The response is not a valid JSON.';
35
+ export const E_RESPONSE_NO_VALUE = 'The response has no value.';
36
+ export const E_RESPONSE_STATUS = 'Invalid response status: ';
37
+ export const E_RESPONSE_UNKNOWN = 'The response has unknown format.';
38
+ export const E_RESPONSE_LOCATION = 'The response has no "location" header.';
39
+
40
+
41
+ export class SdkBase {
42
+ constructor(public sdk: Sdk) {}
43
+
44
+ protected logInvalidResponse(response: IStoreResponse): void {
45
+ if (response.body) {
46
+ try {
47
+ const data = JSON.parse(response.body);
48
+ if (data.message) {
49
+ console.warn(`[Store message]: ${data.message}`);
50
+ }
51
+ } catch (e) {
52
+ // .
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Throws unified message for a common error status codes.
59
+ * It handles 404, 403, and 401 status codes.
60
+ */
61
+ protected inspectCommonStatusCodes(status: number): void {
62
+ if (status === 404) {
63
+ throw new Error(`Not found.`);
64
+ }
65
+ if (status === 403) {
66
+ throw new Error(`You have no access to this resource.`);
67
+ }
68
+ if (status === 401) {
69
+ throw new Error(`Not authorized.`);
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,190 @@
1
+ import { JsonPatch } from 'json8-patch';
2
+ import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION } from './SdkBase.js';
3
+ import { RouteBuilder } from './RouteBuilder.js';
4
+ import { IListOptions, IListResponse } from '../../models/Backend.js';
5
+ import { IWorkspace, IUserWorkspace, Workspace, Kind as WorkspaceKind } from '../../models/Workspace.js';
6
+ import { UserAccessOperation } from '../../models/User.js';
7
+
8
+ export class SpacesSdk extends SdkBase {
9
+ /**
10
+ * Lists spaces in the store.
11
+ * @param options Optional query options.
12
+ */
13
+ async list(options?: IListOptions): Promise<IListResponse> {
14
+ const { token } = this.sdk;
15
+ const url = this.sdk.getUrl(RouteBuilder.spaces());
16
+ this.sdk.appendListOptions(url, options);
17
+ const result = await this.sdk.http.get(url.toString(), { token });
18
+ this.inspectCommonStatusCodes(result.status);
19
+ const E_PREFIX = 'Unable to list spaces. ';
20
+ if (result.status !== 200) {
21
+ this.logInvalidResponse(result);
22
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
23
+ }
24
+ if (!result.body) {
25
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
26
+ }
27
+ let data: IListResponse;
28
+ try {
29
+ data = JSON.parse(result.body);
30
+ } catch (e) {
31
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
32
+ }
33
+ if (!Array.isArray(data.data)) {
34
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
35
+ }
36
+ return data;
37
+ }
38
+
39
+ /**
40
+ * Creates a workspace in the store.
41
+ * @param space The workspace definition.
42
+ * @returns The key of the creates space.
43
+ */
44
+ async create(space: IWorkspace | Workspace): Promise<string> {
45
+ const { token } = this.sdk;
46
+ const url = this.sdk.getUrl(RouteBuilder.spaces());
47
+ const body = JSON.stringify(space);
48
+ const result = await this.sdk.http.post(url.toString(), { token, body });
49
+ this.inspectCommonStatusCodes(result.status);
50
+ const E_PREFIX = 'Unable to create a user space. ';
51
+ if (result.status !== 204) {
52
+ this.logInvalidResponse(result);
53
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
54
+ }
55
+ const location = result.headers.get('location');
56
+ if (!location) {
57
+ throw new Error(`${E_PREFIX}${E_RESPONSE_LOCATION}`);
58
+ }
59
+ const id = location.split('/').pop();
60
+ return id as string;
61
+ }
62
+
63
+ /**
64
+ * Reads a user space definition from the store.
65
+ * @param key The user space key
66
+ * @returns The definition of the user space.
67
+ */
68
+ async read(key: string): Promise<IUserWorkspace> {
69
+ const { token } = this.sdk;
70
+ const url = this.sdk.getUrl(RouteBuilder.space(key));
71
+ const result = await this.sdk.http.get(url.toString(), { token });
72
+ this.inspectCommonStatusCodes(result.status);
73
+ const E_PREFIX = 'Unable to read a user space. ';
74
+ if (result.status !== 200) {
75
+ this.logInvalidResponse(result);
76
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
77
+ }
78
+ if (!result.body) {
79
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
80
+ }
81
+ let data: IUserWorkspace;
82
+ try {
83
+ data = JSON.parse(result.body);
84
+ } catch (e) {
85
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
86
+ }
87
+ if (data.kind !== WorkspaceKind) {
88
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
89
+ }
90
+ return data;
91
+ }
92
+
93
+ /**
94
+ * Patches a user space in the store.
95
+ * @param key The key of the user space to patch
96
+ * @param value The JSON patch to be processed.
97
+ * @returns The JSON patch to revert the change using the `json8-patch` library
98
+ */
99
+ async patch(key: string, value: JsonPatch): Promise<JsonPatch> {
100
+ const { token } = this.sdk;
101
+ const url = this.sdk.getUrl(RouteBuilder.space(key));
102
+ const body = JSON.stringify(value);
103
+ const result = await this.sdk.http.patch(url.toString(), { token, body });
104
+ this.inspectCommonStatusCodes(result.status);
105
+ const E_PREFIX = 'Unable to patch a user space. ';
106
+ if (result.status !== 200) {
107
+ this.logInvalidResponse(result);
108
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
109
+ }
110
+ if (!result.body) {
111
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
112
+ }
113
+ let data: any;
114
+ try {
115
+ data = JSON.parse(result.body);
116
+ } catch (e) {
117
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
118
+ }
119
+ if (!data.revert) {
120
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
121
+ }
122
+ return data.revert as JsonPatch;
123
+ }
124
+
125
+ /**
126
+ * Deletes the space in the store.
127
+ *
128
+ * @param key The key of the space to delete.
129
+ */
130
+ async delete(key: string): Promise<void> {
131
+ const { token } = this.sdk;
132
+ const url = this.sdk.getUrl(RouteBuilder.space(key));
133
+ const result = await this.sdk.http.delete(url.toString(), { token });
134
+ this.inspectCommonStatusCodes(result.status);
135
+ const E_PREFIX = 'Unable to delete a user space. ';
136
+ if (result.status !== 204) {
137
+ this.logInvalidResponse(result);
138
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Updates the sharing options of the space.
144
+ *
145
+ * @param key The user space key
146
+ * @param value The patch operation on the space's ACL
147
+ */
148
+ async patchUsers(key: string, value: UserAccessOperation[]): Promise<void> {
149
+ const { token } = this.sdk;
150
+ const url = this.sdk.getUrl(RouteBuilder.spaceUsers(key));
151
+ const body = JSON.stringify(value);
152
+ const result = await this.sdk.http.patch(url.toString(), { token, body });
153
+ this.inspectCommonStatusCodes(result.status);
154
+ const E_PREFIX = 'Unable to patch a user space. ';
155
+ if (result.status !== 204) {
156
+ this.logInvalidResponse(result);
157
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Lists uses having access to the user space.
163
+ *
164
+ * @param key The user space key
165
+ */
166
+ async listUsers(key: string): Promise<IListResponse> {
167
+ const { token } = this.sdk;
168
+ const url = this.sdk.getUrl(RouteBuilder.spaceUsers(key));
169
+ const result = await this.sdk.http.get(url.toString(), { token });
170
+ this.inspectCommonStatusCodes(result.status);
171
+ const E_PREFIX = 'Unable to list users in the space. ';
172
+ if (result.status !== 200) {
173
+ this.logInvalidResponse(result);
174
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
175
+ }
176
+ if (!result.body) {
177
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
178
+ }
179
+ let data: IListResponse;
180
+ try {
181
+ data = JSON.parse(result.body);
182
+ } catch (e) {
183
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
184
+ }
185
+ if (!Array.isArray(data.data)) {
186
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
187
+ }
188
+ return data;
189
+ }
190
+ }
@@ -0,0 +1,13 @@
1
+ import { HttpNode } from './HttpNode.js';
2
+ import { WsClientNode } from './WsClientNode.js';
3
+ import { Sdk } from './Sdk.js';
4
+ import { Http } from './Http.js';
5
+ import { WsClient } from './WsClient.js';
6
+
7
+ /**
8
+ * NodeJS API for API Client's net-store module.
9
+ */
10
+ export class StoreSdk extends Sdk {
11
+ http: Http = new HttpNode(this);
12
+ ws: WsClient = new WsClientNode(this);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { HttpWeb } from './HttpWeb.js';
2
+ import { WsClientWeb } from './WsClientWeb.js';
3
+ import { Sdk } from './Sdk.js';
4
+ import { Http } from './Http.js';
5
+ import { WsClient } from './WsClient.js';
6
+
7
+ /**
8
+ * NodeJS API for API Client's net-store module.
9
+ */
10
+ export class StoreSdk extends Sdk {
11
+ http: Http = new HttpWeb(this);
12
+ ws: WsClient = new WsClientWeb(this);
13
+ }
@@ -0,0 +1,89 @@
1
+ import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN } from './SdkBase.js';
2
+ import { RouteBuilder } from './RouteBuilder.js';
3
+ import { IListOptions, IListResponse } from '../../models/Backend.js';
4
+ import { IUser } from '../../models/User.js';
5
+
6
+ export class UsersSdk extends SdkBase {
7
+ async me(): Promise<IUser> {
8
+ const { token } = this.sdk;
9
+ const url = this.sdk.getUrl(RouteBuilder.usersMe());
10
+ const result = await this.sdk.http.get(url.toString(), { token });
11
+ this.inspectCommonStatusCodes(result.status);
12
+ const E_PREFIX = 'Unable to read a user. ';
13
+ if (result.status !== 200) {
14
+ this.logInvalidResponse(result);
15
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
16
+ }
17
+ if (!result.body) {
18
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
19
+ }
20
+ let data: IUser;
21
+ try {
22
+ data = JSON.parse(result.body);
23
+ } catch (e) {
24
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
25
+ }
26
+ if (!data.key) {
27
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
28
+ }
29
+ return data;
30
+ }
31
+
32
+ /**
33
+ * Lists users in the store
34
+ *
35
+ * @param options Optional query options.
36
+ */
37
+ async list(options?: IListOptions): Promise<IListResponse> {
38
+ const { token } = this.sdk;
39
+ const url = this.sdk.getUrl(RouteBuilder.users());
40
+ this.sdk.appendListOptions(url, options);
41
+ const result = await this.sdk.http.get(url.toString(), { token });
42
+ this.inspectCommonStatusCodes(result.status);
43
+ const E_PREFIX = 'Unable to list projects. ';
44
+ if (result.status !== 200) {
45
+ this.logInvalidResponse(result);
46
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
47
+ }
48
+ if (!result.body) {
49
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
50
+ }
51
+ let data: IListResponse;
52
+ try {
53
+ data = JSON.parse(result.body);
54
+ } catch (e) {
55
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
56
+ }
57
+ if (!Array.isArray(data.data)) {
58
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
59
+ }
60
+ return data;
61
+ }
62
+
63
+ /**
64
+ * Reads a user information from the store.
65
+ * @param key The user key.
66
+ * @returns The user object
67
+ */
68
+ async read(key: string): Promise<IUser> {
69
+ const { token } = this.sdk;
70
+ const url = this.sdk.getUrl(RouteBuilder.user(key));
71
+ const result = await this.sdk.http.get(url.toString(), { token });
72
+ this.inspectCommonStatusCodes(result.status);
73
+ const E_PREFIX = 'Unable to read the user info. ';
74
+ if (result.status !== 200) {
75
+ this.logInvalidResponse(result);
76
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
77
+ }
78
+ if (!result.body) {
79
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
80
+ }
81
+ let data: IUser;
82
+ try {
83
+ data = JSON.parse(result.body);
84
+ } catch (e) {
85
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
86
+ }
87
+ return data;
88
+ }
89
+ }
@@ -0,0 +1,28 @@
1
+ import WebSocketNode from 'ws';
2
+ import { SdkBase } from './SdkBase.js';
3
+
4
+ export abstract class WsClient extends SdkBase {
5
+ /**
6
+ * Creates a WS client with optional token
7
+ * @param addr The ws:// address
8
+ * @param token Optional token to add.
9
+ */
10
+ abstract getClient(addr: string, token?: string): WebSocket | WebSocketNode;
11
+
12
+ /**
13
+ * Connect to the WS server
14
+ *
15
+ * @param client The client to wait for connection.
16
+ */
17
+ abstract connect(client: WebSocket | WebSocketNode): Promise<void>;
18
+
19
+ /**
20
+ * Disconnects from the WS server.
21
+ */
22
+ abstract disconnect(client: WebSocket | WebSocketNode): Promise<void>;
23
+
24
+ /**
25
+ * The combination of `getClient()` and `connect()`.
26
+ */
27
+ abstract createAndConnect(addr: string, token?: string): Promise<WebSocket | WebSocketNode>;
28
+ }
@@ -0,0 +1,68 @@
1
+ import WebSocket from 'ws';
2
+ import { WsClient } from './WsClient.js';
3
+
4
+ export class WsClientNode extends WsClient {
5
+ /**
6
+ * Creates a WS client with optional token
7
+ * @param addr The ws:// address
8
+ * @param token Optional token to add.
9
+ */
10
+ getClient(addr: string, token = this.sdk.token): WebSocket {
11
+ let url = addr;
12
+ if (token) {
13
+ url += url.includes('?') ? '&' : '?';
14
+ url += 'token=';
15
+ url += token;
16
+ }
17
+ if (url.startsWith('http:')) {
18
+ url = `ws:${url.substring(5)}`;
19
+ } else if (url.startsWith('https:')) {
20
+ url = `wss:${url.substring(6)}`;
21
+ }
22
+ return new WebSocket(url);
23
+ }
24
+
25
+ /**
26
+ * Connect to the WS server
27
+ *
28
+ * @param client The client to wait for connection.
29
+ */
30
+ connect(client: WebSocket): Promise<void> {
31
+ return new Promise((resolve, reject) => {
32
+ client.once('open', () => {
33
+ client.removeAllListeners('error');
34
+ resolve();
35
+ });
36
+ client.once('error', (err) => {
37
+ client.removeAllListeners('open');
38
+ reject(err);
39
+ });
40
+ });
41
+ }
42
+
43
+ /**
44
+ * Disconnects from the WS server.
45
+ */
46
+ disconnect(client: WebSocket): Promise<void> {
47
+ return new Promise((resolve, reject) => {
48
+ client.once('close', () => {
49
+ client.removeAllListeners('error');
50
+ resolve();
51
+ });
52
+ client.once('error', (err) => {
53
+ client.removeAllListeners('close');
54
+ reject(err);
55
+ });
56
+ client.close();
57
+ });
58
+ }
59
+
60
+ /**
61
+ * The combination of `getClient()` and `connect()`.
62
+ */
63
+ async createAndConnect(addr: string, token?: string): Promise<WebSocket> {
64
+ const client = this.getClient(addr, token);
65
+ await this.connect(client);
66
+ return client;
67
+ }
68
+ }
@@ -0,0 +1,75 @@
1
+ import { WsClient } from './WsClient.js';
2
+
3
+ export class WsClientWeb extends WsClient {
4
+ /**
5
+ * Creates a WS client with optional token
6
+ * @param addr The ws:// address
7
+ * @param token Optional token to add.
8
+ */
9
+ getClient(addr: string, token = this.sdk.token): WebSocket {
10
+ let url = addr;
11
+ if (token) {
12
+ url += url.includes('?') ? '&' : '?';
13
+ url += 'token=';
14
+ url += token;
15
+ }
16
+ if (url.startsWith('http:')) {
17
+ url = `ws:${url.substring(5)}`;
18
+ } else if (url.startsWith('https:')) {
19
+ url = `wss:${url.substring(6)}`;
20
+ }
21
+ return new WebSocket(url);
22
+ }
23
+
24
+ /**
25
+ * Connect to the WS server
26
+ *
27
+ * @param client The client to wait for connection.
28
+ */
29
+ connect(client: WebSocket): Promise<void> {
30
+ return new Promise((resolve, reject) => {
31
+ function opened(): void {
32
+ client.removeEventListener('open', opened);
33
+ client.removeEventListener('error', errored);
34
+ resolve();
35
+ }
36
+ function errored(): void {
37
+ client.removeEventListener('open', opened);
38
+ client.removeEventListener('error', errored);
39
+ reject(new Error(`Unable to connect to: ${client.url}`));
40
+ }
41
+ client.addEventListener('open', opened);
42
+ client.addEventListener('error', errored);
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Disconnects from the WS server.
48
+ */
49
+ disconnect(client: WebSocket): Promise<void> {
50
+ return new Promise((resolve, reject) => {
51
+ function closed(): void {
52
+ client.removeEventListener('close', closed);
53
+ client.removeEventListener('error', errored);
54
+ resolve();
55
+ }
56
+ function errored(): void {
57
+ client.removeEventListener('close', closed);
58
+ client.removeEventListener('error', errored);
59
+ reject(new Error(`Unable to connect to: ${client.url}`));
60
+ }
61
+ client.addEventListener('close', closed);
62
+ client.addEventListener('error', errored);
63
+ client.close();
64
+ });
65
+ }
66
+
67
+ /**
68
+ * The combination of `getClient()` and `connect()`.
69
+ */
70
+ async createAndConnect(addr: string, token?: string): Promise<WebSocket> {
71
+ const client = this.getClient(addr, token);
72
+ await this.connect(client);
73
+ return client;
74
+ }
75
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArcResponse.js","sourceRoot":"","sources":["../../../src/models/ArcResponse.ts"],"names":[],"mappings":"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"}