@2bad/bitrix 2.5.0 → 3.0.0-beta.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 (242) hide show
  1. package/README.md +10 -9
  2. package/build/bitrix.d.ts +65 -0
  3. package/build/bitrix.js +55 -0
  4. package/build/client/hooks/addAccessToken.js +9 -0
  5. package/build/{module/client → client}/index.d.ts +3 -3
  6. package/build/{module/client → client}/index.js +21 -16
  7. package/build/{module/client → client}/methods/batch.d.ts +6 -6
  8. package/build/client/methods/batch.js +75 -0
  9. package/build/{module/client → client}/methods/call.d.ts +4 -4
  10. package/build/{module/client → client}/methods/call.js +8 -9
  11. package/build/{module/client → client}/methods/list.d.ts +10 -10
  12. package/build/client/methods/list.js +58 -0
  13. package/build/{module/commands.d.ts → commands.d.ts} +3 -3
  14. package/build/commands.js +1 -0
  15. package/build/{module/methods.d.ts → methods.d.ts} +19 -19
  16. package/build/{module/methods.js → methods.js} +5 -5
  17. package/build/{main/payloads.d.ts → payloads.d.ts} +5 -5
  18. package/build/payloads.js +1 -0
  19. package/build/{main/services → services}/common.d.ts +7 -7
  20. package/build/services/common.js +2 -0
  21. package/build/{main/services → services}/companies/entities.d.ts +2 -2
  22. package/build/services/companies/entities.js +1 -0
  23. package/build/services/companies/index.d.ts +15 -0
  24. package/build/services/companies/index.js +17 -0
  25. package/build/{module/services → services}/companies/methods.d.ts +5 -5
  26. package/build/services/companies/methods.js +1 -0
  27. package/build/{module/services → services}/contacts/entities.d.ts +2 -2
  28. package/build/services/contacts/entities.js +1 -0
  29. package/build/services/contacts/index.d.ts +15 -0
  30. package/build/services/contacts/index.js +17 -0
  31. package/build/{module/services → services}/contacts/methods.d.ts +5 -5
  32. package/build/services/contacts/methods.js +1 -0
  33. package/build/{module/services → services}/currencies/entities.d.ts +2 -2
  34. package/build/services/currencies/entities.js +1 -0
  35. package/build/{module/services → services}/deals/entities.d.ts +2 -2
  36. package/build/services/deals/entities.js +1 -0
  37. package/build/services/deals/index.d.ts +15 -0
  38. package/build/services/deals/index.js +17 -0
  39. package/build/{main/services → services}/deals/methods.d.ts +5 -5
  40. package/build/services/deals/methods.js +1 -0
  41. package/build/{module/services → services}/leads/entities.d.ts +2 -2
  42. package/build/services/leads/entities.js +1 -0
  43. package/build/services/leads/index.d.ts +15 -0
  44. package/build/services/leads/index.js +17 -0
  45. package/build/{main/services → services}/leads/methods.d.ts +5 -5
  46. package/build/services/leads/methods.js +1 -0
  47. package/build/{main/services → services}/statuses/entities.d.ts +3 -3
  48. package/build/services/statuses/entities.js +1 -0
  49. package/build/services/statuses/index.d.ts +14 -0
  50. package/build/services/statuses/index.js +19 -0
  51. package/build/{main/services → services}/statuses/methods.d.ts +5 -5
  52. package/build/services/statuses/methods.js +1 -0
  53. package/build/{module/services → services}/users/entities.d.ts +2 -2
  54. package/build/services/users/entities.js +1 -0
  55. package/build/services/users/index.d.ts +9 -0
  56. package/build/services/users/index.js +7 -0
  57. package/build/{main/services → services}/users/methods.d.ts +4 -4
  58. package/build/services/users/methods.js +1 -0
  59. package/build/utils/Diff.d.ts +1 -0
  60. package/build/utils/Diff.js +7 -0
  61. package/build/{module/utils → utils}/ExtractValue.d.ts +1 -1
  62. package/build/{main/utils/ExtractValue.d.ts → utils/ExtractValue.js} +1 -2
  63. package/build/utils/isArray.d.ts +2 -0
  64. package/build/{module/utils → utils}/isArray.js +1 -1
  65. package/package.json +43 -49
  66. package/build/main/bitrix.d.ts +0 -114
  67. package/build/main/bitrix.integration.test.d.ts +0 -0
  68. package/build/main/bitrix.integration.test.js +0 -31
  69. package/build/main/bitrix.js +0 -58
  70. package/build/main/bitrix.unit.test.d.ts +0 -1
  71. package/build/main/bitrix.unit.test.js +0 -44
  72. package/build/main/client/client.unit.test.d.ts +0 -1
  73. package/build/main/client/client.unit.test.js +0 -70
  74. package/build/main/client/hooks/addAccessToken.js +0 -13
  75. package/build/main/client/hooks/addAccessToken.unit.test.d.ts +0 -1
  76. package/build/main/client/hooks/addAccessToken.unit.test.js +0 -31
  77. package/build/main/client/index.d.ts +0 -15
  78. package/build/main/client/index.js +0 -53
  79. package/build/main/client/methods/batch.d.ts +0 -40
  80. package/build/main/client/methods/batch.js +0 -85
  81. package/build/main/client/methods/batch.unit.test.d.ts +0 -1
  82. package/build/main/client/methods/batch.unit.test.js +0 -494
  83. package/build/main/client/methods/call.d.ts +0 -17
  84. package/build/main/client/methods/call.js +0 -36
  85. package/build/main/client/methods/call.unit.test.d.ts +0 -1
  86. package/build/main/client/methods/call.unit.test.js +0 -183
  87. package/build/main/client/methods/list.d.ts +0 -30
  88. package/build/main/client/methods/list.js +0 -66
  89. package/build/main/client/methods/list.unit.test.d.ts +0 -1
  90. package/build/main/client/methods/list.unit.test.js +0 -277
  91. package/build/main/commands.d.ts +0 -10
  92. package/build/main/commands.js +0 -2
  93. package/build/main/methods.d.ts +0 -92
  94. package/build/main/methods.js +0 -41
  95. package/build/main/payloads.js +0 -2
  96. package/build/main/services/common.js +0 -2
  97. package/build/main/services/companies/entities.js +0 -2
  98. package/build/main/services/companies/index.d.ts +0 -26
  99. package/build/main/services/companies/index.integration.test.d.ts +0 -1
  100. package/build/main/services/companies/index.integration.test.js +0 -19
  101. package/build/main/services/companies/index.js +0 -10
  102. package/build/main/services/companies/index.unit.test.d.ts +0 -1
  103. package/build/main/services/companies/index.unit.test.js +0 -72
  104. package/build/main/services/companies/methods.d.ts +0 -44
  105. package/build/main/services/companies/methods.js +0 -3
  106. package/build/main/services/contacts/entities.d.ts +0 -45
  107. package/build/main/services/contacts/entities.js +0 -2
  108. package/build/main/services/contacts/index.d.ts +0 -26
  109. package/build/main/services/contacts/index.integration.test.d.ts +0 -1
  110. package/build/main/services/contacts/index.integration.test.js +0 -19
  111. package/build/main/services/contacts/index.js +0 -10
  112. package/build/main/services/contacts/index.unit.test.d.ts +0 -1
  113. package/build/main/services/contacts/index.unit.test.js +0 -72
  114. package/build/main/services/contacts/methods.d.ts +0 -44
  115. package/build/main/services/contacts/methods.js +0 -3
  116. package/build/main/services/currencies/entities.d.ts +0 -15
  117. package/build/main/services/currencies/entities.js +0 -2
  118. package/build/main/services/deals/entities.d.ts +0 -43
  119. package/build/main/services/deals/entities.js +0 -2
  120. package/build/main/services/deals/index.d.ts +0 -26
  121. package/build/main/services/deals/index.integration.test.d.ts +0 -1
  122. package/build/main/services/deals/index.integration.test.js +0 -19
  123. package/build/main/services/deals/index.js +0 -10
  124. package/build/main/services/deals/index.unit.test.d.ts +0 -1
  125. package/build/main/services/deals/index.unit.test.js +0 -72
  126. package/build/main/services/deals/methods.js +0 -3
  127. package/build/main/services/leads/entities.d.ts +0 -49
  128. package/build/main/services/leads/entities.js +0 -2
  129. package/build/main/services/leads/index.d.ts +0 -26
  130. package/build/main/services/leads/index.integration.test.d.ts +0 -1
  131. package/build/main/services/leads/index.integration.test.js +0 -19
  132. package/build/main/services/leads/index.js +0 -10
  133. package/build/main/services/leads/index.unit.test.d.ts +0 -1
  134. package/build/main/services/leads/index.unit.test.js +0 -72
  135. package/build/main/services/leads/methods.js +0 -3
  136. package/build/main/services/statuses/entities.js +0 -2
  137. package/build/main/services/statuses/index.d.ts +0 -14
  138. package/build/main/services/statuses/index.integration.test.d.ts +0 -1
  139. package/build/main/services/statuses/index.integration.test.js +0 -90
  140. package/build/main/services/statuses/index.js +0 -11
  141. package/build/main/services/statuses/index.unit.test.d.ts +0 -1
  142. package/build/main/services/statuses/index.unit.test.js +0 -60
  143. package/build/main/services/statuses/methods.js +0 -3
  144. package/build/main/services/users/entities.d.ts +0 -40
  145. package/build/main/services/users/entities.js +0 -2
  146. package/build/main/services/users/index.d.ts +0 -9
  147. package/build/main/services/users/index.integration.test.d.ts +0 -1
  148. package/build/main/services/users/index.integration.test.js +0 -33
  149. package/build/main/services/users/index.js +0 -7
  150. package/build/main/services/users/index.unit.test.d.ts +0 -1
  151. package/build/main/services/users/index.unit.test.js +0 -25
  152. package/build/main/services/users/methods.js +0 -3
  153. package/build/main/utils/Diff.d.ts +0 -1
  154. package/build/main/utils/Diff.js +0 -2
  155. package/build/main/utils/ExtractValue.js +0 -2
  156. package/build/main/utils/isArray.d.ts +0 -2
  157. package/build/main/utils/isArray.js +0 -4
  158. package/build/module/bitrix.d.ts +0 -114
  159. package/build/module/bitrix.integration.test.d.ts +0 -0
  160. package/build/module/bitrix.integration.test.js +0 -31
  161. package/build/module/bitrix.js +0 -39
  162. package/build/module/bitrix.unit.test.d.ts +0 -1
  163. package/build/module/bitrix.unit.test.js +0 -16
  164. package/build/module/client/client.unit.test.d.ts +0 -1
  165. package/build/module/client/client.unit.test.js +0 -65
  166. package/build/module/client/hooks/addAccessToken.d.ts +0 -6
  167. package/build/module/client/hooks/addAccessToken.js +0 -11
  168. package/build/module/client/hooks/addAccessToken.unit.test.d.ts +0 -1
  169. package/build/module/client/hooks/addAccessToken.unit.test.js +0 -26
  170. package/build/module/client/methods/batch.js +0 -76
  171. package/build/module/client/methods/batch.unit.test.d.ts +0 -1
  172. package/build/module/client/methods/batch.unit.test.js +0 -466
  173. package/build/module/client/methods/call.unit.test.d.ts +0 -1
  174. package/build/module/client/methods/call.unit.test.js +0 -155
  175. package/build/module/client/methods/list.js +0 -55
  176. package/build/module/client/methods/list.unit.test.d.ts +0 -1
  177. package/build/module/client/methods/list.unit.test.js +0 -252
  178. package/build/module/commands.js +0 -1
  179. package/build/module/payloads.d.ts +0 -40
  180. package/build/module/payloads.js +0 -1
  181. package/build/module/services/common.d.ts +0 -22
  182. package/build/module/services/common.js +0 -1
  183. package/build/module/services/companies/entities.d.ts +0 -54
  184. package/build/module/services/companies/entities.js +0 -1
  185. package/build/module/services/companies/index.d.ts +0 -26
  186. package/build/module/services/companies/index.integration.test.d.ts +0 -1
  187. package/build/module/services/companies/index.integration.test.js +0 -14
  188. package/build/module/services/companies/index.js +0 -8
  189. package/build/module/services/companies/index.unit.test.d.ts +0 -1
  190. package/build/module/services/companies/index.unit.test.js +0 -67
  191. package/build/module/services/companies/methods.js +0 -1
  192. package/build/module/services/contacts/entities.js +0 -1
  193. package/build/module/services/contacts/index.d.ts +0 -26
  194. package/build/module/services/contacts/index.integration.test.d.ts +0 -1
  195. package/build/module/services/contacts/index.integration.test.js +0 -14
  196. package/build/module/services/contacts/index.js +0 -8
  197. package/build/module/services/contacts/index.unit.test.d.ts +0 -1
  198. package/build/module/services/contacts/index.unit.test.js +0 -67
  199. package/build/module/services/contacts/methods.js +0 -1
  200. package/build/module/services/currencies/entities.js +0 -1
  201. package/build/module/services/deals/entities.js +0 -1
  202. package/build/module/services/deals/index.d.ts +0 -26
  203. package/build/module/services/deals/index.integration.test.d.ts +0 -1
  204. package/build/module/services/deals/index.integration.test.js +0 -14
  205. package/build/module/services/deals/index.js +0 -8
  206. package/build/module/services/deals/index.unit.test.d.ts +0 -1
  207. package/build/module/services/deals/index.unit.test.js +0 -67
  208. package/build/module/services/deals/methods.d.ts +0 -44
  209. package/build/module/services/deals/methods.js +0 -1
  210. package/build/module/services/leads/entities.js +0 -1
  211. package/build/module/services/leads/index.d.ts +0 -26
  212. package/build/module/services/leads/index.integration.test.d.ts +0 -1
  213. package/build/module/services/leads/index.integration.test.js +0 -14
  214. package/build/module/services/leads/index.js +0 -8
  215. package/build/module/services/leads/index.unit.test.d.ts +0 -1
  216. package/build/module/services/leads/index.unit.test.js +0 -67
  217. package/build/module/services/leads/methods.d.ts +0 -44
  218. package/build/module/services/leads/methods.js +0 -1
  219. package/build/module/services/statuses/entities.d.ts +0 -16
  220. package/build/module/services/statuses/entities.js +0 -1
  221. package/build/module/services/statuses/index.d.ts +0 -14
  222. package/build/module/services/statuses/index.integration.test.d.ts +0 -1
  223. package/build/module/services/statuses/index.integration.test.js +0 -85
  224. package/build/module/services/statuses/index.js +0 -9
  225. package/build/module/services/statuses/index.unit.test.d.ts +0 -1
  226. package/build/module/services/statuses/index.unit.test.js +0 -55
  227. package/build/module/services/statuses/methods.d.ts +0 -51
  228. package/build/module/services/statuses/methods.js +0 -1
  229. package/build/module/services/users/entities.js +0 -1
  230. package/build/module/services/users/index.d.ts +0 -9
  231. package/build/module/services/users/index.integration.test.d.ts +0 -1
  232. package/build/module/services/users/index.integration.test.js +0 -28
  233. package/build/module/services/users/index.js +0 -5
  234. package/build/module/services/users/index.unit.test.d.ts +0 -1
  235. package/build/module/services/users/index.unit.test.js +0 -20
  236. package/build/module/services/users/methods.d.ts +0 -17
  237. package/build/module/services/users/methods.js +0 -1
  238. package/build/module/utils/Diff.d.ts +0 -1
  239. package/build/module/utils/Diff.js +0 -1
  240. package/build/module/utils/ExtractValue.js +0 -1
  241. package/build/module/utils/isArray.d.ts +0 -2
  242. /package/build/{main/client → client}/hooks/addAccessToken.d.ts +0 -0
