@2bad/bitrix 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/README.md +53 -45
  2. package/build/main/bitrix.d.ts +25 -16
  3. package/build/main/bitrix.integration.test.js +0 -1
  4. package/build/main/bitrix.js +40 -13
  5. package/build/main/bitrix.unit.test.js +24 -9
  6. package/build/main/client/client.unit.test.js +13 -10
  7. package/build/main/client/hooks/addAccessToken.d.ts +5 -2
  8. package/build/main/client/hooks/addAccessToken.js +3 -1
  9. package/build/main/client/hooks/addAccessToken.unit.test.js +13 -12
  10. package/build/main/client/index.d.ts +10 -1
  11. package/build/main/client/index.js +23 -11
  12. package/build/main/client/methods/batch.d.ts +24 -5
  13. package/build/main/client/methods/batch.js +49 -17
  14. package/build/main/client/methods/batch.unit.test.js +103 -45
  15. package/build/main/client/methods/call.d.ts +11 -4
  16. package/build/main/client/methods/call.js +16 -6
  17. package/build/main/client/methods/call.unit.test.js +36 -21
  18. package/build/main/client/methods/list.d.ts +15 -3
  19. package/build/main/client/methods/list.js +36 -14
  20. package/build/main/client/methods/list.unit.test.js +42 -27
  21. package/build/main/commands.d.ts +2 -2
  22. package/build/main/commands.js +0 -1
  23. package/build/main/methods.d.ts +27 -8
  24. package/build/main/methods.js +1 -1
  25. package/build/main/payloads.d.ts +8 -8
  26. package/build/main/payloads.js +0 -1
  27. package/build/main/services/common.d.ts +5 -4
  28. package/build/main/services/common.js +0 -1
  29. package/build/main/services/companies/entities.d.ts +7 -6
  30. package/build/main/services/companies/entities.js +0 -1
  31. package/build/main/services/companies/index.d.ts +7 -6
  32. package/build/main/services/companies/index.integration.test.js +2 -3
  33. package/build/main/services/companies/index.js +0 -1
  34. package/build/main/services/companies/index.unit.test.js +1 -2
  35. package/build/main/services/companies/methods.d.ts +4 -4
  36. package/build/main/services/companies/methods.js +0 -1
  37. package/build/main/services/contacts/entities.d.ts +4 -3
  38. package/build/main/services/contacts/entities.js +0 -1
  39. package/build/main/services/contacts/index.d.ts +7 -6
  40. package/build/main/services/contacts/index.integration.test.js +2 -3
  41. package/build/main/services/contacts/index.js +0 -1
  42. package/build/main/services/contacts/index.unit.test.js +1 -2
  43. package/build/main/services/contacts/methods.d.ts +4 -4
  44. package/build/main/services/contacts/methods.js +0 -1
  45. package/build/main/services/currencies/entities.d.ts +2 -2
  46. package/build/main/services/currencies/entities.js +0 -1
  47. package/build/main/services/deals/entities.d.ts +2 -2
  48. package/build/main/services/deals/entities.js +0 -1
  49. package/build/main/services/deals/index.d.ts +7 -6
  50. package/build/main/services/deals/index.integration.test.js +2 -3
  51. package/build/main/services/deals/index.js +0 -1
  52. package/build/main/services/deals/index.unit.test.js +1 -2
  53. package/build/main/services/deals/methods.d.ts +4 -4
  54. package/build/main/services/deals/methods.js +0 -1
  55. package/build/main/services/leads/entities.d.ts +2 -2
  56. package/build/main/services/leads/entities.js +0 -1
  57. package/build/main/services/leads/index.d.ts +7 -6
  58. package/build/main/services/leads/index.integration.test.js +2 -3
  59. package/build/main/services/leads/index.js +0 -1
  60. package/build/main/services/leads/index.unit.test.js +1 -2
  61. package/build/main/services/leads/methods.d.ts +4 -4
  62. package/build/main/services/leads/methods.js +0 -1
  63. package/build/main/services/statuses/entities.d.ts +5 -4
  64. package/build/main/services/statuses/entities.js +0 -1
  65. package/build/main/services/statuses/index.d.ts +7 -11
  66. package/build/main/services/statuses/index.integration.test.js +8 -4
  67. package/build/main/services/statuses/index.js +0 -1
  68. package/build/main/services/statuses/index.unit.test.js +1 -2
  69. package/build/main/services/statuses/methods.d.ts +6 -6
  70. package/build/main/services/statuses/methods.js +0 -1
  71. package/build/main/services/users/entities.d.ts +4 -3
  72. package/build/main/services/users/entities.js +0 -1
  73. package/build/main/services/users/index.d.ts +3 -3
  74. package/build/main/services/users/index.integration.test.js +2 -3
  75. package/build/main/services/users/index.js +0 -1
  76. package/build/main/services/users/index.unit.test.js +1 -2
  77. package/build/main/services/users/methods.d.ts +4 -4
  78. package/build/main/services/users/methods.js +0 -1
  79. package/build/main/utils/Diff.js +0 -1
  80. package/build/main/utils/ExtractValue.d.ts +6 -1
  81. package/build/main/utils/ExtractValue.js +0 -1
  82. package/build/main/utils/isArray.d.ts +1 -1
  83. package/build/main/utils/isArray.js +1 -1
  84. package/build/module/bitrix.d.ts +25 -16
  85. package/build/module/bitrix.integration.test.js +0 -1
  86. package/build/module/bitrix.js +19 -3
  87. package/build/module/bitrix.unit.test.js +0 -1
  88. package/build/module/client/client.unit.test.js +9 -6
  89. package/build/module/client/hooks/addAccessToken.d.ts +5 -2
  90. package/build/module/client/hooks/addAccessToken.js +3 -1
  91. package/build/module/client/hooks/addAccessToken.unit.test.js +9 -8
  92. package/build/module/client/index.d.ts +10 -1
  93. package/build/module/client/index.js +19 -7
  94. package/build/module/client/methods/batch.d.ts +24 -5
  95. package/build/module/client/methods/batch.js +28 -3
  96. package/build/module/client/methods/batch.unit.test.js +61 -19
  97. package/build/module/client/methods/call.d.ts +11 -4
  98. package/build/module/client/methods/call.js +10 -3
  99. package/build/module/client/methods/call.unit.test.js +1 -2
  100. package/build/module/client/methods/list.d.ts +15 -3
  101. package/build/module/client/methods/list.js +21 -5
  102. package/build/module/client/methods/list.unit.test.js +0 -1
  103. package/build/module/commands.d.ts +2 -2
  104. package/build/module/commands.js +1 -1
  105. package/build/module/methods.d.ts +27 -8
  106. package/build/module/methods.js +0 -1
  107. package/build/module/payloads.d.ts +8 -8
  108. package/build/module/payloads.js +1 -1
  109. package/build/module/services/common.d.ts +5 -4
  110. package/build/module/services/common.js +1 -1
  111. package/build/module/services/companies/entities.d.ts +7 -6
  112. package/build/module/services/companies/entities.js +1 -1
  113. package/build/module/services/companies/index.d.ts +7 -6
  114. package/build/module/services/companies/index.integration.test.js +1 -2
  115. package/build/module/services/companies/index.js +0 -1
  116. package/build/module/services/companies/index.unit.test.js +0 -1
  117. package/build/module/services/companies/methods.d.ts +4 -4
  118. package/build/module/services/companies/methods.js +0 -1
  119. package/build/module/services/contacts/entities.d.ts +4 -3
  120. package/build/module/services/contacts/entities.js +1 -1
  121. package/build/module/services/contacts/index.d.ts +7 -6
  122. package/build/module/services/contacts/index.integration.test.js +1 -2
  123. package/build/module/services/contacts/index.js +0 -1
  124. package/build/module/services/contacts/index.unit.test.js +0 -1
  125. package/build/module/services/contacts/methods.d.ts +4 -4
  126. package/build/module/services/contacts/methods.js +0 -1
  127. package/build/module/services/currencies/entities.d.ts +2 -2
  128. package/build/module/services/currencies/entities.js +1 -1
  129. package/build/module/services/deals/entities.d.ts +2 -2
  130. package/build/module/services/deals/entities.js +1 -1
  131. package/build/module/services/deals/index.d.ts +7 -6
  132. package/build/module/services/deals/index.integration.test.js +1 -2
  133. package/build/module/services/deals/index.js +0 -1
  134. package/build/module/services/deals/index.unit.test.js +0 -1
  135. package/build/module/services/deals/methods.d.ts +4 -4
  136. package/build/module/services/deals/methods.js +0 -1
  137. package/build/module/services/leads/entities.d.ts +2 -2
  138. package/build/module/services/leads/entities.js +1 -1
  139. package/build/module/services/leads/index.d.ts +7 -6
  140. package/build/module/services/leads/index.integration.test.js +1 -2
  141. package/build/module/services/leads/index.js +0 -1
  142. package/build/module/services/leads/index.unit.test.js +0 -1
  143. package/build/module/services/leads/methods.d.ts +4 -4
  144. package/build/module/services/leads/methods.js +0 -1
  145. package/build/module/services/statuses/entities.d.ts +5 -4
  146. package/build/module/services/statuses/entities.js +1 -1
  147. package/build/module/services/statuses/index.d.ts +7 -11
  148. package/build/module/services/statuses/index.integration.test.js +7 -3
  149. package/build/module/services/statuses/index.js +0 -1
  150. package/build/module/services/statuses/index.unit.test.js +0 -1
  151. package/build/module/services/statuses/methods.d.ts +6 -6
  152. package/build/module/services/statuses/methods.js +0 -1
  153. package/build/module/services/users/entities.d.ts +4 -3
  154. package/build/module/services/users/entities.js +1 -1
  155. package/build/module/services/users/index.d.ts +3 -3
  156. package/build/module/services/users/index.integration.test.js +1 -2
  157. package/build/module/services/users/index.js +0 -1
  158. package/build/module/services/users/index.unit.test.js +0 -1
  159. package/build/module/services/users/methods.d.ts +4 -4
  160. package/build/module/services/users/methods.js +0 -1
  161. package/build/module/utils/Diff.js +1 -1
  162. package/build/module/utils/ExtractValue.d.ts +6 -1
  163. package/build/module/utils/ExtractValue.js +1 -1
  164. package/build/module/utils/isArray.d.ts +1 -1
  165. package/build/module/utils/isArray.js +1 -1
  166. package/package.json +64 -60
  167. package/build/main/bitrix.integration.test.js.map +0 -1
  168. package/build/main/bitrix.js.map +0 -1
  169. package/build/main/bitrix.unit.test.js.map +0 -1
  170. package/build/main/client/client.unit.test.js.map +0 -1
  171. package/build/main/client/hooks/addAccessToken.js.map +0 -1
  172. package/build/main/client/hooks/addAccessToken.unit.test.js.map +0 -1
  173. package/build/main/client/index.js.map +0 -1
  174. package/build/main/client/methods/batch.js.map +0 -1
  175. package/build/main/client/methods/batch.unit.test.js.map +0 -1
  176. package/build/main/client/methods/call.js.map +0 -1
  177. package/build/main/client/methods/call.unit.test.js.map +0 -1
  178. package/build/main/client/methods/list.js.map +0 -1
  179. package/build/main/client/methods/list.unit.test.js.map +0 -1
  180. package/build/main/commands.js.map +0 -1
  181. package/build/main/methods.js.map +0 -1
  182. package/build/main/payloads.js.map +0 -1
  183. package/build/main/services/common.js.map +0 -1
  184. package/build/main/services/companies/entities.js.map +0 -1
  185. package/build/main/services/companies/index.integration.test.js.map +0 -1
  186. package/build/main/services/companies/index.js.map +0 -1
  187. package/build/main/services/companies/index.unit.test.js.map +0 -1
  188. package/build/main/services/companies/methods.js.map +0 -1
  189. package/build/main/services/contacts/entities.js.map +0 -1
  190. package/build/main/services/contacts/index.integration.test.js.map +0 -1
  191. package/build/main/services/contacts/index.js.map +0 -1
  192. package/build/main/services/contacts/index.unit.test.js.map +0 -1
  193. package/build/main/services/contacts/methods.js.map +0 -1
  194. package/build/main/services/currencies/entities.js.map +0 -1
  195. package/build/main/services/deals/entities.js.map +0 -1
  196. package/build/main/services/deals/index.integration.test.js.map +0 -1
  197. package/build/main/services/deals/index.js.map +0 -1
  198. package/build/main/services/deals/index.unit.test.js.map +0 -1
  199. package/build/main/services/deals/methods.js.map +0 -1
  200. package/build/main/services/leads/entities.js.map +0 -1
  201. package/build/main/services/leads/index.integration.test.js.map +0 -1
  202. package/build/main/services/leads/index.js.map +0 -1
  203. package/build/main/services/leads/index.unit.test.js.map +0 -1
  204. package/build/main/services/leads/methods.js.map +0 -1
  205. package/build/main/services/statuses/entities.js.map +0 -1
  206. package/build/main/services/statuses/index.integration.test.js.map +0 -1
  207. package/build/main/services/statuses/index.js.map +0 -1
  208. package/build/main/services/statuses/index.unit.test.js.map +0 -1
  209. package/build/main/services/statuses/methods.js.map +0 -1
  210. package/build/main/services/users/entities.js.map +0 -1
  211. package/build/main/services/users/index.integration.test.js.map +0 -1
  212. package/build/main/services/users/index.js.map +0 -1
  213. package/build/main/services/users/index.unit.test.js.map +0 -1
  214. package/build/main/services/users/methods.js.map +0 -1
  215. package/build/main/utils/Diff.js.map +0 -1
  216. package/build/main/utils/ExtractValue.js.map +0 -1
  217. package/build/main/utils/isArray.js.map +0 -1
  218. package/build/module/bitrix.integration.test.js.map +0 -1
  219. package/build/module/bitrix.js.map +0 -1
  220. package/build/module/bitrix.unit.test.js.map +0 -1
  221. package/build/module/client/client.unit.test.js.map +0 -1
  222. package/build/module/client/hooks/addAccessToken.js.map +0 -1
  223. package/build/module/client/hooks/addAccessToken.unit.test.js.map +0 -1
  224. package/build/module/client/index.js.map +0 -1
  225. package/build/module/client/methods/batch.js.map +0 -1
  226. package/build/module/client/methods/batch.unit.test.js.map +0 -1
  227. package/build/module/client/methods/call.js.map +0 -1
  228. package/build/module/client/methods/call.unit.test.js.map +0 -1
  229. package/build/module/client/methods/list.js.map +0 -1
  230. package/build/module/client/methods/list.unit.test.js.map +0 -1
  231. package/build/module/commands.js.map +0 -1
  232. package/build/module/methods.js.map +0 -1
  233. package/build/module/payloads.js.map +0 -1
  234. package/build/module/services/common.js.map +0 -1
  235. package/build/module/services/companies/entities.js.map +0 -1
  236. package/build/module/services/companies/index.integration.test.js.map +0 -1
  237. package/build/module/services/companies/index.js.map +0 -1
  238. package/build/module/services/companies/index.unit.test.js.map +0 -1
  239. package/build/module/services/companies/methods.js.map +0 -1
  240. package/build/module/services/contacts/entities.js.map +0 -1
  241. package/build/module/services/contacts/index.integration.test.js.map +0 -1
  242. package/build/module/services/contacts/index.js.map +0 -1
  243. package/build/module/services/contacts/index.unit.test.js.map +0 -1
  244. package/build/module/services/contacts/methods.js.map +0 -1
  245. package/build/module/services/currencies/entities.js.map +0 -1
  246. package/build/module/services/deals/entities.js.map +0 -1
  247. package/build/module/services/deals/index.integration.test.js.map +0 -1
  248. package/build/module/services/deals/index.js.map +0 -1
  249. package/build/module/services/deals/index.unit.test.js.map +0 -1
  250. package/build/module/services/deals/methods.js.map +0 -1
  251. package/build/module/services/leads/entities.js.map +0 -1
  252. package/build/module/services/leads/index.integration.test.js.map +0 -1
  253. package/build/module/services/leads/index.js.map +0 -1
  254. package/build/module/services/leads/index.unit.test.js.map +0 -1
  255. package/build/module/services/leads/methods.js.map +0 -1
  256. package/build/module/services/statuses/entities.js.map +0 -1
  257. package/build/module/services/statuses/index.integration.test.js.map +0 -1
  258. package/build/module/services/statuses/index.js.map +0 -1
  259. package/build/module/services/statuses/index.unit.test.js.map +0 -1
  260. package/build/module/services/statuses/methods.js.map +0 -1
  261. package/build/module/services/users/entities.js.map +0 -1
  262. package/build/module/services/users/index.integration.test.js.map +0 -1
  263. package/build/module/services/users/index.js.map +0 -1
  264. package/build/module/services/users/index.unit.test.js.map +0 -1
  265. package/build/module/services/users/methods.js.map +0 -1
  266. package/build/module/utils/Diff.js.map +0 -1
  267. package/build/module/utils/ExtractValue.js.map +0 -1
  268. package/build/module/utils/isArray.js.map +0 -1
