loop-client 0.0.1

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 (351) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +3 -0
  3. package/build/const.d.ts +31 -0
  4. package/build/const.d.ts.map +1 -0
  5. package/build/const.js +40 -0
  6. package/build/const.js.map +1 -0
  7. package/build/errors.d.ts +621 -0
  8. package/build/errors.d.ts.map +1 -0
  9. package/build/errors.js +665 -0
  10. package/build/errors.js.map +1 -0
  11. package/build/index.d.ts +6 -0
  12. package/build/index.d.ts.map +1 -0
  13. package/build/index.js +27 -0
  14. package/build/index.js.map +1 -0
  15. package/build/instrument.d.ts +14 -0
  16. package/build/instrument.d.ts.map +1 -0
  17. package/build/instrument.js +75 -0
  18. package/build/instrument.js.map +1 -0
  19. package/build/logger.d.ts +6 -0
  20. package/build/logger.d.ts.map +1 -0
  21. package/build/logger.js +24 -0
  22. package/build/logger.js.map +1 -0
  23. package/build/methods.d.ts +1101 -0
  24. package/build/methods.d.ts.map +1 -0
  25. package/build/methods.js +2080 -0
  26. package/build/methods.js.map +1 -0
  27. package/build/types/admin.d.ts +56 -0
  28. package/build/types/admin.d.ts.map +1 -0
  29. package/build/types/admin.js +18 -0
  30. package/build/types/admin.js.map +1 -0
  31. package/build/types/apps.d.ts +214 -0
  32. package/build/types/apps.d.ts.map +1 -0
  33. package/build/types/apps.js +81 -0
  34. package/build/types/apps.js.map +1 -0
  35. package/build/types/audits.d.ts +10 -0
  36. package/build/types/audits.d.ts.map +1 -0
  37. package/build/types/audits.js +3 -0
  38. package/build/types/audits.js.map +1 -0
  39. package/build/types/autocomplete.d.ts +13 -0
  40. package/build/types/autocomplete.d.ts.map +1 -0
  41. package/build/types/autocomplete.js +3 -0
  42. package/build/types/autocomplete.js.map +1 -0
  43. package/build/types/boards.d.ts +57 -0
  44. package/build/types/boards.d.ts.map +1 -0
  45. package/build/types/boards.js +28 -0
  46. package/build/types/boards.js.map +1 -0
  47. package/build/types/bots.d.ts +16 -0
  48. package/build/types/bots.d.ts.map +1 -0
  49. package/build/types/bots.js +3 -0
  50. package/build/types/bots.js.map +1 -0
  51. package/build/types/channels.d.ts +279 -0
  52. package/build/types/channels.d.ts.map +1 -0
  53. package/build/types/channels.js +62 -0
  54. package/build/types/channels.js.map +1 -0
  55. package/build/types/cloud.d.ts +155 -0
  56. package/build/types/cloud.d.ts.map +1 -0
  57. package/build/types/cloud.js +12 -0
  58. package/build/types/cloud.js.map +1 -0
  59. package/build/types/common.d.ts +5 -0
  60. package/build/types/common.d.ts.map +1 -0
  61. package/build/types/common.js +3 -0
  62. package/build/types/common.js.map +1 -0
  63. package/build/types/compliance.d.ts +14 -0
  64. package/build/types/compliance.d.ts.map +1 -0
  65. package/build/types/compliance.js +3 -0
  66. package/build/types/compliance.js.map +1 -0
  67. package/build/types/config.d.ts +966 -0
  68. package/build/types/config.d.ts.map +1 -0
  69. package/build/types/config.js +17 -0
  70. package/build/types/config.js.map +1 -0
  71. package/build/types/data-retention.d.ts +31 -0
  72. package/build/types/data-retention.d.ts.map +1 -0
  73. package/build/types/data-retention.js +3 -0
  74. package/build/types/data-retention.js.map +1 -0
  75. package/build/types/dialog.d.ts +63 -0
  76. package/build/types/dialog.d.ts.map +1 -0
  77. package/build/types/dialog.js +26 -0
  78. package/build/types/dialog.js.map +1 -0
  79. package/build/types/drafts.d.ts +15 -0
  80. package/build/types/drafts.d.ts.map +1 -0
  81. package/build/types/drafts.js +3 -0
  82. package/build/types/drafts.js.map +1 -0
  83. package/build/types/emojis.d.ts +52 -0
  84. package/build/types/emojis.d.ts.map +1 -0
  85. package/build/types/emojis.js +19 -0
  86. package/build/types/emojis.js.map +1 -0
  87. package/build/types/files.d.ts +53 -0
  88. package/build/types/files.d.ts.map +1 -0
  89. package/build/types/files.js +3 -0
  90. package/build/types/files.js.map +1 -0
  91. package/build/types/groups.d.ts +143 -0
  92. package/build/types/groups.d.ts.map +1 -0
  93. package/build/types/groups.js +14 -0
  94. package/build/types/groups.js.map +1 -0
  95. package/build/types/index.d.ts +46 -0
  96. package/build/types/index.d.ts.map +1 -0
  97. package/build/types/index.js +62 -0
  98. package/build/types/index.js.map +1 -0
  99. package/build/types/integrations.d.ts +108 -0
  100. package/build/types/integrations.d.ts.map +1 -0
  101. package/build/types/integrations.js +15 -0
  102. package/build/types/integrations.js.map +1 -0
  103. package/build/types/jobs.d.ts +28 -0
  104. package/build/types/jobs.d.ts.map +1 -0
  105. package/build/types/jobs.js +22 -0
  106. package/build/types/jobs.js.map +1 -0
  107. package/build/types/limits.d.ts +5 -0
  108. package/build/types/limits.d.ts.map +1 -0
  109. package/build/types/limits.js +3 -0
  110. package/build/types/limits.js.map +1 -0
  111. package/build/types/marketplace.d.ts +43 -0
  112. package/build/types/marketplace.d.ts.map +1 -0
  113. package/build/types/marketplace.js +21 -0
  114. package/build/types/marketplace.js.map +1 -0
  115. package/build/types/metadata.d.ts +16 -0
  116. package/build/types/metadata.d.ts.map +1 -0
  117. package/build/types/metadata.js +3 -0
  118. package/build/types/metadata.js.map +1 -0
  119. package/build/types/methods/bots.methods.d.ts +77 -0
  120. package/build/types/methods/bots.methods.d.ts.map +1 -0
  121. package/build/types/methods/bots.methods.js +3 -0
  122. package/build/types/methods/bots.methods.js.map +1 -0
  123. package/build/types/methods/brand.methods.d.ts +15 -0
  124. package/build/types/methods/brand.methods.d.ts.map +1 -0
  125. package/build/types/methods/brand.methods.js +3 -0
  126. package/build/types/methods/brand.methods.js.map +1 -0
  127. package/build/types/methods/channels.methods.d.ts +473 -0
  128. package/build/types/methods/channels.methods.d.ts.map +1 -0
  129. package/build/types/methods/channels.methods.js +3 -0
  130. package/build/types/methods/channels.methods.js.map +1 -0
  131. package/build/types/methods/cloud.methods.d.ts +14 -0
  132. package/build/types/methods/cloud.methods.d.ts.map +1 -0
  133. package/build/types/methods/cloud.methods.js +3 -0
  134. package/build/types/methods/cloud.methods.js.map +1 -0
  135. package/build/types/methods/common.methods.d.ts +87 -0
  136. package/build/types/methods/common.methods.d.ts.map +1 -0
  137. package/build/types/methods/common.methods.js +4 -0
  138. package/build/types/methods/common.methods.js.map +1 -0
  139. package/build/types/methods/compliance.methods.d.ts +32 -0
  140. package/build/types/methods/compliance.methods.d.ts.map +1 -0
  141. package/build/types/methods/compliance.methods.js +3 -0
  142. package/build/types/methods/compliance.methods.js.map +1 -0
  143. package/build/types/methods/data-retention.methods.d.ts +67 -0
  144. package/build/types/methods/data-retention.methods.d.ts.map +1 -0
  145. package/build/types/methods/data-retention.methods.js +3 -0
  146. package/build/types/methods/data-retention.methods.js.map +1 -0
  147. package/build/types/methods/emojis.methods.d.ts +32 -0
  148. package/build/types/methods/emojis.methods.d.ts.map +1 -0
  149. package/build/types/methods/emojis.methods.js +3 -0
  150. package/build/types/methods/emojis.methods.js.map +1 -0
  151. package/build/types/methods/files.methods.d.ts +139 -0
  152. package/build/types/methods/files.methods.d.ts.map +1 -0
  153. package/build/types/methods/files.methods.js +3 -0
  154. package/build/types/methods/files.methods.js.map +1 -0
  155. package/build/types/methods/groups.methods.d.ts +113 -0
  156. package/build/types/methods/groups.methods.d.ts.map +1 -0
  157. package/build/types/methods/groups.methods.js +3 -0
  158. package/build/types/methods/groups.methods.js.map +1 -0
  159. package/build/types/methods/index.d.ts +28 -0
  160. package/build/types/methods/index.d.ts.map +1 -0
  161. package/build/types/methods/index.js +44 -0
  162. package/build/types/methods/index.js.map +1 -0
  163. package/build/types/methods/integrations.methods.d.ts +191 -0
  164. package/build/types/methods/integrations.methods.d.ts.map +1 -0
  165. package/build/types/methods/integrations.methods.js +3 -0
  166. package/build/types/methods/integrations.methods.js.map +1 -0
  167. package/build/types/methods/interactive.methods.d.ts +38 -0
  168. package/build/types/methods/interactive.methods.d.ts.map +1 -0
  169. package/build/types/methods/interactive.methods.js +3 -0
  170. package/build/types/methods/interactive.methods.js.map +1 -0
  171. package/build/types/methods/jobs.methods.d.ts +20 -0
  172. package/build/types/methods/jobs.methods.d.ts.map +1 -0
  173. package/build/types/methods/jobs.methods.js +3 -0
  174. package/build/types/methods/jobs.methods.js.map +1 -0
  175. package/build/types/methods/playbook-runs.methods.d.ts +89 -0
  176. package/build/types/methods/playbook-runs.methods.d.ts.map +1 -0
  177. package/build/types/methods/playbook-runs.methods.js +3 -0
  178. package/build/types/methods/playbook-runs.methods.js.map +1 -0
  179. package/build/types/methods/playbooks.methods.d.ts +156 -0
  180. package/build/types/methods/playbooks.methods.d.ts.map +1 -0
  181. package/build/types/methods/playbooks.methods.js +3 -0
  182. package/build/types/methods/playbooks.methods.js.map +1 -0
  183. package/build/types/methods/plugins.methods.d.ts +31 -0
  184. package/build/types/methods/plugins.methods.d.ts.map +1 -0
  185. package/build/types/methods/plugins.methods.js +3 -0
  186. package/build/types/methods/plugins.methods.js.map +1 -0
  187. package/build/types/methods/posts.methods.d.ts +216 -0
  188. package/build/types/methods/posts.methods.d.ts.map +1 -0
  189. package/build/types/methods/posts.methods.js +3 -0
  190. package/build/types/methods/posts.methods.js.map +1 -0
  191. package/build/types/methods/preferences.methods.d.ts +12 -0
  192. package/build/types/methods/preferences.methods.d.ts.map +1 -0
  193. package/build/types/methods/preferences.methods.js +3 -0
  194. package/build/types/methods/preferences.methods.js.map +1 -0
  195. package/build/types/methods/reactions.methods.d.ts +15 -0
  196. package/build/types/methods/reactions.methods.d.ts.map +1 -0
  197. package/build/types/methods/reactions.methods.js +3 -0
  198. package/build/types/methods/reactions.methods.js.map +1 -0
  199. package/build/types/methods/reports.methods.d.ts +4 -0
  200. package/build/types/methods/reports.methods.d.ts.map +1 -0
  201. package/build/types/methods/reports.methods.js +3 -0
  202. package/build/types/methods/reports.methods.js.map +1 -0
  203. package/build/types/methods/roles.methods.d.ts +14 -0
  204. package/build/types/methods/roles.methods.d.ts.map +1 -0
  205. package/build/types/methods/roles.methods.js +3 -0
  206. package/build/types/methods/roles.methods.js.map +1 -0
  207. package/build/types/methods/schemes.methods.d.ts +30 -0
  208. package/build/types/methods/schemes.methods.d.ts.map +1 -0
  209. package/build/types/methods/schemes.methods.js +3 -0
  210. package/build/types/methods/schemes.methods.js.map +1 -0
  211. package/build/types/methods/system.methods.d.ts +107 -0
  212. package/build/types/methods/system.methods.d.ts.map +1 -0
  213. package/build/types/methods/system.methods.js +3 -0
  214. package/build/types/methods/system.methods.js.map +1 -0
  215. package/build/types/methods/teams.methods.d.ts +161 -0
  216. package/build/types/methods/teams.methods.d.ts.map +1 -0
  217. package/build/types/methods/teams.methods.js +3 -0
  218. package/build/types/methods/teams.methods.js.map +1 -0
  219. package/build/types/methods/terms-of-service.methods.d.ts +24 -0
  220. package/build/types/methods/terms-of-service.methods.d.ts.map +1 -0
  221. package/build/types/methods/terms-of-service.methods.js +3 -0
  222. package/build/types/methods/terms-of-service.methods.js.map +1 -0
  223. package/build/types/methods/uploads.methods.d.ts +13 -0
  224. package/build/types/methods/uploads.methods.d.ts.map +1 -0
  225. package/build/types/methods/uploads.methods.js +3 -0
  226. package/build/types/methods/uploads.methods.js.map +1 -0
  227. package/build/types/methods/users.methods.d.ts +257 -0
  228. package/build/types/methods/users.methods.d.ts.map +1 -0
  229. package/build/types/methods/users.methods.js +3 -0
  230. package/build/types/methods/users.methods.js.map +1 -0
  231. package/build/types/mfa.d.ts +5 -0
  232. package/build/types/mfa.d.ts.map +1 -0
  233. package/build/types/mfa.js +3 -0
  234. package/build/types/mfa.js.map +1 -0
  235. package/build/types/playbooks.d.ts +221 -0
  236. package/build/types/playbooks.d.ts.map +1 -0
  237. package/build/types/playbooks.js +3 -0
  238. package/build/types/playbooks.js.map +1 -0
  239. package/build/types/plugins.d.ts +101 -0
  240. package/build/types/plugins.d.ts.map +1 -0
  241. package/build/types/plugins.js +3 -0
  242. package/build/types/plugins.js.map +1 -0
  243. package/build/types/posts.d.ts +290 -0
  244. package/build/types/posts.d.ts.map +1 -0
  245. package/build/types/posts.js +88 -0
  246. package/build/types/posts.js.map +1 -0
  247. package/build/types/preferences.d.ts +7 -0
  248. package/build/types/preferences.d.ts.map +1 -0
  249. package/build/types/preferences.js +3 -0
  250. package/build/types/preferences.js.map +1 -0
  251. package/build/types/product-notices.d.ts +27 -0
  252. package/build/types/product-notices.d.ts.map +1 -0
  253. package/build/types/product-notices.js +8 -0
  254. package/build/types/product-notices.js.map +1 -0
  255. package/build/types/products.d.ts +8 -0
  256. package/build/types/products.d.ts.map +1 -0
  257. package/build/types/products.js +3 -0
  258. package/build/types/products.js.map +1 -0
  259. package/build/types/reactions.d.ts +7 -0
  260. package/build/types/reactions.d.ts.map +1 -0
  261. package/build/types/reactions.js +3 -0
  262. package/build/types/reactions.js.map +1 -0
  263. package/build/types/reports.d.ts +66 -0
  264. package/build/types/reports.d.ts.map +1 -0
  265. package/build/types/reports.js +30 -0
  266. package/build/types/reports.js.map +1 -0
  267. package/build/types/requests.d.ts +61 -0
  268. package/build/types/requests.d.ts.map +1 -0
  269. package/build/types/requests.js +12 -0
  270. package/build/types/requests.js.map +1 -0
  271. package/build/types/responses/common.responses.d.ts +23 -0
  272. package/build/types/responses/common.responses.d.ts.map +1 -0
  273. package/build/types/responses/common.responses.js +3 -0
  274. package/build/types/responses/common.responses.js.map +1 -0
  275. package/build/types/responses/index.d.ts +5 -0
  276. package/build/types/responses/index.d.ts.map +1 -0
  277. package/build/types/responses/index.js +21 -0
  278. package/build/types/responses/index.js.map +1 -0
  279. package/build/types/responses/playbooks.responses.d.ts +19 -0
  280. package/build/types/responses/playbooks.responses.d.ts.map +1 -0
  281. package/build/types/responses/playbooks.responses.js +3 -0
  282. package/build/types/responses/playbooks.responses.js.map +1 -0
  283. package/build/types/responses/posts.responses.d.ts +32 -0
  284. package/build/types/responses/posts.responses.d.ts.map +1 -0
  285. package/build/types/responses/posts.responses.js +8 -0
  286. package/build/types/responses/posts.responses.js.map +1 -0
  287. package/build/types/responses/system.responses.d.ts +87 -0
  288. package/build/types/responses/system.responses.d.ts.map +1 -0
  289. package/build/types/responses/system.responses.js +3 -0
  290. package/build/types/responses/system.responses.js.map +1 -0
  291. package/build/types/roles.d.ts +41 -0
  292. package/build/types/roles.d.ts.map +1 -0
  293. package/build/types/roles.js +33 -0
  294. package/build/types/roles.js.map +1 -0
  295. package/build/types/saml.d.ts +11 -0
  296. package/build/types/saml.d.ts.map +1 -0
  297. package/build/types/saml.js +3 -0
  298. package/build/types/saml.js.map +1 -0
  299. package/build/types/schemes.d.ts +28 -0
  300. package/build/types/schemes.d.ts.map +1 -0
  301. package/build/types/schemes.js +9 -0
  302. package/build/types/schemes.js.map +1 -0
  303. package/build/types/search.d.ts +13 -0
  304. package/build/types/search.d.ts.map +1 -0
  305. package/build/types/search.js +3 -0
  306. package/build/types/search.js.map +1 -0
  307. package/build/types/setup.d.ts +5 -0
  308. package/build/types/setup.d.ts.map +1 -0
  309. package/build/types/setup.js +3 -0
  310. package/build/types/setup.js.map +1 -0
  311. package/build/types/state.d.ts +464 -0
  312. package/build/types/state.d.ts.map +1 -0
  313. package/build/types/state.js +3 -0
  314. package/build/types/state.js.map +1 -0
  315. package/build/types/store.d.ts +65 -0
  316. package/build/types/store.d.ts.map +1 -0
  317. package/build/types/store.js +3 -0
  318. package/build/types/store.js.map +1 -0
  319. package/build/types/teams.d.ts +94 -0
  320. package/build/types/teams.d.ts.map +1 -0
  321. package/build/types/teams.js +9 -0
  322. package/build/types/teams.js.map +1 -0
  323. package/build/types/terms-of-service.d.ts +7 -0
  324. package/build/types/terms-of-service.d.ts.map +1 -0
  325. package/build/types/terms-of-service.js +3 -0
  326. package/build/types/terms-of-service.js.map +1 -0
  327. package/build/types/threads.d.ts +40 -0
  328. package/build/types/threads.d.ts.map +1 -0
  329. package/build/types/threads.js +8 -0
  330. package/build/types/threads.js.map +1 -0
  331. package/build/types/typing.d.ts +6 -0
  332. package/build/types/typing.d.ts.map +1 -0
  333. package/build/types/typing.js +3 -0
  334. package/build/types/typing.js.map +1 -0
  335. package/build/types/users.d.ts +281 -0
  336. package/build/types/users.d.ts.map +1 -0
  337. package/build/types/users.js +42 -0
  338. package/build/types/users.js.map +1 -0
  339. package/build/types/web-client.d.ts +82 -0
  340. package/build/types/web-client.d.ts.map +1 -0
  341. package/build/types/web-client.js +17 -0
  342. package/build/types/web-client.js.map +1 -0
  343. package/build/utils.d.ts +24 -0
  344. package/build/utils.d.ts.map +1 -0
  345. package/build/utils.js +136 -0
  346. package/build/utils.js.map +1 -0
  347. package/build/web-client.d.ts +117 -0
  348. package/build/web-client.d.ts.map +1 -0
  349. package/build/web-client.js +421 -0
  350. package/build/web-client.js.map +1 -0
  351. package/package.json +74 -0
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebClient = void 0;
7
+ const logger_1 = require("@triple-sun/logger");
8
+ const again_ts_1 = require("again-ts");
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const breadline_ts_1 = require("breadline-ts");
11
+ const const_1 = require("./const");
12
+ const errors_1 = require("./errors");
13
+ const instrument_1 = require("./instrument");
14
+ const logger_2 = require("./logger");
15
+ const methods_1 = require("./methods");
16
+ const web_client_1 = require("./types/web-client");
17
+ const utils_1 = require("./utils");
18
+ class WebClient extends methods_1.Methods {
19
+ /**
20
+ * @description The base URL for reaching Loop/Mattermost Web API
21
+ * Must end with `api/v4/`
22
+ * @example https://your-loop.loop.ru/api/v4/
23
+ */
24
+ url;
25
+ /**
26
+ * @descripton Authentication and authorization token for accessing Loop/Mattermost API
27
+ */
28
+ token;
29
+ /**
30
+ * Configuration for retry operations. See {@link https://github.com/triplesunn/again-ts|Again} for more details.
31
+ */
32
+ retryConfig;
33
+ /**
34
+ * Queue of requests in which a maximum of {@link WebClientOptions.maxRequestConcurrency} can concurrently be
35
+ * in-flight.
36
+ */
37
+ breadline;
38
+ /**
39
+ * Axios HTTP client instance used by this client
40
+ */
41
+ axios;
42
+ /**
43
+ * Configuration for custom TLS handling
44
+ */
45
+ tlsConfig;
46
+ /**
47
+ * The name used to prefix all logging generated from this object
48
+ */
49
+ static loggerName = "LoopWebClient";
50
+ /**
51
+ * This object's logger instance
52
+ */
53
+ logger;
54
+ /**
55
+ * @description Current userID
56
+ * useCurrentUserForDirectChannels and useCurrentUserForPostCreation will
57
+ * use it instead of fetching from server if not overriden by token
58
+ */
59
+ userID;
60
+ /**
61
+ * @description Use current user_id if only one was provided for direct channel creation.
62
+ * Will fetch current user ID from server if no userID was provided or overridden by token in options
63
+ *
64
+ * @default true
65
+ */
66
+ useCurrentUserForDirectChannels;
67
+ /**
68
+ * @description Use post.user_id in PostCreateArguments to fetch a channel_id for post
69
+ * Will call channels.create.direct for current user if true
70
+ * Will fetch current user ID from server if no userID was provided or overridden by token in options
71
+ *
72
+ * @default true
73
+ * @default false if userID is provided
74
+ */
75
+ useCurrentUserForPostCreation;
76
+ /**
77
+ * @description If true the client will set its userID if it was fetched while
78
+ * useCurrentUserForDirectChannels=true, useCurrentUserForPostCreation=true
79
+ * or via users.profile.get.me()
80
+ *
81
+ * @default false
82
+ */
83
+ saveFetchedUserID;
84
+ clusterId;
85
+ serverVersion;
86
+ constructor(url, { token = undefined, userID = undefined, logger = undefined, logLevel = undefined, maxRequestConcurrency = 100, retryConfig = const_1.tenRetriesInAboutThirtyMinutes, useCurrentUserForDirectChannels = true, useCurrentUserForPostCreation = true, saveFetchedUserID = false, testConnectionOnInit = false, agent = undefined, tls = undefined, timeout = 0, headers = {}, requestInterceptor = undefined, adapter = undefined } = {}) {
87
+ super();
88
+ this.token = token;
89
+ this.url = url;
90
+ if (!this.url.endsWith("/"))
91
+ this.url += "/";
92
+ if (!this.url.endsWith(`api/v4/`))
93
+ this.url += `api/v4/`;
94
+ this.userID = userID;
95
+ this.clusterId = "";
96
+ this.serverVersion = "";
97
+ this.retryConfig = retryConfig;
98
+ this.breadline = new breadline_ts_1.Breadline({ concurrency: maxRequestConcurrency });
99
+ // NOTE: may want to filter the keys to only those acceptable for TLS options
100
+ this.tlsConfig = tls;
101
+ this.useCurrentUserForDirectChannels = useCurrentUserForDirectChannels;
102
+ this.useCurrentUserForPostCreation = useCurrentUserForPostCreation;
103
+ this.saveFetchedUserID = saveFetchedUserID;
104
+ /** Set up logging */
105
+ if (logger !== undefined) {
106
+ this.logger = logger;
107
+ if (logLevel !== undefined) {
108
+ this.logger.debug("The logLevel given to WebClient was ignored as you also gave logger");
109
+ }
110
+ }
111
+ else {
112
+ this.logger = (0, logger_2.getLogger)(WebClient.loggerName, logLevel ?? logger_1.LogLevel.INFO, logger);
113
+ }
114
+ if (this.token && !headers.Authorization) {
115
+ headers.Authorization = `Bearer ${this.token}`;
116
+ }
117
+ this.axios = axios_1.default.create({
118
+ timeout,
119
+ baseURL: this.url,
120
+ httpAgent: agent,
121
+ httpsAgent: agent,
122
+ headers: { ...headers, "User-Agent": (0, instrument_1.getUserAgent)() },
123
+ validateStatus: () => true, // all HTTP status codes should result in a resolved promise (as opposed to only 2xx)
124
+ maxRedirects: 0,
125
+ // disabling axios' automatic proxy support:
126
+ // axios would read from envvars to configure a proxy automatically, but it doesn't support TLS destinations.
127
+ // for compatibility and for a larger set of possible proxies (SOCKS or other
128
+ // protocols), users of this package should use the `agent` option to configure a proxy.
129
+ proxy: false
130
+ });
131
+ /** config.type and serializeApiCallData will set ContentType automatically */
132
+ this.axios.defaults.headers.post["Content-Type"] = null;
133
+ if (requestInterceptor) {
134
+ /**
135
+ * request interceptors have reversed execution order
136
+ * see: {@link https://github.com/axios/axios/blob/v1.x/test/specs/interceptors.spec.js#L88}
137
+ */
138
+ this.axios.interceptors.request.use(requestInterceptor, null);
139
+ }
140
+ if (adapter) {
141
+ this.axios.defaults.adapter = (config) => adapter({ ...config });
142
+ }
143
+ /**
144
+ * Built-int interceptors
145
+ */
146
+ /** set current user for direct channels interceptor */
147
+ if (this.useCurrentUserForDirectChannels) {
148
+ this.axios.interceptors.request.use(this.setCurrentUserForDirectChannel.bind(this));
149
+ }
150
+ /** set current user for posts interceptor */
151
+ if (this.useCurrentUserForPostCreation) {
152
+ this.axios.interceptors.request.use(this.setCurrentUserForPostCreation.bind(this));
153
+ }
154
+ /** path specific transformations */
155
+ this.axios.interceptors.request.use(this.transformPathSpecificParams.bind(this));
156
+ /** main data serializer interceptor */
157
+ this.axios.interceptors.request.use(this.serializeApiCallData.bind(this));
158
+ /** test connection if needed */
159
+ if (testConnectionOnInit)
160
+ this.system.checkHealth();
161
+ this.logger.debug("initialized");
162
+ }
163
+ /**
164
+ * Generic method for calling a Web API method
165
+ * @param path - the Web API path to call
166
+ * @param options - method options
167
+ *
168
+ * @throws WebApiCallFailedError with detailed errors in ctx.errors
169
+ */
170
+ async apiCall(config, options = {}) {
171
+ this.logger.debug(`APICall [${config.method} ${config.path}] start`);
172
+ if (typeof options === "string" ||
173
+ typeof options === "number" ||
174
+ typeof options === "boolean") {
175
+ throw new TypeError(`Expected options; instead got ${typeof options}`);
176
+ }
177
+ /** gotta set headers! */
178
+ const headers = {
179
+ "Content-Type": config.type
180
+ };
181
+ /** and handle TokenOverridable */
182
+ if (typeof options["token"] === "string") {
183
+ headers["Authorization"] = `Bearer ${options[""]}`;
184
+ options["token"] = undefined;
185
+ this.logger.debug(`token has been overridden`);
186
+ }
187
+ /** and warn if no fallback in attachments */
188
+ (0, utils_1.warnIfFallbackIsMissing)(config.path, this.logger, options);
189
+ /** and fill url from options */
190
+ const url = this.fillRequestUrl(config, options);
191
+ const response = await this.makeRequest(url, {
192
+ headers,
193
+ method: config.method,
194
+ data: options
195
+ });
196
+ const result = this.buildResult(url, response);
197
+ this.logger.debug(`APICall result: ${JSON.stringify(result, null, 2)}`);
198
+ this.logger.debug(`APICall [${config.method} ${config.path}] end`);
199
+ return result;
200
+ }
201
+ /**
202
+ * @description Low-level function to make a single API request.
203
+ * Handles queueing, retries, and http-level errors
204
+ */
205
+ async makeRequest(url, config) {
206
+ const task = () =>
207
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <jesting>
208
+ this.breadline.add(async () => {
209
+ const cfg = {
210
+ ...config,
211
+ ...this.tlsConfig
212
+ };
213
+ if (this.logger.getLevel() === logger_1.LogLevel.DEBUG) {
214
+ this.logger.debug(`http request url: ${url}`);
215
+ this.logger.debug(`http request data: ${(0, utils_1.redact)(config.data)}`);
216
+ this.logger.debug(`http request headers: ${(0, utils_1.redact)({
217
+ ...this.axios.defaults.headers.common,
218
+ ...config.headers
219
+ })}`);
220
+ }
221
+ /** ApiCallData is serialized through interceptors */
222
+ const response = await this.axios(url, cfg);
223
+ this.logger.debug("http response received");
224
+ this.logger.debug(`http response status: ${response.status}`);
225
+ if (this.serverVersion !== response.headers[const_1.HEADER_X_VERSION_ID]) {
226
+ this.serverVersion = response.headers[const_1.HEADER_X_VERSION_ID];
227
+ }
228
+ if (this.clusterId !== response.headers[const_1.HEADER_X_CLUSTER_ID]) {
229
+ this.clusterId = response.headers[const_1.HEADER_X_CLUSTER_ID];
230
+ }
231
+ /** handle error status code */
232
+ if (response.status > 300) {
233
+ this.logger.debug(`http error: ${JSON.stringify(response.data, null, 2)}`);
234
+ const { data } = response;
235
+ if ((0, errors_1.isServerError)(data)) {
236
+ if (response.status === 429)
237
+ throw new errors_1.WebAPIRateLimitedError(data);
238
+ throw new errors_1.WebAPIServerError(data);
239
+ }
240
+ throw new errors_1.WebAPIRequestError(data);
241
+ }
242
+ return response;
243
+ });
244
+ return await (0, again_ts_1.retry)("safe", task, this.retryConfig);
245
+ }
246
+ /**
247
+ * Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevant
248
+ * HTTP headers into the object.
249
+ * @param response - an http response
250
+ */
251
+ buildResult(url, result) {
252
+ const ctx = { ...result.ctx, url };
253
+ /** short-circuit if we have an error */
254
+ if (!result.ok)
255
+ throw result.ctx.errors[result.ctx.errors.length - 1];
256
+ this.logger.debug(`response headers: ${JSON.stringify(result.value.headers, null, 2)}`);
257
+ /**
258
+ * handle string responses?
259
+ * @todo check if it's actually needed
260
+ */
261
+ if (typeof result.value.data === "string") {
262
+ try {
263
+ result.value.data = JSON.parse(result.value.data);
264
+ }
265
+ catch (err) {
266
+ // failed to parse the string value as JSON data
267
+ throw err instanceof Error
268
+ ? err
269
+ : new TypeError(`non-error type thrown: ${err}`);
270
+ }
271
+ }
272
+ return Object.freeze({ data: result.value.data, ctx });
273
+ }
274
+ fillRequestUrl(config, options) {
275
+ let requestUrl = `${config.path}`;
276
+ /** fills :something with { something: "something" } from options */
277
+ if (requestUrl.match(new RegExp(/\/:\D*/))) {
278
+ for (const [k, v] of Object.entries(options)) {
279
+ this.logger.debug(`Replacing :${k} with ${v} in ${requestUrl}`);
280
+ requestUrl = requestUrl.replace(new RegExp(`:${k}`, "g"), String(v));
281
+ }
282
+ }
283
+ /** if no user_id in options: get 'me' user_id by default */
284
+ if (requestUrl.includes("users/:user_id")) {
285
+ requestUrl = requestUrl.replace(":user_id", "me");
286
+ }
287
+ return `${this.axios.getUri()}${requestUrl}`;
288
+ }
289
+ /**
290
+ * @description Sets authenticated user id for channel creation
291
+ */
292
+ async setCurrentUserForDirectChannel(config) {
293
+ const { data } = config;
294
+ if (config.url?.endsWith("/api/v4/channels/direct")) {
295
+ const userIDs = data;
296
+ if (!Array.isArray(userIDs)) {
297
+ throw new errors_1.WebClientOptionsError(`Expected user_ids to be an array`);
298
+ }
299
+ if (userIDs.length === 0) {
300
+ throw new errors_1.WebClientOptionsError(`To create a direct channel you should use at least one user_id in a tuple`);
301
+ }
302
+ if (userIDs.length === 1) {
303
+ /** throw if not enough user_ids and can't fetch current from server */
304
+ if (!this.useCurrentUserForDirectChannels) {
305
+ throw new errors_1.WebClientOptionsError(`If useCurrentUserForDirectChannels is false you MUST use two user_ids in a tuple to create a direct channel`);
306
+ }
307
+ config.data = [userIDs[0], await this.getCurrentUserID(data)];
308
+ }
309
+ }
310
+ return config;
311
+ }
312
+ /**
313
+ * @description Sets channel_id for user_id for post creation
314
+ */
315
+ async setCurrentUserForPostCreation(config) {
316
+ if (config.url?.endsWith("/api/v4/posts") && config.method === "post") {
317
+ const { data } = config;
318
+ /** throw if we dont have required params and we can't fetch them */
319
+ if (!this.useCurrentUserForPostCreation && !data.channel_id) {
320
+ throw new errors_1.WebClientOptionsError("If useCurrentUserForPostCreation is false you MUST provide channel_id to send a post");
321
+ }
322
+ /** throw if we don't even have options required to fetch missing data */
323
+ if (!data.user_id && !data.channel_id) {
324
+ throw new errors_1.WebClientOptionsError("To create a post you need to provide either a channel_id or user_id");
325
+ }
326
+ if (typeof data.user_id === "string" && !data.channel_id) {
327
+ const opts = {
328
+ token: data["token"],
329
+ user_ids: [data.user_id, await this.getCurrentUserID(data)]
330
+ };
331
+ /** if token overridable or no userID - fetch channel_id from server */
332
+ const channel = await this.channels.create.direct(opts);
333
+ config.data.channel_id = channel.data.id;
334
+ }
335
+ }
336
+ return config;
337
+ }
338
+ /**
339
+ * Gets or fetches current user ID using
340
+ * @param data Axios config.data
341
+ * @returns
342
+ */
343
+ async getCurrentUserID(data) {
344
+ const opts = {};
345
+ if (typeof data["token"] === "string") {
346
+ opts.token = data["token"];
347
+ }
348
+ if (opts.token || !this.userID) {
349
+ /** if token overridable or no userID - fetch userID from server */
350
+ const me = await this.users.profile.get.me(opts);
351
+ /** save if needed */
352
+ if (this.saveFetchedUserID) {
353
+ this.userID = me.data.id;
354
+ }
355
+ return me.data.id;
356
+ }
357
+ else {
358
+ return this.userID;
359
+ }
360
+ }
361
+ transformPathSpecificParams(config) {
362
+ const { data } = config;
363
+ /** transform to array */
364
+ if (config.url?.endsWith("/api/v4/channels/direct")) {
365
+ const userIDs = data.user_ids;
366
+ if (!Array.isArray(userIDs)) {
367
+ throw new errors_1.WebClientOptionsError(`Expected data.user_ids to be an array`);
368
+ }
369
+ config.data = userIDs;
370
+ }
371
+ if (config.url?.endsWith("/channels/ids")) {
372
+ const channelIDs = data.channel_ids;
373
+ if (!Array.isArray(channelIDs)) {
374
+ throw new errors_1.WebClientOptionsError(`Expected data.channel_ids to be an array`);
375
+ }
376
+ config.data = channelIDs;
377
+ }
378
+ if (config.url?.endsWith("/api/v4/roles/names") &&
379
+ config.method?.toLowerCase() === "post") {
380
+ const roles = data.roles;
381
+ if (!Array.isArray(roles)) {
382
+ throw new errors_1.WebClientOptionsError(`Expected data.channel_ids to be an array`);
383
+ }
384
+ config.data = roles;
385
+ }
386
+ return config;
387
+ }
388
+ /**
389
+ * Transforms options (a simple key-value object) into an acceptable value for a body. This can be either
390
+ * a string, used when posting with a content-type of url-encoded. Or, it can be a readable stream, used
391
+ * when the options contain a binary (a stream or a buffer) and the upload should be done
392
+ * with content-type multipart/form-data.
393
+ * @param config - The Axios request configuration object
394
+ */
395
+ serializeApiCallData(config) {
396
+ const { data, headers } = config;
397
+ const hasBinaryData = (0, utils_1.checkForBinaryData)(data);
398
+ /** Handling multipart form-data */
399
+ if (hasBinaryData ||
400
+ config.headers["Content-Type"] === web_client_1.ContentType.FormData) {
401
+ this.logger.debug("Request arguments contain binary data");
402
+ return (0, utils_1.getFormDataConfig)(data, headers);
403
+ }
404
+ /** Use json for json oh wow ¯\_(ツ)_/¯ */
405
+ if (headers["Content-Type"] === web_client_1.ContentType.JSON) {
406
+ return { ...config, data };
407
+ }
408
+ /** Otherwise it's a query */
409
+ return {
410
+ ...config,
411
+ params: Object.entries(data).reduce((accumulator, [key, value]) => {
412
+ if (key !== undefined && value !== undefined) {
413
+ accumulator[key] = value;
414
+ }
415
+ return accumulator;
416
+ }, {})
417
+ };
418
+ }
419
+ }
420
+ exports.WebClient = WebClient;
421
+ //# sourceMappingURL=web-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-client.js","sourceRoot":"","sources":["../src/web-client.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA2D;AAC3D,uCAKkB;AAClB,kDAMe;AACf,+CAAyC;AACzC,mCAIiB;AACjB,qCAMkB;AAClB,6CAA4C;AAC5C,qCAAqC;AACrC,uCAAoC;AAMpC,mDAM4B;AAC5B,mCAKiB;AAEjB,MAAa,SAA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C5B,CAAC;QAED,6BAA6B;QAC7B,OAAO;YACN,GAAG,MAAM;YACT,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAClC,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC7B,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC9C,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBAC1B,CAAC;gBACD,OAAO,WAAW,CAAC;YACpB,CAAC,EACD,EAA6B,CAC7B;SACD,CAAC;IACH,CAAC;;AA7jBF,8BA8jBC"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "loop-client",
3
+ "version": "0.0.1",
4
+ "main": "build/index.js",
5
+ "description": "\"Loop/Mattermost TypeScript client\"",
6
+ "engines": {
7
+ "node": ">=20"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/triple-sun/loop-client.git"
12
+ },
13
+ "author": "triple-sun",
14
+ "license": "ISC",
15
+ "bugs": {
16
+ "url": "https://github.com/triple-sun/loop-client/issues"
17
+ },
18
+ "homepage": "https://github.com/triple-sun/loop-client#readme",
19
+ "files": [
20
+ "build/**/*",
21
+ "*.md"
22
+ ],
23
+ "dependencies": {
24
+ "@triple-sun/logger": "^0.0.1",
25
+ "again-ts": "^1.0.5",
26
+ "axios": "^1.13.3",
27
+ "breadline-ts": "^1.0.0",
28
+ "eventemitter3": "^5.0.4",
29
+ "form-data": "^4.0.5",
30
+ "is-stream": "^4.0.1",
31
+ "qs": "^6.14.1",
32
+ "ws": "^8.19.0"
33
+ },
34
+ "devDependencies": {
35
+ "@biomejs/biome": "2.3.10",
36
+ "@tsconfig/recommended": "^1",
37
+ "@types/jest": "^30.0.0",
38
+ "@types/nock": "^10.0.3",
39
+ "@types/node": "^25.0.10",
40
+ "@types/qs": "^6.14.0",
41
+ "@types/ws": "^8.5.11",
42
+ "dotenv": "^17.2.3",
43
+ "husky": "^9.1.7",
44
+ "jest": "^30.2.0",
45
+ "lint-staged": "^16.2.7",
46
+ "nock": "^15.0.0",
47
+ "rimraf": "^6.1.2",
48
+ "ts-jest": "^29.4.6",
49
+ "ts-node": "^10.9.2",
50
+ "ts-to-zod": "^5.1.0",
51
+ "tsd": "^0.33.0",
52
+ "typescript": "5.9.3",
53
+ "zod": "^4.3.6"
54
+ },
55
+ "lint-staged": {
56
+ "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
57
+ "biome check --files-ignore-unknown=true",
58
+ "biome check --write --no-errors-on-unmatched"
59
+ ],
60
+ "*": [
61
+ "biome check --no-errors-on-unmatched --files-ignore-unknown=true"
62
+ ],
63
+ "test/integration/real-api/schemas/*": []
64
+ },
65
+ "scripts": {
66
+ "test": "jest",
67
+ "build": "rimraf ./build && tsc -p tsconfig.json",
68
+ "format": "biome format ./ --write",
69
+ "gen:schemas:res": "./scripts/generate-response-schemas.sh",
70
+ "lint": "biome lint ./src",
71
+ "test:real:base": "jest --testPathIgnorePatterns=null",
72
+ "test:real:only": "jest --testPathIgnorePatterns=null --testMatch=\"**/test/integration/real-api/*.test.ts\""
73
+ }
74
+ }