@@ -1,26 +0,0 @@
1
- import { Call } from '../../client/methods/call';
2
- import { List } from '../../client/methods/list';
3
- import { Method, MethodParams } from '../../methods';
4
- declare type Dependencies = {
5
- readonly call: Call;
6
- readonly list: List;
7
- };
8
- declare const _default: ({ call, list }: Dependencies) => {
9
- fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
10
- create: <D extends {
11
- readonly fields: Partial<import("./entities").Deal>;
12
- readonly params?: {
13
- readonly REGISTER_SONET_EVENT: "Y" | "N";
14
- } | undefined;
15
- }>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("../../payloads").GetPayload<number>>;
16
- get: (id: string) => Promise<import("../../payloads").GetPayload<import("./entities").Deal>>;
17
- list: (params?: MethodParams<Method.CRM_DEAL_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Deal>>;
18
- update: <D_1 extends {
19
- readonly id: string;
20
- readonly fields: Record<string, unknown>;
21
- readonly params?: {
22
- readonly REGISTER_SONET_EVENT: "Y" | "N";
23
- } | undefined;
24
- }>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("../../payloads").GetPayload<boolean>>;
25
- };
26
- export default _default;
@@ -1,14 +0,0 @@
1
- import Bitrix from './../../bitrix';
2
- const WEBHOOK_URL = process.env['WEBHOOK_URL'];
3
- if (!WEBHOOK_URL) {
4
- throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
5
- }
6
- const { deals } = Bitrix(WEBHOOK_URL);
7
- describe('Deals', () => {
8
- describe('fields', () => {
9
- it('should get all fields', async () => {
10
- const { result } = await deals.fields();
11
- expect(result).toMatchSnapshot();
12
- });
13
- });
14
- });
@@ -1,8 +0,0 @@
1
- import { Method } from '../../methods';
2
- export default ({ call, list }) => ({
3
- fields: () => call(Method.CRM_DEAL_FIELDS, {}),
4
- create: (fields, params) => call(Method.CRM_DEAL_ADD, { fields, params }),
5
- get: (id) => call(Method.CRM_DEAL_GET, { id }),
6
- list: (params = {}) => list(Method.CRM_DEAL_LIST, params),
7
- update: (id, fields, params) => call(Method.CRM_DEAL_UPDATE, { id, fields, params })
8
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,67 +0,0 @@
1
- import Deals from '.';
2
- const mockCall = jest.fn(() => Promise.resolve());
3
- const mockList = jest.fn(() => Promise.resolve());
4
- const deals = Deals({ call: mockCall, list: mockList });
5
- const ID = '77';
6
- describe('Deals', () => {
7
- beforeEach(() => {
8
- mockCall.mockClear();
9
- mockList.mockClear();
10
- });
11
- it('should expose API methods', () => {
12
- expect(deals).toMatchSnapshot();
13
- });
14
- describe('`create`', () => {
15
- it('should invoke `call`', async () => {
16
- await deals.create({
17
- COMMENTS: 'Some comment'
18
- }, {
19
- REGISTER_SONET_EVENT: 'Y'
20
- });
21
- expect(mockCall.mock.calls).toMatchSnapshot();
22
- });
23
- it('should work without optional params', async () => {
24
- await deals.create({
25
- COMMENTS: 'Some comment'
26
- });
27
- expect(mockCall.mock.calls).toMatchSnapshot();
28
- });
29
- });
30
- describe('`get`', () => {
31
- it('should invoke `call`', async () => {
32
- await deals.get(ID);
33
- expect(mockCall.mock.calls).toMatchSnapshot();
34
- });
35
- });
36
- describe('`list`', () => {
37
- it('should invoke `list`', async () => {
38
- await deals.list({
39
- start: 0,
40
- order: { COMMENTS: 'ASC' },
41
- filter: { '>PROBABILITY': 50 },
42
- select: ['*', 'UF_*']
43
- });
44
- expect(mockList.mock.calls).toMatchSnapshot();
45
- });
46
- it('should work without optional params', async () => {
47
- await deals.list();
48
- expect(mockList.mock.calls).toMatchSnapshot();
49
- });
50
- });
51
- describe('`update`', () => {
52
- it('should invoke `call`', async () => {
53
- await deals.update(ID, {
54
- COMMENTS: 'Some comment'
55
- }, {
56
- REGISTER_SONET_EVENT: 'Y'
57
- });
58
- expect(mockCall.mock.calls).toMatchSnapshot();
59
- });
60
- it('should work without optional params', async () => {
61
- await deals.update(ID, {
62
- COMMENTS: 'Some comment'
63
- });
64
- expect(mockCall.mock.calls).toMatchSnapshot();
65
- });
66
- });
67
- });
@@ -1,44 +0,0 @@
1
- import { ListParams, Method } from '../../methods';
2
- import { GetPayload, ListPayload } from '../../payloads';
3
- import { Fields } from '../common';
4
- import { Deal } from './entities';
5
- export declare type DealsMethods = {
6
- readonly [Method.CRM_DEAL_FIELDS]: {
7
- readonly type: Deal;
8
- readonly payload: GetPayload<Fields>;
9
- readonly params?: Record<string, unknown>;
10
- };
11
- readonly [Method.CRM_DEAL_ADD]: {
12
- readonly type: Deal;
13
- readonly payload: GetPayload<number>;
14
- readonly params: {
15
- readonly fields: Partial<Deal>;
16
- readonly params?: {
17
- readonly REGISTER_SONET_EVENT: 'Y' | 'N';
18
- };
19
- };
20
- };
21
- readonly [Method.CRM_DEAL_GET]: {
22
- readonly type: Deal;
23
- readonly payload: GetPayload<Deal>;
24
- readonly params: {
25
- readonly id: string;
26
- };
27
- };
28
- readonly [Method.CRM_DEAL_LIST]: {
29
- readonly type: Deal;
30
- readonly payload: ListPayload<Deal>;
31
- readonly params: ListParams;
32
- };
33
- readonly [Method.CRM_DEAL_UPDATE]: {
34
- readonly type: Deal;
35
- readonly payload: GetPayload<boolean>;
36
- readonly params: {
37
- readonly id: string;
38
- readonly fields: Record<string, unknown>;
39
- readonly params?: {
40
- readonly REGISTER_SONET_EVENT: 'Y' | 'N';
41
- };
42
- };
43
- };
44
- };
@@ -1 +0,0 @@
1
- import { Method } from '../../methods';
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { Call } from '../../client/methods/call';
2
- import { List } from '../../client/methods/list';
3
- import { Method, MethodParams } from '../../methods';
4
- declare type Dependencies = {
5
- readonly call: Call;
6
- readonly list: List;
7
- };
8
- declare const _default: ({ call, list }: Dependencies) => {
9
- fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
10
- create: <D extends {
11
- readonly fields: Partial<import("./entities").Lead>;
12
- readonly params?: {
13
- readonly REGISTER_SONET_EVENT: "Y" | "N";
14
- } | undefined;
15
- }>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("../../payloads").GetPayload<number>>;
16
- get: (id: string) => Promise<import("../../payloads").GetPayload<import("./entities").Lead>>;
17
- list: (params?: MethodParams<Method.CRM_LEAD_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Lead>>;
18
- update: <D_1 extends {
19
- readonly id: string;
20
- readonly fields: Record<string, unknown>;
21
- readonly params?: {
22
- readonly REGISTER_SONET_EVENT: "Y" | "N";
23
- } | undefined;
24
- }>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("../../payloads").GetPayload<boolean>>;
25
- };
26
- export default _default;
@@ -1,14 +0,0 @@
1
- import Bitrix from './../../bitrix';
2
- const WEBHOOK_URL = process.env['WEBHOOK_URL'];
3
- if (!WEBHOOK_URL) {
4
- throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
5
- }
6
- const { leads } = Bitrix(WEBHOOK_URL);
7
- describe('Leads', () => {
8
- describe('fields', () => {
9
- it('should get all fields', async () => {
10
- const { result } = await leads.fields();
11
- expect(result).toMatchSnapshot();
12
- });
13
- });
14
- });
@@ -1,8 +0,0 @@
1
- import { Method } from '../../methods';
2
- export default ({ call, list }) => ({
3
- fields: () => call(Method.CRM_LEAD_FIELDS, {}),
4
- create: (fields, params) => call(Method.CRM_LEAD_ADD, { fields, params }),
5
- get: (id) => call(Method.CRM_LEAD_GET, { id }),
6
- list: (params = {}) => list(Method.CRM_LEAD_LIST, params),
7
- update: (id, fields, params) => call(Method.CRM_LEAD_UPDATE, { id, fields, params })
8
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,67 +0,0 @@
1
- import Leads from '.';
2
- const mockCall = jest.fn(() => Promise.resolve());
3
- const mockList = jest.fn(() => Promise.resolve());
4
- const leads = Leads({ call: mockCall, list: mockList });
5
- const ID = '77';
6
- describe('Leads', () => {
7
- beforeEach(() => {
8
- mockCall.mockClear();
9
- mockList.mockClear();
10
- });
11
- it('should expose API methods', () => {
12
- expect(leads).toMatchSnapshot();
13
- });
14
- describe('`create`', () => {
15
- it('should invoke `call`', async () => {
16
- await leads.create({
17
- COMMENTS: 'Some comment'
18
- }, {
19
- REGISTER_SONET_EVENT: 'Y'
20
- });
21
- expect(mockCall.mock.calls).toMatchSnapshot();
22
- });
23
- it('should work without optional params', async () => {
24
- await leads.create({
25
- COMMENTS: 'Some comment'
26
- });
27
- expect(mockCall.mock.calls).toMatchSnapshot();
28
- });
29
- });
30
- describe('`get`', () => {
31
- it('should invoke `call`', async () => {
32
- await leads.get(ID);
33
- expect(mockCall.mock.calls).toMatchSnapshot();
34
- });
35
- });
36
- describe('`list`', () => {
37
- it('should invoke `list`', async () => {
38
- await leads.list({
39
- start: 0,
40
- order: { COMMENTS: 'ASC' },
41
- filter: { '>PROBABILITY': 50 },
42
- select: ['*', 'UF_*']
43
- });
44
- expect(mockList.mock.calls).toMatchSnapshot();
45
- });
46
- it('should work without optional params', async () => {
47
- await leads.list();
48
- expect(mockList.mock.calls).toMatchSnapshot();
49
- });
50
- });
51
- describe('`update`', () => {
52
- it('should invoke `call`', async () => {
53
- await leads.update(ID, {
54
- COMMENTS: 'Some comment'
55
- }, {
56
- REGISTER_SONET_EVENT: 'Y'
57
- });
58
- expect(mockCall.mock.calls).toMatchSnapshot();
59
- });
60
- it('should work without optional params', async () => {
61
- await leads.update(ID, {
62
- COMMENTS: 'Some comment'
63
- });
64
- expect(mockCall.mock.calls).toMatchSnapshot();
65
- });
66
- });
67
- });
@@ -1,44 +0,0 @@
1
- import { ListParams, Method } from '../../methods';
2
- import { GetPayload, ListPayload } from '../../payloads';
3
- import { Fields } from '../common';
4
- import { Lead } from './entities';
5
- export declare type LeadsMethods = {
6
- readonly [Method.CRM_LEAD_FIELDS]: {
7
- readonly type: Lead;
8
- readonly payload: GetPayload<Fields>;
9
- readonly params?: Record<string, unknown>;
10
- };
11
- readonly [Method.CRM_LEAD_ADD]: {
12
- readonly type: Lead;
13
- readonly payload: GetPayload<number>;
14
- readonly params: {
15
- readonly fields: Partial<Lead>;
16
- readonly params?: {
17
- readonly REGISTER_SONET_EVENT: 'Y' | 'N';
18
- };
19
- };
20
- };
21
- readonly [Method.CRM_LEAD_GET]: {
22
- readonly type: Lead;
23
- readonly payload: GetPayload<Lead>;
24
- readonly params: {
25
- readonly id: string;
26
- };
27
- };
28
- readonly [Method.CRM_LEAD_LIST]: {
29
- readonly type: Lead;
30
- readonly payload: ListPayload<Lead>;
31
- readonly params: ListParams;
32
- };
33
- readonly [Method.CRM_LEAD_UPDATE]: {
34
- readonly type: Lead;
35
- readonly payload: GetPayload<boolean>;
36
- readonly params: {
37
- readonly id: string;
38
- readonly fields: Record<string, unknown>;
39
- readonly params?: {
40
- readonly REGISTER_SONET_EVENT: 'Y' | 'N';
41
- };
42
- };
43
- };
44
- };
@@ -1 +0,0 @@
1
- import { Method } from '../../methods';
@@ -1,16 +0,0 @@
1
- import { BoolString, NumberString } from '../common';
2
- export declare type Extra = {
3
- readonly SEMANTICS: string;
4
- readonly COLOR: string;
5
- };
6
- export declare type Status = {
7
- readonly [key: string]: string | Extra | undefined;
8
- readonly ID: NumberString;
9
- readonly ENTITY_ID: string;
10
- readonly STATUS_ID: NumberString;
11
- readonly NAME: string;
12
- readonly NAME_INIT: string;
13
- readonly SORT: NumberString;
14
- readonly SYSTEM: BoolString;
15
- readonly EXTRA: Extra | undefined;
16
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { Call } from '../../client/methods/call';
2
- import { Method, MethodParams } from '../../methods';
3
- declare type Dependencies = {
4
- readonly call: Call;
5
- };
6
- declare const _default: ({ call }: Dependencies) => {
7
- fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
8
- create: (fields: MethodParams<Method.CRM_STATUS_ADD>['fields']) => Promise<import("../../payloads").GetPayload<number>>;
9
- delete: (id: string | number, params?: MethodParams<Method.CRM_STATUS_DELETE>['params']) => Promise<import("../../payloads").GetPayload<boolean>>;
10
- get: (id: string | number) => Promise<import("../../payloads").GetPayload<import("./entities").Status>>;
11
- list: (params?: MethodParams<Method.CRM_STATUS_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Status>>;
12
- update: (id: string | number, fields: MethodParams<Method.CRM_STATUS_UPDATE>['fields']) => Promise<import("../../payloads").GetPayload<boolean>>;
13
- };
14
- export default _default;
@@ -1,85 +0,0 @@
1
- import Bitrix from '../../bitrix';
2
- // @ts-ignore this should be improved in a future but it works for now
3
- const isSortedAsc = (arr) => arr.slice(1).every((v, i) => arr[i] <= v);
4
- // @ts-ignore this should be improved in a future but it works for now
5
- const isSortedDesc = (arr) => arr.slice(1).every((v, i) => arr[i] >= v);
6
- const WEBHOOK_URL = process.env['WEBHOOK_URL'];
7
- if (!WEBHOOK_URL) {
8
- throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
9
- }
10
- const { statuses } = Bitrix(WEBHOOK_URL);
11
- describe('Statuses', () => {
12
- describe('fields', () => {
13
- it('should get all fields', async () => {
14
- const { result } = await statuses.fields();
15
- expect(result).toMatchSnapshot();
16
- });
17
- });
18
- describe('list', () => {
19
- it('should get all entries without optional parameters', async () => {
20
- const { result } = await statuses.list();
21
- expect(result).toMatchSnapshot();
22
- });
23
- it('should return only entries with ENTITY_ID = STATUS sorted in ascending order', async () => {
24
- const { result } = await statuses.list({
25
- order: { SORT: 'ASC' },
26
- filter: { ENTITY_ID: 'STATUS' }
27
- });
28
- expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
29
- expect(isSortedAsc(result.map((s) => s.SORT))).toBeTruthy();
30
- expect(result).toMatchSnapshot();
31
- });
32
- it('should return only entries with ENTITY_ID = STATUS sorted in descending order', async () => {
33
- const { result } = await statuses.list({
34
- order: { SORT: 'DESC' },
35
- filter: { ENTITY_ID: 'STATUS' }
36
- });
37
- expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
38
- expect(isSortedDesc(result.map((s) => s.SORT))).toBeTruthy();
39
- expect(result).toMatchSnapshot();
40
- });
41
- });
42
- describe('get', () => {
43
- it('should get entry with ID = 1', async () => {
44
- const { result } = await statuses.get('1');
45
- expect(result).toMatchSnapshot();
46
- });
47
- it('should return an error in case non existent ID is requested', async () => {
48
- const get = statuses.get('1001');
49
- await expect(get).rejects.toThrow(Error);
50
- });
51
- });
52
- describe('create', () => {
53
- it('should create an entry', async () => {
54
- const entry = {
55
- ENTITY_ID: 'STATUS',
56
- STATUS_ID: 'TEST',
57
- NAME: 'TEST'
58
- };
59
- const { result: id } = await statuses.create(entry);
60
- expect(id).toBeGreaterThan(0);
61
- const { result: status } = await statuses.get(id);
62
- expect(status).toMatchSnapshot({
63
- ID: expect.any(String)
64
- });
65
- const { result: deleteResult } = await statuses.delete(id);
66
- expect(deleteResult).toBeTruthy();
67
- });
68
- });
69
- describe('update', () => {
70
- it('should update an entry', async () => {
71
- const STATUS_ID = 101;
72
- const { result: status } = await statuses.get(STATUS_ID);
73
- expect(status).toMatchSnapshot();
74
- const { result: updateResult } = await statuses.update(STATUS_ID, {
75
- ...status,
76
- NAME: 'CHANGED'
77
- });
78
- expect(updateResult).toBeTruthy();
79
- const { result: updatedStatus } = await statuses.get(STATUS_ID);
80
- expect(updatedStatus).toMatchSnapshot();
81
- const { result: rollbackResult } = await statuses.update(STATUS_ID, status);
82
- expect(rollbackResult).toBeTruthy();
83
- });
84
- });
85
- });
@@ -1,9 +0,0 @@
1
- import { Method } from '../../methods';
2
- export default ({ call }) => ({
3
- fields: () => call(Method.CRM_STATUS_FIELDS, {}),
4
- create: (fields) => call(Method.CRM_STATUS_ADD, { fields }),
5
- delete: (id, params = {}) => call(Method.CRM_STATUS_DELETE, { id, params }),
6
- get: (id) => call(Method.CRM_STATUS_GET, { id }),
7
- list: (params = {}) => call(Method.CRM_STATUS_LIST, params),
8
- update: (id, fields) => call(Method.CRM_STATUS_UPDATE, { id, fields })
9
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,55 +0,0 @@
1
- import Statuses from '.';
2
- const mockCall = jest.fn(() => Promise.resolve());
3
- const mockList = jest.fn(() => Promise.resolve());
4
- const statuses = Statuses({ call: mockCall });
5
- const ID = '77';
6
- describe('Statuses', () => {
7
- beforeEach(() => {
8
- mockCall.mockClear();
9
- mockList.mockClear();
10
- });
11
- it('should expose API methods', () => {
12
- expect(statuses).toMatchSnapshot();
13
- });
14
- describe('`create`', () => {
15
- it('should invoke `call`', async () => {
16
- await statuses.create({
17
- NAME: 'Test name'
18
- });
19
- expect(mockCall.mock.calls).toMatchSnapshot();
20
- });
21
- });
22
- describe('`get`', () => {
23
- it('should invoke `call`', async () => {
24
- await statuses.get(ID);
25
- expect(mockCall.mock.calls).toMatchSnapshot();
26
- });
27
- });
28
- describe('`list`', () => {
29
- it('should invoke `call`', async () => {
30
- await statuses.list({
31
- order: { NAME: 'ASC' },
32
- filter: { ENTITY_ID: 'STATUS' }
33
- });
34
- expect(mockCall.mock.calls).toMatchSnapshot();
35
- });
36
- it('should work without optional params', async () => {
37
- await statuses.list();
38
- expect(mockCall.mock.calls).toMatchSnapshot();
39
- });
40
- });
41
- describe('`update`', () => {
42
- it('should invoke `call`', async () => {
43
- await statuses.update(ID, {
44
- NAME: 'Test name'
45
- });
46
- expect(mockCall.mock.calls).toMatchSnapshot();
47
- });
48
- it('should work without optional params', async () => {
49
- await statuses.update(ID, {
50
- NAME: 'Test name'
51
- });
52
- expect(mockCall.mock.calls).toMatchSnapshot();
53
- });
54
- });
55
- });
@@ -1,51 +0,0 @@
1
- import { Method } from '../../methods';
2
- import { GetPayload, ListPayload } from '../../payloads';
3
- import { Fields } from '../common';
4
- import { Status } from './entities';
5
- export declare type StatusesMethods = {
6
- readonly [Method.CRM_STATUS_FIELDS]: {
7
- readonly type: Status;
8
- readonly payload: GetPayload<Fields>;
9
- readonly params?: Record<string, unknown>;
10
- };
11
- readonly [Method.CRM_STATUS_ADD]: {
12
- readonly type: Status;
13
- readonly payload: GetPayload<number>;
14
- readonly params: {
15
- readonly fields: Partial<Status>;
16
- };
17
- };
18
- readonly [Method.CRM_STATUS_DELETE]: {
19
- readonly type: Status;
20
- readonly payload: GetPayload<boolean>;
21
- readonly params: {
22
- readonly id: string | number;
23
- readonly params?: {
24
- readonly FORCED?: 'Y' | 'N';
25
- };
26
- };
27
- };
28
- readonly [Method.CRM_STATUS_GET]: {
29
- readonly type: Status;
30
- readonly payload: GetPayload<Status>;
31
- readonly params: {
32
- readonly id: string | number;
33
- };
34
- };
35
- readonly [Method.CRM_STATUS_LIST]: {
36
- readonly type: Status;
37
- readonly payload: ListPayload<Status>;
38
- readonly params: {
39
- readonly order?: Record<string, unknown>;
40
- readonly filter?: Record<string, unknown>;
41
- };
42
- };
43
- readonly [Method.CRM_STATUS_UPDATE]: {
44
- readonly type: Status;
45
- readonly payload: GetPayload<boolean>;
46
- readonly params: {
47
- readonly id: string | number;
48
- readonly fields: Record<string, unknown>;
49
- };
50
- };
51
- };
@@ -1 +0,0 @@
1
- import { Method } from '../../methods';
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { Call } from '../../client/methods/call';
2
- declare type Dependencies = {
3
- readonly call: Call;
4
- };
5
- declare const _default: ({ call }: Dependencies) => {
6
- fields: () => Promise<import("../../payloads").GetPayload<import("./entities").User>>;
7
- get: (id?: string) => Promise<import("../../payloads").GetPayload<readonly import("./entities").User[]>>;
8
- };
9
- export default _default;
@@ -1,28 +0,0 @@
1
- import Bitrix from './../../bitrix';
2
- const WEBHOOK_URL = process.env['WEBHOOK_URL'];
3
- if (!WEBHOOK_URL) {
4
- throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
5
- }
6
- const { users } = Bitrix(WEBHOOK_URL);
7
- describe('Users', () => {
8
- describe('fields', () => {
9
- it('should get all fields', async () => {
10
- const { result } = await users.fields();
11
- expect(result).toMatchSnapshot();
12
- });
13
- });
14
- describe('get', () => {
15
- it('should get all users', async () => {
16
- const { result } = await users.get();
17
- expect(result).toMatchSnapshot();
18
- });
19
- it('should get entry with ID = 1', async () => {
20
- const { result } = await users.get('1');
21
- expect(result).toMatchSnapshot();
22
- });
23
- it('should return an error in case non existent ID is requested', async () => {
24
- const { result } = await users.get('1001');
25
- expect(result).toEqual([]);
26
- });
27
- });
28
- });
@@ -1,5 +0,0 @@
1
- import { Method } from '../../methods';
2
- export default ({ call }) => ({
3
- fields: () => call(Method.USER_FIELDS, {}),
4
- get: (id) => call(Method.USER_GET, { id })
5
- });
@@ -1 +0,0 @@
1
- export {};