@@ -2,11 +2,11 @@ import { Method } from '../../methods';
2
2
  import { GetPayload, ListPayload } from '../../payloads';
3
3
  import { Fields } from '../common';
4
4
  import { Status } from './entities';
5
- export interface StatusesMethods {
5
+ export declare type StatusesMethods = {
6
6
  readonly [Method.CRM_STATUS_FIELDS]: {
7
7
  readonly type: Status;
8
8
  readonly payload: GetPayload<Fields>;
9
- readonly params?: {};
9
+ readonly params?: Record<string, unknown>;
10
10
  };
11
11
  readonly [Method.CRM_STATUS_ADD]: {
12
12
  readonly type: Status;
@@ -36,8 +36,8 @@ export interface StatusesMethods {
36
36
  readonly type: Status;
37
37
  readonly payload: ListPayload<Status>;
38
38
  readonly params: {
39
- readonly order?: Record<string, any>;
40
- readonly filter?: Record<string, any>;
39
+ readonly order?: Record<string, unknown>;
40
+ readonly filter?: Record<string, unknown>;
41
41
  };
42
42
  };
43
43
  readonly [Method.CRM_STATUS_UPDATE]: {
@@ -45,7 +45,7 @@ export interface StatusesMethods {
45
45
  readonly payload: GetPayload<boolean>;
46
46
  readonly params: {
47
47
  readonly id: string | number;
48
- readonly fields: Record<string, any>;
48
+ readonly fields: Record<string, unknown>;
49
49
  };
50
50
  };
51
- }
51
+ };
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const methods_1 = require("../../methods");
4
- //# sourceMappingURL=methods.js.map
@@ -1,5 +1,6 @@
1
1
  import { GenderString, ISODate, NumberString } from '../common';
2
- export interface User {
2
+ export declare type User = {
3
+ readonly [key: string]: string | boolean | null | readonly number[];
3
4
  readonly ID: NumberString;
4
5
  readonly ACTIVE: boolean;
5
6
  readonly EMAIL: string | null;
@@ -24,7 +25,7 @@ export interface User {
24
25
  readonly WORK_COMPANY: string | null;
25
26
  readonly WORK_POSITION: string | null;
26
27
  readonly WORK_PHONE: string | null;
27
- readonly UF_DEPARTMENT: ReadonlyArray<number>;
28
+ readonly UF_DEPARTMENT: readonly number[];
28
29
  readonly UF_INTERESTS: string | null;
29
30
  readonly UF_SKILLS: string | null;
30
31
  readonly UF_WEB_SITES: string | null;
@@ -36,4 +37,4 @@ export interface User {
36
37
  readonly UF_DISTRICT: string | null;
37
38
  readonly UF_PHONE_INNER: NumberString | null;
38
39
  readonly USER_TYPE: 'employee';
39
- }
40
+ };
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=entities.js.map
@@ -1,9 +1,9 @@
1
1
  import { Call } from '../../client/methods/call';
2
- interface Dependencies {
2
+ declare type Dependencies = {
3
3
  readonly call: Call;
4
- }
4
+ };
5
5
  declare const _default: ({ call }: Dependencies) => {
6
6
  fields: () => Promise<import("../../payloads").GetPayload<import("./entities").User>>;
7
- get: (id?: string | undefined) => Promise<import("../../payloads").GetPayload<readonly import("./entities").User[]>>;
7
+ get: (id?: string) => Promise<import("../../payloads").GetPayload<readonly import("./entities").User[]>>;
8
8
  };
9
9
  export default _default;
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const bitrix_1 = __importDefault(require("./../../bitrix"));
7
- const WEBHOOK_URL = process.env.WEBHOOK_URL;
7
+ const WEBHOOK_URL = process.env['WEBHOOK_URL'];
8
8
  if (!WEBHOOK_URL) {
9
9
  throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
10
10
  }
11
- const { users } = bitrix_1.default(WEBHOOK_URL);
11
+ const { users } = (0, bitrix_1.default)(WEBHOOK_URL);
12
12
  describe('Users', () => {
13
13
  describe('fields', () => {
14
14
  it('should get all fields', async () => {
@@ -31,4 +31,3 @@ describe('Users', () => {
31
31
  });
32
32
  });
33
33
  });
34
- //# sourceMappingURL=index.integration.test.js.map
@@ -5,4 +5,3 @@ exports.default = ({ call }) => ({
5
5
  fields: () => call(methods_1.Method.USER_FIELDS, {}),
6
6
  get: (id) => call(methods_1.Method.USER_GET, { id })
7
7
  });
8
- //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const _1 = __importDefault(require("."));
7
7
  const mockCall = jest.fn(() => Promise.resolve());
8
8
  const mockList = jest.fn(() => Promise.resolve());
9
- const users = _1.default({ call: mockCall });
9
+ const users = (0, _1.default)({ call: mockCall });
10
10
  const ID = '77';
11
11
  describe('Users', () => {
12
12
  beforeEach(() => {
@@ -23,4 +23,3 @@ describe('Users', () => {
23
23
  });
24
24
  });
25
25
  });
26
- //# sourceMappingURL=index.unit.test.js.map
@@ -1,17 +1,17 @@
1
1
  import { Method } from '../../methods';
2
2
  import { GetPayload } from '../../payloads';
3
3
  import { User } from './entities';
4
- export interface UsersMethods {
4
+ export declare type UsersMethods = {
5
5
  readonly [Method.USER_FIELDS]: {
6
6
  readonly type: User;
7
7
  readonly payload: GetPayload<User>;
8
- readonly params?: {};
8
+ readonly params?: Record<string, unknown>;
9
9
  };
10
10
  readonly [Method.USER_GET]: {
11
11
  readonly type: User;
12
- readonly payload: GetPayload<ReadonlyArray<User>>;
12
+ readonly payload: GetPayload<readonly User[]>;
13
13
  readonly params: {
14
14
  readonly id?: string;
15
15
  };
16
16
  };
17
- }
17
+ };
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const methods_1 = require("../../methods");
4
- //# sourceMappingURL=methods.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Diff.js.map
@@ -1 +1,6 @@
1
- export declare type ExtractValue<MAP extends Record<string, any>, KEY extends string | number | symbol, MAPKEY extends keyof MAP = KEY extends keyof MAP ? KEY : never> = MAP[MAPKEY];
1
+ /**
2
+ * Extract value from the `MAP` following the `KEY`
3
+ * It works with `enum` as a `KEY` when matched against dict as `enum` values as a keys,
4
+ * which justifies whole existence of that helper.
5
+ */
6
+ export declare type ExtractValue<MAP extends Record<string, unknown>, KEY extends string | number | symbol, MAPKEY extends keyof MAP = KEY extends keyof MAP ? KEY : never> = MAP[MAPKEY];
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ExtractValue.js.map
@@ -1,2 +1,2 @@
1
- declare const _default: <E>(x: any) => x is readonly E[];
1
+ declare const _default: <E>(x: unknown) => x is readonly E[];
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Because `Array.isArray` itself give a strange result with `any[]`
3
4
  exports.default = (x) => Array.isArray(x);
4
- //# sourceMappingURL=isArray.js.map
@@ -1,4 +1,13 @@
1
- declare const _default: (restURI: string, accessToken?: string | undefined) => {
1
+ import { ExtendOptions } from 'got';
2
+ /**
3
+ * Construct a Bitrix client with generic methods
4
+ * @param restURI REST endpoint, like a `https://hello.bitrix24.ua/rest` or an inbound webhook endpoint,
5
+ * like a `https://hello.bitrix24.ua/rest/1/WEBHOOK_TOKEN`.
6
+ * @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
7
+ * @param clientOptions an object that will overwrite underlying configuration for HTTP client,
8
+ * see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
9
+ */
10
+ declare const _default: (restURI: string, accessToken?: string, clientOptions?: ExtendOptions) => {
2
11
  call: import("./client/methods/call").Call;
3
12
  batch: import("./client/methods/batch").Batch;
4
13
  list: import("./client/methods/list").List;
@@ -7,16 +16,16 @@ declare const _default: (restURI: string, accessToken?: string | undefined) => {
7
16
  create: <D extends {
8
17
  readonly fields: Partial<import("./services/companies/entities").Company>;
9
18
  readonly params?: {
10
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
19
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
11
20
  } | undefined;
12
21
  }>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
13
22
  get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/companies/entities").Company>>;
14
23
  list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/companies/entities").Company>>;
15
24
  update: <D_1 extends {
16
25
  readonly id: string;
17
- readonly fields: Record<string, any>;
26
+ readonly fields: Record<string, unknown>;
18
27
  readonly params?: {
19
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
28
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
20
29
  } | undefined;
21
30
  }>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
22
31
  };
@@ -25,16 +34,16 @@ declare const _default: (restURI: string, accessToken?: string | undefined) => {
25
34
  create: <D_2 extends {
26
35
  readonly fields: Partial<import("./services/contacts/entities").Contact>;
27
36
  readonly params?: {
28
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
37
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
29
38
  } | undefined;
30
39
  }>(fields: D_2["fields"], params?: D_2["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
31
40
  get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/contacts/entities").Contact>>;
32
41
  list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/contacts/entities").Contact>>;
33
42
  update: <D_3 extends {
34
43
  readonly id: string;
35
- readonly fields: Record<string, any>;
44
+ readonly fields: Record<string, unknown>;
36
45
  readonly params?: {
37
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
46
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
38
47
  } | undefined;
39
48
  }>(id: string, fields: D_3["fields"], params?: D_3["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
40
49
  };
@@ -43,16 +52,16 @@ declare const _default: (restURI: string, accessToken?: string | undefined) => {
43
52
  create: <D_4 extends {
44
53
  readonly fields: Partial<import("./services/deals/entities").Deal>;
45
54
  readonly params?: {
46
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
55
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
47
56
  } | undefined;
48
57
  }>(fields: D_4["fields"], params?: D_4["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
49
58
  get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/deals/entities").Deal>>;
50
59
  list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/deals/entities").Deal>>;
51
60
  update: <D_5 extends {
52
61
  readonly id: string;
53
- readonly fields: Record<string, any>;
62
+ readonly fields: Record<string, unknown>;
54
63
  readonly params?: {
55
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
64
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
56
65
  } | undefined;
57
66
  }>(id: string, fields: D_5["fields"], params?: D_5["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
58
67
  };
@@ -61,16 +70,16 @@ declare const _default: (restURI: string, accessToken?: string | undefined) => {
61
70
  create: <D_6 extends {
62
71
  readonly fields: Partial<import("./services/leads/entities").Lead>;
63
72
  readonly params?: {
64
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
73
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
65
74
  } | undefined;
66
75
  }>(fields: D_6["fields"], params?: D_6["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
67
76
  get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/leads/entities").Lead>>;
68
77
  list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/leads/entities").Lead>>;
69
78
  update: <D_7 extends {
70
79
  readonly id: string;
71
- readonly fields: Record<string, any>;
80
+ readonly fields: Record<string, unknown>;
72
81
  readonly params?: {
73
- readonly REGISTER_SONET_EVENT: import("./services/common").BoolString;
82
+ readonly REGISTER_SONET_EVENT: "Y" | "N";
74
83
  } | undefined;
75
84
  }>(id: string, fields: D_7["fields"], params?: D_7["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
76
85
  };
@@ -82,10 +91,10 @@ declare const _default: (restURI: string, accessToken?: string | undefined) => {
82
91
  } | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
83
92
  get: (id: string | number) => Promise<import("./payloads").GetPayload<import("./services/statuses/entities").Status>>;
84
93
  list: (params?: {
85
- readonly order?: Record<string, any> | undefined;
86
- readonly filter?: Record<string, any> | undefined;
94
+ readonly order?: Record<string, unknown> | undefined;
95
+ readonly filter?: Record<string, unknown> | undefined;
87
96
  }) => Promise<import("./payloads").ListPayload<import("./services/statuses/entities").Status>>;
88
- update: (id: string | number, fields: Record<string, any>) => Promise<import("./payloads").GetPayload<boolean>>;
97
+ update: (id: string | number, fields: Record<string, unknown>) => Promise<import("./payloads").GetPayload<boolean>>;
89
98
  };
90
99
  users: {
91
100
  fields: () => Promise<import("./payloads").GetPayload<import("./services/users/entities").User>>;
@@ -29,4 +29,3 @@ describe('Bitrix API', () => {
29
29
  });
30
30
  });
31
31
  });
32
- //# sourceMappingURL=bitrix.integration.test.js.map
@@ -5,8 +5,16 @@ import DealsService from './services/deals';
5
5
  import LeadsService from './services/leads';
6
6
  import StatusesService from './services/statuses';
7
7
  import UsersService from './services/users';
8
- export default (restURI, accessToken) => {
9
- const { call, batch, list } = Client(restURI, accessToken);
8
+ /**
9
+ * Construct a Bitrix client with generic methods
10
+ * @param restURI REST endpoint, like a `https://hello.bitrix24.ua/rest` or an inbound webhook endpoint,
11
+ * like a `https://hello.bitrix24.ua/rest/1/WEBHOOK_TOKEN`.
12
+ * @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
13
+ * @param clientOptions an object that will overwrite underlying configuration for HTTP client,
14
+ * see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
15
+ */
16
+ export default (restURI, accessToken, clientOptions) => {
17
+ const { call, batch, list } = Client(restURI, accessToken, clientOptions);
10
18
  return {
11
19
  call,
12
20
  batch,
@@ -20,4 +28,12 @@ export default (restURI, accessToken) => {
20
28
  };
21
29
  };
22
30
  export * from './methods';
23
- //# sourceMappingURL=bitrix.js.map
31
+ export * from './commands';
32
+ export * from './services/common';
33
+ export * from './services/companies/entities';
34
+ export * from './services/contacts/entities';
35
+ export * from './services/currencies/entities';
36
+ export * from './services/deals/entities';
37
+ export * from './services/leads/entities';
38
+ export * from './services/statuses/entities';
39
+ export * from './services/users/entities';
@@ -14,4 +14,3 @@ describe('Bitrix', () => {
14
14
  expect(bitrix).toMatchSnapshot();
15
15
  });
16
16
  });
17
- //# sourceMappingURL=bitrix.unit.test.js.map
@@ -17,20 +17,20 @@ describe('Client', () => {
17
17
  });
18
18
  it('should extend `Got` instance with a specified parameters', () => {
19
19
  const spiedGotExtend = jest.spyOn(got, 'extend');
20
- Client('https://test.com', 'test_token');
20
+ Client('https://test.com', 'test_token', { https: { rejectUnauthorized: false } });
21
21
  expect(spiedGotExtend.mock.calls).toMatchSnapshot();
22
22
  });
23
23
  it('should expose API methods', () => {
24
24
  expect(client).toMatchSnapshot();
25
25
  });
26
26
  describe('`call`', () => {
27
- it('should add to queue', async () => {
27
+ // @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
28
+ it.skip('should add to queue', async () => {
28
29
  const payload = {};
29
30
  const method = Method.CRM_DEAL_LIST;
30
31
  nock(TEST_URI)
31
32
  .get(`/${method}?access_token=${TEST_ACCESS_TOKEN}`)
32
- .reply(RESPONSE_200, payload)
33
- .get(`/${method}?access_token=${TEST_ACCESS_TOKEN}`)
33
+ .twice()
34
34
  .reply(RESPONSE_200, payload);
35
35
  await client.call(method, {});
36
36
  await client.call(method, {});
@@ -38,7 +38,8 @@ describe('Client', () => {
38
38
  });
39
39
  });
40
40
  describe('`batch`', () => {
41
- it('should add to queue', async () => {
41
+ // @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
42
+ it.skip('should add to queue', async () => {
42
43
  const payload = {
43
44
  result: {
44
45
  result: ['done'],
@@ -50,6 +51,9 @@ describe('Client', () => {
50
51
  { method: Method.CRM_DEAL_LIST }
51
52
  ];
52
53
  nock(TEST_URI)
54
+ // @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
55
+ // fails to match request when it contains `cmd[someName]`. The issue definitely connected
56
+ // to the `[]`, since it does not appear when only one bracket present
53
57
  .get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}&access_token=${TEST_ACCESS_TOKEN}`)
54
58
  .reply(RESPONSE_200, payload)
55
59
  .get(`/${Method.BATCH}?cmd%5B0%5D=${commands[1].method}&access_token=${TEST_ACCESS_TOKEN}`)
@@ -59,4 +63,3 @@ describe('Client', () => {
59
63
  });
60
64
  });
61
65
  });
62
- //# sourceMappingURL=client.unit.test.js.map
@@ -1,3 +1,6 @@
1
- import got from 'got';
2
- declare const _default: (accessToken?: string | undefined) => (options: got.GotJSONOptions) => void;
1
+ import { BeforeRequestHook } from 'got';
2
+ /**
3
+ * Got can't merge `query` option with other queries if they are string. But that hook can.
4
+ */
5
+ declare const _default: (accessToken?: string) => BeforeRequestHook;
3
6
  export default _default;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Got can't merge `query` option with other queries if they are string. But that hook can.
3
+ */
1
4
  export default (accessToken) => (options) => {
2
5
  if (!accessToken)
3
6
  return;
@@ -6,4 +9,3 @@ export default (accessToken) => (options) => {
6
9
  const hasQuery = options.path.includes('?');
7
10
  options.path = `${options.path}${hasQuery ? '&' : '?'}access_token=${accessToken}`;
8
11
  };
9
- //# sourceMappingURL=addAccessToken.js.map
@@ -1,25 +1,26 @@
1
+ import got from 'got';
1
2
  import addAccessToken from './addAccessToken';
2
3
  const token = 'mock_token';
4
+ const merge = got.mergeOptions;
3
5
  describe('Client `addAccessToken` hook', () => {
4
6
  it('should add access token to URL without a query', () => {
5
- const options = { json: true, path: '/test' };
7
+ const options = merge({ path: 'test', responseType: 'json' });
6
8
  addAccessToken(token)(options);
7
- expect(options.path).toBe(`/test?access_token=${token}`);
9
+ expect(options.path).toBe(`test?access_token=${token}`);
8
10
  });
9
11
  it('should add access token to URL with a query', () => {
10
- const options = { json: true, path: '/test?value=1' };
12
+ const options = merge({ path: 'test?value=1', responseType: 'json' });
11
13
  addAccessToken(token)(options);
12
- expect(options.path).toBe(`/test?value=1&access_token=${token}`);
14
+ expect(options.path).toBe(`test?value=1&access_token=${token}`);
13
15
  });
14
16
  it('should not add access token when it is undefined', () => {
15
- const options = { json: true, path: '/test' };
17
+ const options = merge({ path: 'test', responseType: 'json' });
16
18
  addAccessToken()(options);
17
- expect(options.path).toBe('/test');
19
+ expect(options.path).toBe('test');
18
20
  });
19
21
  it('should not add access token when URL is undefined', () => {
20
- const options = { json: true, path: undefined };
22
+ const options = merge({ path: undefined, responseType: 'json' });
21
23
  addAccessToken(token)(options);
22
24
  expect(options.path).toBe(undefined);
23
25
  });
24
26
  });
25
- //# sourceMappingURL=addAccessToken.unit.test.js.map
@@ -1,4 +1,13 @@
1
- declare const _default: (restURI: string, accessToken?: string | undefined) => {
1
+ import { ExtendOptions } from 'got';
2
+ /**
3
+ * Construct a Bitrix client with generic methods
4
+ * @param restURI REST endpoint, like a `https://hello.bitrix24.ru/rest` or an inbound webhook endpoint,
5
+ * like a `https://hello.bitrix24.ru/rest/1/WEBHOOK_TOKEN`.
6
+ * @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
7
+ * @param options an object that will overwrite underlying configuration for HTTP client,
8
+ * see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
9
+ */
10
+ declare const _default: (restURI: string, accessToken?: string, options?: ExtendOptions) => {
2
11
  call: import("./methods/call").Call;
3
12
  batch: import("./methods/batch").Batch;
4
13
  list: import("./methods/list").List;
@@ -5,26 +5,39 @@ import Batch from './methods/batch';
5
5
  import Call from './methods/call';
6
6
  import List from './methods/list';
7
7
  const BITRIX_API_RATE_LIMIT = 2;
8
- const BITRIX_API_RATE_INTERVAL = 1000;
9
- export default (restURI, accessToken) => {
8
+ const BITRIX_API_RATE_INTERVAL = 1000; // 1 second
9
+ /**
10
+ * Construct a Bitrix client with generic methods
11
+ * @param restURI REST endpoint, like a `https://hello.bitrix24.ru/rest` or an inbound webhook endpoint,
12
+ * like a `https://hello.bitrix24.ru/rest/1/WEBHOOK_TOKEN`.
13
+ * @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
14
+ * @param options an object that will overwrite underlying configuration for HTTP client,
15
+ * see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
16
+ */
17
+ export default (restURI, accessToken, options) => {
10
18
  const client = got.extend({
11
- baseUrl: restURI,
19
+ prefixUrl: restURI,
12
20
  headers: {
13
- 'user-agent': `@2bad/bitrix`
21
+ 'user-agent': '@2bad/bitrix'
14
22
  },
15
- json: true,
23
+ responseType: 'json',
16
24
  hooks: {
17
25
  beforeRequest: [
18
26
  addAccessToken(accessToken)
19
27
  ]
20
- }
28
+ },
29
+ ...options ?? {}
21
30
  });
22
31
  const queue = new Queue({
23
32
  intervalCap: BITRIX_API_RATE_LIMIT,
24
33
  interval: BITRIX_API_RATE_INTERVAL
25
34
  });
26
35
  const queuedGet = (...args) => queue.add(() => client.get(...args));
36
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
+ // @ts-expect-error @todo remove after issue is resolved (https://github.com/sindresorhus/got/issues/954)
27
38
  const call = Call({ get: queuedGet });
39
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
+ // @ts-expect-error @todo remove after issue is resolved (https://github.com/sindresorhus/got/issues/954)
28
41
  const batch = Batch({ get: queuedGet });
29
42
  const list = List({ call, batch });
30
43
  return {
@@ -33,4 +46,3 @@ export default (restURI, accessToken) => {
33
46
  list
34
47
  };
35
48
  };
36
- //# sourceMappingURL=index.js.map
@@ -1,11 +1,23 @@
1
- import { GotJSONFn } from 'got';
1
+ import got from 'got';
2
2
  import { Commands } from '../../commands';
3
3
  import { Method, MethodPayloadType } from '../../methods';
4
4
  import { BatchPayload } from '../../payloads';
5
5
  export declare const MAX_COMMANDS_PER_BATCH = 50;
6
+ /**
7
+ * Split any number of commands into the chunks with max commands per batch in each chunk
8
+ */
6
9
  export declare const chunkCommands: <C extends Commands>(commands: C, size?: number) => readonly C[];
10
+ /**
11
+ * Prepares list of commands to be used in requests to the Bitrix
12
+ * @note We could avoid that function... if only Bitrix API would support posting of the batch commands as
13
+ * plain objects, like it does with other methods. Instead, it should be a dict or array of string queries
14
+ */
7
15
  export declare const prepareCommandsQueries: <C extends Commands, R = { [K in keyof C]: string; }>(commands: C) => R;
8
- export declare const mergeBatchPayloads: <B extends BatchPayload<any>, P = B extends BatchPayload<infer U> ? U : never>(payloads: readonly B[]) => BatchPayload<P>;
16
+ /**
17
+ * Merges list of batch responses into a single batch
18
+ * @todo Generics inference is complicated here and might be not super accurate
19
+ */
20
+ export declare const mergeBatchPayloads: <B extends BatchPayload<unknown>, P = B extends BatchPayload<infer U> ? U : never>(payloads: readonly B[]) => BatchPayload<P>;
9
21
  export declare type CommandsPayloads<C extends Commands, CM = {
10
22
  [K in keyof C]: C[K] extends {
11
23
  readonly method: infer M;
@@ -14,8 +26,15 @@ export declare type CommandsPayloads<C extends Commands, CM = {
14
26
  [K in keyof CM]: MethodPayloadType<CM[K] extends Method ? CM[K] : never>;
15
27
  };
16
28
  export declare type Batch = <C extends Commands, P = CommandsPayloads<C>>(commands: C, commandsPerRequest?: number) => Promise<BatchPayload<P>>;
17
- interface Dependencies {
18
- readonly get: GotJSONFn;
19
- }
29
+ declare type Dependencies = {
30
+ readonly get: typeof got.get;
31
+ };
32
+ /**
33
+ * Dispatches a batch request with specified commands. Will fill figure out payload type based on the Methods.
34
+ * Supports unlimited number of commands. If they do exceed max amount of commands per batch, will dispatch
35
+ * multiple request and merge result into single batch payload
36
+ * @todo For now due to issues with types it won't check `params` of command, so any Method can be used
37
+ * with any (even wrong) params
38
+ */
20
39
  declare const _default: ({ get }: Dependencies) => Batch;
21
40
  export default _default;
@@ -5,22 +5,40 @@ import { Method } from '../../methods';
5
5
  import isArray from '../../utils/isArray';
6
6
  import { handlePayload } from './call';
7
7
  export const MAX_COMMANDS_PER_BATCH = 50;
8
+ /**
9
+ * Split any number of commands into the chunks with max commands per batch in each chunk
10
+ */
8
11
  export const chunkCommands = (commands, size = MAX_COMMANDS_PER_BATCH) => {
9
12
  const commandsIsArray = isArray(commands);
10
13
  const chunks = chunk(Object.entries(commands), size);
14
+ // @todo Generated return type isn't very accurate since it says that it will make array of <C>, while
15
+ // in fact <C> will be distributed among chunks. That gives wrong hints with named commands and arrays as const.
11
16
  return chunks.map((c) => commandsIsArray
17
+ // @todo Figure out how to avoid unsafe casting to <C> here
18
+ // Without `<C>` generic it won't work with complex functions like `batch`
12
19
  ? c.map(([_key, command]) => command)
13
20
  : fromPairs(c));
14
21
  };
22
+ /**
23
+ * Prepares list of commands to be used in requests to the Bitrix
24
+ * @note We could avoid that function... if only Bitrix API would support posting of the batch commands as
25
+ * plain objects, like it does with other methods. Instead, it should be a dict or array of string queries
26
+ */
15
27
  export const prepareCommandsQueries = (commands) => Object.entries(commands).reduce((calls, [name, { method, params }]) => {
16
28
  const stringifiedParams = params ? `?${toQuery(params)}` : '';
17
29
  return {
18
30
  ...calls,
19
31
  [`cmd[${name}]`]: `${method}${stringifiedParams}`
20
32
  };
33
+ // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
21
34
  }, {});
35
+ /**
36
+ * Merges list of batch responses into a single batch
37
+ * @todo Generics inference is complicated here and might be not super accurate
38
+ */
22
39
  export const mergeBatchPayloads = (payloads) => {
23
40
  const merge = (a, b) => isArray(a) && isArray(b)
41
+ // @todo Gotta find way to avoid unsafe casting here
24
42
  ? [...a, ...b]
25
43
  : ({ ...a, ...b });
26
44
  return payloads.reduce((merged, payload) => ({
@@ -32,15 +50,23 @@ export const mergeBatchPayloads = (payloads) => {
32
50
  result_total: merge(merged.result.result_total || [], payload.result.result_total)
33
51
  },
34
52
  time: { ...merged.time, ...payload.time }
53
+ // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
35
54
  }), { result: {}, time: {} });
36
55
  };
56
+ /**
57
+ * Dispatches a batch request with specified commands. Will fill figure out payload type based on the Methods.
58
+ * Supports unlimited number of commands. If they do exceed max amount of commands per batch, will dispatch
59
+ * multiple request and merge result into single batch payload
60
+ * @todo For now due to issues with types it won't check `params` of command, so any Method can be used
61
+ * with any (even wrong) params
62
+ */
37
63
  export default ({ get }) => {
38
64
  const batch = async (commands, commandsPerRequest = MAX_COMMANDS_PER_BATCH) => {
39
- const call = (c) => get(Method.BATCH, { query: prepareCommandsQueries(c) })
65
+ const call = (c) => get(Method.BATCH, { searchParams: prepareCommandsQueries(c) })
40
66
  .then(({ body }) => body);
41
67
  const calls = chunkCommands(commands, commandsPerRequest)
42
68
  .map(call);
43
- return Promise.all(calls)
69
+ return await Promise.all(calls)
44
70
  .then((chunkedPayloads) => {
45
71
  const payloads = mergeBatchPayloads(chunkedPayloads);
46
72
  return handlePayload(payloads);
@@ -48,4 +74,3 @@ export default ({ get }) => {
48
74
  };
49
75
  return batch;
50
76
  };
51
- //# sourceMappingURL=batch.js.map