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
package/build/utils.js ADDED
@@ -0,0 +1,136 @@
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.threadIsSynthetic = exports.areShippingDetailsValid = exports.warnIfFallbackIsMissing = exports.redact = exports.getFormDataConfig = exports.checkForBinaryData = exports.wait = void 0;
7
+ /** biome-ignore-all lint/complexity/useLiteralKeys: <ts4111> */
8
+ const node_path_1 = require("node:path");
9
+ const form_data_1 = __importDefault(require("form-data"));
10
+ const is_stream_1 = require("is-stream");
11
+ const const_1 = require("./const");
12
+ const types_1 = require("./types");
13
+ const wait = (ms) => {
14
+ return new Promise(resolve => setTimeout(resolve, ms));
15
+ };
16
+ exports.wait = wait;
17
+ /**
18
+ * Checks request data for binary data
19
+ */
20
+ const checkForBinaryData = (data) => {
21
+ if (!data || typeof data !== "object")
22
+ return false;
23
+ for (const value of Object.values(data)) {
24
+ if (Buffer.isBuffer(value) || (0, is_stream_1.isStream)(value))
25
+ return true;
26
+ }
27
+ return false;
28
+ };
29
+ exports.checkForBinaryData = checkForBinaryData;
30
+ const getFormDataConfig = (data, headers) => {
31
+ const config = {
32
+ headers
33
+ };
34
+ const form = new form_data_1.default();
35
+ for (const [key, value] of Object.entries(data)) {
36
+ if (Buffer.isBuffer(value) || (0, is_stream_1.isStream)(value)) {
37
+ const opts = {};
38
+ opts.filename = (() => {
39
+ // attempt to find filename from `value`. adapted from:
40
+ // https://github.com/form-data/form-data/blob/028c21e0f93c5fefa46a7bbf1ba753e4f627ab7a/lib/form_data.js#L227-L230
41
+ // formidable and the browser add a name property
42
+ // fs- and request- streams have path property
43
+ // biome-ignore lint/suspicious/noExplicitAny: form values can be anything
44
+ const streamOrBuffer = value;
45
+ if (typeof streamOrBuffer.name === "string") {
46
+ return (0, node_path_1.basename)(streamOrBuffer.name);
47
+ }
48
+ if (typeof streamOrBuffer.path === "string") {
49
+ return (0, node_path_1.basename)(streamOrBuffer.path);
50
+ }
51
+ return `${const_1.DEFAULT_FILE_NAME}_${Date.now().toString()}`;
52
+ })();
53
+ form.append(key, value, opts);
54
+ }
55
+ else if (key !== undefined && value !== undefined) {
56
+ form.append(key, value);
57
+ }
58
+ }
59
+ if (headers) {
60
+ // Copying FormData-generated headers into headers param
61
+ // not reassigning to headers param since it is passed by reference and behaves as an inout param
62
+ for (const [header, value] of Object.entries(form.getHeaders())) {
63
+ headers[header] = value;
64
+ }
65
+ }
66
+ config.data = form;
67
+ config.headers = headers;
68
+ return config;
69
+ };
70
+ exports.getFormDataConfig = getFormDataConfig;
71
+ /**
72
+ * Takes an object and redacts specific items
73
+ * @param data
74
+ * @returns
75
+ */
76
+ const redact = (data) => {
77
+ if (typeof data !== "object" || data === null) {
78
+ return "Data is not an object!";
79
+ }
80
+ const flattened = Object.entries(data).map(([key, value]) => {
81
+ // no value provided
82
+ if (value === undefined || value === null)
83
+ return [];
84
+ let serializedValue = value;
85
+ // redact possible tokens
86
+ if (key.match(/.*token.*/) !== null || key.match(/[Aa]uthorization/)) {
87
+ serializedValue = "[[REDACTED]]";
88
+ }
89
+ // when value is buffer or stream we can avoid logging it
90
+ if (Buffer.isBuffer(value) || (0, is_stream_1.isStream)(value)) {
91
+ serializedValue = "[[BINARY VALUE OMITTED]]";
92
+ }
93
+ else if (typeof value !== "string" &&
94
+ typeof value !== "number" &&
95
+ typeof value !== "boolean") {
96
+ serializedValue = JSON.stringify(value, null, 2);
97
+ }
98
+ return [key, serializedValue];
99
+ });
100
+ // return as object
101
+ return JSON.stringify(flattened.reduce((accumulator, [key, value]) => {
102
+ if (key !== undefined && value !== undefined) {
103
+ accumulator[key] = value;
104
+ }
105
+ return accumulator;
106
+ }, {}));
107
+ };
108
+ exports.redact = redact;
109
+ /**
110
+ * @param path api method being called
111
+ * @param logger instance of we clients logger
112
+ * @param options arguments for the Web API method
113
+ */
114
+ const warnIfFallbackIsMissing = (path, logger, options) => {
115
+ if (!options || Array.isArray(options))
116
+ return;
117
+ if (Array.isArray(options["attachments"]) &&
118
+ options["attachments"].length > 0 &&
119
+ options["attachments"].some(attachment => !attachment.fallback || attachment.fallback.trim() === "")) {
120
+ logger.warn(`The attachment-level \`fallback\` argument is missing in the request payload for a ${path} call - To avoid this warning, it is recommended to always provide a top-level \`text\` argument when posting a message. Alternatively, you can provide an attachment-level \`fallback\` argument, though this is now considered a legacy field (see https://docs.slack.dev/legacy/legacy-messaging/legacy-secondary-message-attachments for more details).`);
121
+ }
122
+ };
123
+ exports.warnIfFallbackIsMissing = warnIfFallbackIsMissing;
124
+ const areShippingDetailsValid = (address) => {
125
+ if (!address)
126
+ return false;
127
+ return Boolean(address.city &&
128
+ address.country &&
129
+ address.line1 &&
130
+ address.postal_code &&
131
+ address.state);
132
+ };
133
+ exports.areShippingDetailsValid = areShippingDetailsValid;
134
+ const threadIsSynthetic = (thread) => thread.type === types_1.UserThreadType.Synthetic;
135
+ exports.threadIsSynthetic = threadIsSynthetic;
136
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,yCAAqC;AAGrC,0DAAiC;AACjC,yCAAqC;AACrC,mCAA4C;AAC5C,mCAKiB;AAEV,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE;IAClC,OAAO,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,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO;IAE/C,IACC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACrC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC;QACjC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAC1B,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CACvE,EACA,CAAC;QACF,MAAM,CAAC,IAAI,CACV,sFAAsF,IAAI,6VAA6V,CACvb,CAAC;IACH,CAAC;AACF,CAAC,CAAC;AAlBW,QAAA,uBAAuB,2BAkBlC;AAEK,MAAM,uBAAuB,GAAG,CACtC,OAAgD,EACtC,EAAE;IACZ,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,OAAO,OAAO,CACb,OAAO,CAAC,IAAI;QACX,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,KAAK;QACb,OAAO,CAAC,WAAW;QACnB,OAAO,CAAC,KAAK,CACd,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,uBAAuB,2BAYlC;AAEK,MAAM,iBAAiB,GAAG,CAChC,MAAwC,EACR,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,SAAS,CAAC;AAFhE,QAAA,iBAAiB,qBAE+C"}
@@ -0,0 +1,117 @@
1
+ import { Methods } from "./methods";
2
+ import type { WebAPICallResult } from "./types";
3
+ import { type WebApiCallConfig, type WebClientOptions } from "./types/web-client";
4
+ export declare class WebClient extends Methods {
5
+ /**
6
+ * @description The base URL for reaching Loop/Mattermost Web API
7
+ * Must end with `api/v4/`
8
+ * @example https://your-loop.loop.ru/api/v4/
9
+ */
10
+ url: string;
11
+ /**
12
+ * @descripton Authentication and authorization token for accessing Loop/Mattermost API
13
+ */
14
+ token: string | undefined;
15
+ /**
16
+ * Configuration for retry operations. See {@link https://github.com/triplesunn/again-ts|Again} for more details.
17
+ */
18
+ private retryConfig;
19
+ /**
20
+ * Queue of requests in which a maximum of {@link WebClientOptions.maxRequestConcurrency} can concurrently be
21
+ * in-flight.
22
+ */
23
+ private breadline;
24
+ /**
25
+ * Axios HTTP client instance used by this client
26
+ */
27
+ private axios;
28
+ /**
29
+ * Configuration for custom TLS handling
30
+ */
31
+ private tlsConfig;
32
+ /**
33
+ * The name used to prefix all logging generated from this object
34
+ */
35
+ private static loggerName;
36
+ /**
37
+ * This object's logger instance
38
+ */
39
+ private logger;
40
+ /**
41
+ * @description Current userID
42
+ * useCurrentUserForDirectChannels and useCurrentUserForPostCreation will
43
+ * use it instead of fetching from server if not overriden by token
44
+ */
45
+ userID: string | undefined;
46
+ /**
47
+ * @description Use current user_id if only one was provided for direct channel creation.
48
+ * Will fetch current user ID from server if no userID was provided or overridden by token in options
49
+ *
50
+ * @default true
51
+ */
52
+ readonly useCurrentUserForDirectChannels?: boolean;
53
+ /**
54
+ * @description Use post.user_id in PostCreateArguments to fetch a channel_id for post
55
+ * Will call channels.create.direct for current user if true
56
+ * Will fetch current user ID from server if no userID was provided or overridden by token in options
57
+ *
58
+ * @default true
59
+ * @default false if userID is provided
60
+ */
61
+ readonly useCurrentUserForPostCreation?: boolean;
62
+ /**
63
+ * @description If true the client will set its userID if it was fetched while
64
+ * useCurrentUserForDirectChannels=true, useCurrentUserForPostCreation=true
65
+ * or via users.profile.get.me()
66
+ *
67
+ * @default false
68
+ */
69
+ readonly saveFetchedUserID?: boolean;
70
+ private clusterId;
71
+ private serverVersion;
72
+ constructor(url: Readonly<string>, { token, userID, logger, logLevel, maxRequestConcurrency, retryConfig, useCurrentUserForDirectChannels, useCurrentUserForPostCreation, saveFetchedUserID, testConnectionOnInit, agent, tls, timeout, headers, requestInterceptor, adapter }?: WebClientOptions);
73
+ /**
74
+ * Generic method for calling a Web API method
75
+ * @param path - the Web API path to call
76
+ * @param options - method options
77
+ *
78
+ * @throws WebApiCallFailedError with detailed errors in ctx.errors
79
+ */
80
+ apiCall<T = unknown>(config: WebApiCallConfig, options?: Record<string, unknown>): Promise<Readonly<WebAPICallResult<T>>>;
81
+ /**
82
+ * @description Low-level function to make a single API request.
83
+ * Handles queueing, retries, and http-level errors
84
+ */
85
+ private makeRequest;
86
+ /**
87
+ * Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevant
88
+ * HTTP headers into the object.
89
+ * @param response - an http response
90
+ */
91
+ private buildResult;
92
+ private fillRequestUrl;
93
+ /**
94
+ * @description Sets authenticated user id for channel creation
95
+ */
96
+ private setCurrentUserForDirectChannel;
97
+ /**
98
+ * @description Sets channel_id for user_id for post creation
99
+ */
100
+ private setCurrentUserForPostCreation;
101
+ /**
102
+ * Gets or fetches current user ID using
103
+ * @param data Axios config.data
104
+ * @returns
105
+ */
106
+ private getCurrentUserID;
107
+ private transformPathSpecificParams;
108
+ /**
109
+ * Transforms options (a simple key-value object) into an acceptable value for a body. This can be either
110
+ * a string, used when posting with a content-type of url-encoded. Or, it can be a readable stream, used
111
+ * when the options contain a binary (a stream or a buffer) and the upload should be done
112
+ * with content-type multipart/form-data.
113
+ * @param config - The Axios request configuration object
114
+ */
115
+ private serializeApiCallData;
116
+ }
117
+ //# sourceMappingURL=web-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-client.d.ts","sourceRoot":"","sources":["../src/web-client.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAIN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;AAQ5B,qBAAa,SAAU,SAAQ,OAAO;IACrC;;;;OAIG;IACI,GAAG,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACI,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACH,OAAO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