@2bad/bitrix 2.4.0 → 2.5.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.
- package/LICENSE +0 -0
- package/README.md +54 -49
- package/build/main/bitrix.d.ts +10 -2
- package/build/main/bitrix.integration.test.d.ts +0 -0
- package/build/main/bitrix.integration.test.js +31 -0
- package/build/main/bitrix.js +24 -10
- package/build/main/bitrix.unit.test.d.ts +1 -0
- package/build/main/bitrix.unit.test.js +44 -0
- package/build/main/client/client.unit.test.d.ts +1 -0
- package/build/main/client/client.unit.test.js +70 -0
- package/build/main/client/hooks/addAccessToken.d.ts +4 -1
- package/build/main/client/hooks/addAccessToken.js +3 -1
- package/build/main/client/hooks/addAccessToken.unit.test.d.ts +1 -0
- package/build/main/client/hooks/addAccessToken.unit.test.js +31 -0
- package/build/main/client/index.d.ts +9 -1
- package/build/main/client/index.js +17 -6
- package/build/main/client/methods/batch.d.ts +19 -0
- package/build/main/client/methods/batch.js +35 -10
- package/build/main/client/methods/batch.unit.test.d.ts +1 -0
- package/build/main/client/methods/batch.unit.test.js +494 -0
- package/build/main/client/methods/call.d.ts +7 -0
- package/build/main/client/methods/call.js +11 -4
- package/build/main/client/methods/call.unit.test.d.ts +1 -0
- package/build/main/client/methods/call.unit.test.js +183 -0
- package/build/main/client/methods/list.d.ts +12 -0
- package/build/main/client/methods/list.js +23 -7
- package/build/main/client/methods/list.unit.test.d.ts +1 -0
- package/build/main/client/methods/list.unit.test.js +277 -0
- package/build/main/commands.js +0 -1
- package/build/main/methods.d.ts +19 -0
- package/build/main/methods.js +0 -1
- package/build/main/payloads.js +0 -1
- package/build/main/services/common.d.ts +1 -0
- package/build/main/services/common.js +0 -1
- package/build/main/services/companies/entities.js +0 -1
- package/build/main/services/companies/index.integration.test.d.ts +1 -0
- package/build/main/services/companies/index.integration.test.js +19 -0
- package/build/main/services/companies/index.js +0 -1
- package/build/main/services/companies/index.unit.test.d.ts +1 -0
- package/build/main/services/companies/index.unit.test.js +72 -0
- package/build/main/services/companies/methods.js +0 -1
- package/build/main/services/contacts/entities.d.ts +2 -2
- package/build/main/services/contacts/entities.js +0 -1
- package/build/main/services/contacts/index.integration.test.d.ts +1 -0
- package/build/main/services/contacts/index.integration.test.js +19 -0
- package/build/main/services/contacts/index.js +0 -1
- package/build/main/services/contacts/index.unit.test.d.ts +1 -0
- package/build/main/services/contacts/index.unit.test.js +72 -0
- package/build/main/services/contacts/methods.js +0 -1
- package/build/main/services/currencies/entities.js +0 -1
- package/build/main/services/deals/entities.js +0 -1
- package/build/main/services/deals/index.integration.test.d.ts +1 -0
- package/build/main/services/deals/index.integration.test.js +19 -0
- package/build/main/services/deals/index.js +0 -1
- package/build/main/services/deals/index.unit.test.d.ts +1 -0
- package/build/main/services/deals/index.unit.test.js +72 -0
- package/build/main/services/deals/methods.js +0 -1
- package/build/main/services/leads/entities.js +0 -1
- package/build/main/services/leads/index.integration.test.d.ts +1 -0
- package/build/main/services/leads/index.integration.test.js +19 -0
- package/build/main/services/leads/index.js +0 -1
- package/build/main/services/leads/index.unit.test.d.ts +1 -0
- package/build/main/services/leads/index.unit.test.js +72 -0
- package/build/main/services/leads/methods.js +0 -1
- package/build/main/services/statuses/entities.js +0 -1
- package/build/main/services/statuses/index.integration.test.d.ts +1 -0
- package/build/main/services/statuses/index.integration.test.js +90 -0
- package/build/main/services/statuses/index.js +0 -1
- package/build/main/services/statuses/index.unit.test.d.ts +1 -0
- package/build/main/services/statuses/index.unit.test.js +60 -0
- package/build/main/services/statuses/methods.js +0 -1
- package/build/main/services/users/entities.js +0 -1
- package/build/main/services/users/index.d.ts +1 -1
- package/build/main/services/users/index.integration.test.d.ts +1 -0
- package/build/main/services/users/index.integration.test.js +33 -0
- package/build/main/services/users/index.js +0 -1
- package/build/main/services/users/index.unit.test.d.ts +1 -0
- package/build/main/services/users/index.unit.test.js +25 -0
- package/build/main/services/users/methods.js +0 -1
- package/build/main/utils/Diff.js +0 -1
- package/build/main/utils/ExtractValue.d.ts +5 -0
- package/build/main/utils/ExtractValue.js +0 -1
- package/build/main/utils/isArray.js +1 -1
- package/build/module/bitrix.d.ts +10 -2
- package/build/module/bitrix.integration.test.d.ts +0 -0
- package/build/module/bitrix.integration.test.js +31 -0
- package/build/module/bitrix.js +10 -2
- package/build/module/bitrix.unit.test.d.ts +1 -0
- package/build/module/bitrix.unit.test.js +16 -0
- package/build/module/client/client.unit.test.d.ts +1 -0
- package/build/module/client/client.unit.test.js +65 -0
- package/build/module/client/hooks/addAccessToken.d.ts +4 -1
- package/build/module/client/hooks/addAccessToken.js +3 -1
- package/build/module/client/hooks/addAccessToken.unit.test.d.ts +1 -0
- package/build/module/client/hooks/addAccessToken.unit.test.js +26 -0
- package/build/module/client/index.d.ts +9 -1
- package/build/module/client/index.js +14 -3
- package/build/module/client/methods/batch.d.ts +19 -0
- package/build/module/client/methods/batch.js +26 -1
- package/build/module/client/methods/batch.unit.test.d.ts +1 -0
- package/build/module/client/methods/batch.unit.test.js +466 -0
- package/build/module/client/methods/call.d.ts +7 -0
- package/build/module/client/methods/call.js +9 -3
- package/build/module/client/methods/call.unit.test.d.ts +1 -0
- package/build/module/client/methods/call.unit.test.js +155 -0
- package/build/module/client/methods/list.d.ts +12 -0
- package/build/module/client/methods/list.js +20 -6
- package/build/module/client/methods/list.unit.test.d.ts +1 -0
- package/build/module/client/methods/list.unit.test.js +252 -0
- package/build/module/commands.js +0 -1
- package/build/module/methods.d.ts +19 -0
- package/build/module/methods.js +0 -1
- package/build/module/payloads.js +0 -1
- package/build/module/services/common.d.ts +1 -0
- package/build/module/services/common.js +0 -1
- package/build/module/services/companies/entities.js +0 -1
- package/build/module/services/companies/index.integration.test.d.ts +1 -0
- package/build/module/services/companies/index.integration.test.js +14 -0
- package/build/module/services/companies/index.js +0 -1
- package/build/module/services/companies/index.unit.test.d.ts +1 -0
- package/build/module/services/companies/index.unit.test.js +67 -0
- package/build/module/services/companies/methods.js +0 -1
- package/build/module/services/contacts/entities.d.ts +2 -2
- package/build/module/services/contacts/entities.js +0 -1
- package/build/module/services/contacts/index.integration.test.d.ts +1 -0
- package/build/module/services/contacts/index.integration.test.js +14 -0
- package/build/module/services/contacts/index.js +0 -1
- package/build/module/services/contacts/index.unit.test.d.ts +1 -0
- package/build/module/services/contacts/index.unit.test.js +67 -0
- package/build/module/services/contacts/methods.js +0 -1
- package/build/module/services/currencies/entities.js +0 -1
- package/build/module/services/deals/entities.js +0 -1
- package/build/module/services/deals/index.integration.test.d.ts +1 -0
- package/build/module/services/deals/index.integration.test.js +14 -0
- package/build/module/services/deals/index.js +0 -1
- package/build/module/services/deals/index.unit.test.d.ts +1 -0
- package/build/module/services/deals/index.unit.test.js +67 -0
- package/build/module/services/deals/methods.js +0 -1
- package/build/module/services/leads/entities.js +0 -1
- package/build/module/services/leads/index.integration.test.d.ts +1 -0
- package/build/module/services/leads/index.integration.test.js +14 -0
- package/build/module/services/leads/index.js +0 -1
- package/build/module/services/leads/index.unit.test.d.ts +1 -0
- package/build/module/services/leads/index.unit.test.js +67 -0
- package/build/module/services/leads/methods.js +0 -1
- package/build/module/services/statuses/entities.js +0 -1
- package/build/module/services/statuses/index.integration.test.d.ts +1 -0
- package/build/module/services/statuses/index.integration.test.js +85 -0
- package/build/module/services/statuses/index.js +0 -1
- package/build/module/services/statuses/index.unit.test.d.ts +1 -0
- package/build/module/services/statuses/index.unit.test.js +55 -0
- package/build/module/services/statuses/methods.js +0 -1
- package/build/module/services/users/entities.js +0 -1
- package/build/module/services/users/index.d.ts +1 -1
- package/build/module/services/users/index.integration.test.d.ts +1 -0
- package/build/module/services/users/index.integration.test.js +28 -0
- package/build/module/services/users/index.js +0 -1
- package/build/module/services/users/index.unit.test.d.ts +1 -0
- package/build/module/services/users/index.unit.test.js +20 -0
- package/build/module/services/users/methods.js +0 -1
- package/build/module/utils/Diff.js +0 -1
- package/build/module/utils/ExtractValue.d.ts +5 -0
- package/build/module/utils/ExtractValue.js +0 -1
- package/build/module/utils/isArray.js +1 -1
- package/package.json +21 -22
- package/build/main/bitrix.js.map +0 -1
- package/build/main/client/hooks/addAccessToken.js.map +0 -1
- package/build/main/client/index.js.map +0 -1
- package/build/main/client/methods/batch.js.map +0 -1
- package/build/main/client/methods/call.js.map +0 -1
- package/build/main/client/methods/list.js.map +0 -1
- package/build/main/commands.js.map +0 -1
- package/build/main/methods.js.map +0 -1
- package/build/main/payloads.js.map +0 -1
- package/build/main/services/common.js.map +0 -1
- package/build/main/services/companies/entities.js.map +0 -1
- package/build/main/services/companies/index.js.map +0 -1
- package/build/main/services/companies/methods.js.map +0 -1
- package/build/main/services/contacts/entities.js.map +0 -1
- package/build/main/services/contacts/index.js.map +0 -1
- package/build/main/services/contacts/methods.js.map +0 -1
- package/build/main/services/currencies/entities.js.map +0 -1
- package/build/main/services/deals/entities.js.map +0 -1
- package/build/main/services/deals/index.js.map +0 -1
- package/build/main/services/deals/methods.js.map +0 -1
- package/build/main/services/leads/entities.js.map +0 -1
- package/build/main/services/leads/index.js.map +0 -1
- package/build/main/services/leads/methods.js.map +0 -1
- package/build/main/services/statuses/entities.js.map +0 -1
- package/build/main/services/statuses/index.js.map +0 -1
- package/build/main/services/statuses/methods.js.map +0 -1
- package/build/main/services/users/entities.js.map +0 -1
- package/build/main/services/users/index.js.map +0 -1
- package/build/main/services/users/methods.js.map +0 -1
- package/build/main/utils/Diff.js.map +0 -1
- package/build/main/utils/ExtractValue.js.map +0 -1
- package/build/main/utils/isArray.js.map +0 -1
- package/build/module/bitrix.js.map +0 -1
- package/build/module/client/hooks/addAccessToken.js.map +0 -1
- package/build/module/client/index.js.map +0 -1
- package/build/module/client/methods/batch.js.map +0 -1
- package/build/module/client/methods/call.js.map +0 -1
- package/build/module/client/methods/list.js.map +0 -1
- package/build/module/commands.js.map +0 -1
- package/build/module/methods.js.map +0 -1
- package/build/module/payloads.js.map +0 -1
- package/build/module/services/common.js.map +0 -1
- package/build/module/services/companies/entities.js.map +0 -1
- package/build/module/services/companies/index.js.map +0 -1
- package/build/module/services/companies/methods.js.map +0 -1
- package/build/module/services/contacts/entities.js.map +0 -1
- package/build/module/services/contacts/index.js.map +0 -1
- package/build/module/services/contacts/methods.js.map +0 -1
- package/build/module/services/currencies/entities.js.map +0 -1
- package/build/module/services/deals/entities.js.map +0 -1
- package/build/module/services/deals/index.js.map +0 -1
- package/build/module/services/deals/methods.js.map +0 -1
- package/build/module/services/leads/entities.js.map +0 -1
- package/build/module/services/leads/index.js.map +0 -1
- package/build/module/services/leads/methods.js.map +0 -1
- package/build/module/services/statuses/entities.js.map +0 -1
- package/build/module/services/statuses/index.js.map +0 -1
- package/build/module/services/statuses/methods.js.map +0 -1
- package/build/module/services/users/entities.js.map +0 -1
- package/build/module/services/users/index.js.map +0 -1
- package/build/module/services/users/methods.js.map +0 -1
- package/build/module/utils/Diff.js.map +0 -1
- package/build/module/utils/ExtractValue.js.map +0 -1
- package/build/module/utils/isArray.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const got_1 = __importDefault(require("got"));
|
|
30
|
+
const nock_1 = __importDefault(require("nock"));
|
|
31
|
+
const methods_1 = require("../../methods");
|
|
32
|
+
const call_1 = __importStar(require("./call"));
|
|
33
|
+
const TEST_URI = 'https://test.com/rest';
|
|
34
|
+
const call = (0, call_1.default)({
|
|
35
|
+
get: got_1.default.extend({ prefixUrl: TEST_URI, responseType: 'json' }).get
|
|
36
|
+
});
|
|
37
|
+
const RESPONSE_200 = 200;
|
|
38
|
+
describe('Client `handlePayload` method', () => {
|
|
39
|
+
it('should return `GetPayload`', () => {
|
|
40
|
+
const payload = {
|
|
41
|
+
result: 'done',
|
|
42
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
43
|
+
};
|
|
44
|
+
expect((0, call_1.handlePayload)(payload)).toBe(payload);
|
|
45
|
+
});
|
|
46
|
+
it('should return `ListPayload`', () => {
|
|
47
|
+
const payload = {
|
|
48
|
+
error: undefined,
|
|
49
|
+
next: undefined,
|
|
50
|
+
result: ['done'],
|
|
51
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' },
|
|
52
|
+
total: 1
|
|
53
|
+
};
|
|
54
|
+
expect((0, call_1.handlePayload)(payload)).toBe(payload);
|
|
55
|
+
});
|
|
56
|
+
it('should throw when getting error in `ListPayload`', () => {
|
|
57
|
+
const payload = {
|
|
58
|
+
error: 'Expected error for `handlePayload`',
|
|
59
|
+
next: undefined,
|
|
60
|
+
result: ['done'],
|
|
61
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' },
|
|
62
|
+
total: 1
|
|
63
|
+
};
|
|
64
|
+
expect(() => (0, call_1.handlePayload)(payload)).toThrowErrorMatchingSnapshot();
|
|
65
|
+
});
|
|
66
|
+
it('should return `BatchPayload` with numbered commands', () => {
|
|
67
|
+
const payload = {
|
|
68
|
+
result: {
|
|
69
|
+
result: { one: 'done' },
|
|
70
|
+
result_error: [],
|
|
71
|
+
result_next: [],
|
|
72
|
+
result_time: [],
|
|
73
|
+
result_total: []
|
|
74
|
+
},
|
|
75
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
76
|
+
};
|
|
77
|
+
expect((0, call_1.handlePayload)(payload)).toBe(payload);
|
|
78
|
+
});
|
|
79
|
+
it('should return `BatchPayload` with result from array of commands', () => {
|
|
80
|
+
const payload = {
|
|
81
|
+
result: {
|
|
82
|
+
result: ['done'],
|
|
83
|
+
result_error: [],
|
|
84
|
+
result_next: [],
|
|
85
|
+
result_time: [],
|
|
86
|
+
result_total: []
|
|
87
|
+
},
|
|
88
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
89
|
+
};
|
|
90
|
+
expect((0, call_1.handlePayload)(payload)).toBe(payload);
|
|
91
|
+
});
|
|
92
|
+
it('should throw when getting errors in `BatchPayload` with result from named commands', () => {
|
|
93
|
+
const payload = {
|
|
94
|
+
result: {
|
|
95
|
+
result: { one: 'done' },
|
|
96
|
+
result_error: { one: 'Expected error for `handlePayload`' },
|
|
97
|
+
result_next: [],
|
|
98
|
+
result_time: [],
|
|
99
|
+
result_total: []
|
|
100
|
+
},
|
|
101
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
102
|
+
};
|
|
103
|
+
expect(() => (0, call_1.handlePayload)(payload)).toThrowErrorMatchingSnapshot();
|
|
104
|
+
});
|
|
105
|
+
it('should throw when getting errors in `BatchPayload` with result from array of commands', () => {
|
|
106
|
+
const payload = {
|
|
107
|
+
result: {
|
|
108
|
+
result: ['done'],
|
|
109
|
+
result_error: ['Expected error for `handlePayload`'],
|
|
110
|
+
result_next: [],
|
|
111
|
+
result_time: [],
|
|
112
|
+
result_total: []
|
|
113
|
+
},
|
|
114
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
115
|
+
};
|
|
116
|
+
expect(() => (0, call_1.handlePayload)(payload)).toThrowErrorMatchingSnapshot();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('Client `call` method', () => {
|
|
120
|
+
it('should form a proper request', async () => {
|
|
121
|
+
const params = { id: '1' };
|
|
122
|
+
const scope = (0, nock_1.default)(TEST_URI)
|
|
123
|
+
.get(`/${methods_1.Method.CRM_DEAL_GET}`)
|
|
124
|
+
.query(params)
|
|
125
|
+
.reply(RESPONSE_200);
|
|
126
|
+
await call(methods_1.Method.CRM_DEAL_GET, params);
|
|
127
|
+
expect(scope.done()).toBe(undefined);
|
|
128
|
+
});
|
|
129
|
+
it('should form a proper request with list methods', async () => {
|
|
130
|
+
const params = {
|
|
131
|
+
filter: { '>PROBABILITY': 50 },
|
|
132
|
+
order: { STAGE_ID: 'ASC' },
|
|
133
|
+
select: ['ID', 'TITLE'],
|
|
134
|
+
start: 50
|
|
135
|
+
};
|
|
136
|
+
const scope = (0, nock_1.default)(TEST_URI)
|
|
137
|
+
.get(`/${methods_1.Method.CRM_DEAL_LIST}`)
|
|
138
|
+
.query(params)
|
|
139
|
+
.reply(RESPONSE_200);
|
|
140
|
+
await call(methods_1.Method.CRM_DEAL_LIST, params);
|
|
141
|
+
expect(scope.done()).toBe(undefined);
|
|
142
|
+
});
|
|
143
|
+
it('should return body as payload', async () => {
|
|
144
|
+
const params = { id: '1' };
|
|
145
|
+
const payload = { test: 'value' };
|
|
146
|
+
(0, nock_1.default)(TEST_URI)
|
|
147
|
+
.get(`/${methods_1.Method.CRM_DEAL_GET}`)
|
|
148
|
+
.query(params)
|
|
149
|
+
.reply(RESPONSE_200, payload);
|
|
150
|
+
expect(await call(methods_1.Method.CRM_DEAL_GET, params)).toEqual(payload);
|
|
151
|
+
});
|
|
152
|
+
it('should return body as payload with list methods', async () => {
|
|
153
|
+
const payload = { result: ['done'] };
|
|
154
|
+
(0, nock_1.default)(TEST_URI)
|
|
155
|
+
.get(`/${methods_1.Method.CRM_DEAL_LIST}`)
|
|
156
|
+
.reply(RESPONSE_200, payload);
|
|
157
|
+
expect(await call(methods_1.Method.CRM_DEAL_LIST, {})).toEqual(payload);
|
|
158
|
+
});
|
|
159
|
+
it('should throw when getting errors in payload', () => {
|
|
160
|
+
const payload = { result: ['done'], error: 'Expected error for `getList`' };
|
|
161
|
+
(0, nock_1.default)(TEST_URI)
|
|
162
|
+
.get(`/${methods_1.Method.CRM_DEAL_LIST}`)
|
|
163
|
+
.reply(RESPONSE_200, payload);
|
|
164
|
+
return expect(call(methods_1.Method.CRM_DEAL_LIST, {})).rejects.toMatchSnapshot();
|
|
165
|
+
});
|
|
166
|
+
it('should throw when getting errors in batch payload', () => {
|
|
167
|
+
const payload = {
|
|
168
|
+
result: {
|
|
169
|
+
result: ['done'],
|
|
170
|
+
result_error: ['Expected error'],
|
|
171
|
+
result_next: [],
|
|
172
|
+
result_time: [],
|
|
173
|
+
result_total: []
|
|
174
|
+
},
|
|
175
|
+
time: { start: 1, finish: 1, duration: 1, processing: 1, date_start: 'date', date_finish: 'date' }
|
|
176
|
+
};
|
|
177
|
+
(0, nock_1.default)(TEST_URI)
|
|
178
|
+
.get(`/${methods_1.Method.BATCH}`)
|
|
179
|
+
.reply(RESPONSE_200, payload);
|
|
180
|
+
return expect(call(methods_1.Method.BATCH, {})).rejects.toMatchSnapshot();
|
|
181
|
+
});
|
|
182
|
+
it.todo('should cast payload to the <P>');
|
|
183
|
+
});
|
|
@@ -3,16 +3,28 @@ import { ListableMethod, MethodParams, MethodPayloadType } from '../../methods';
|
|
|
3
3
|
import { BatchPayload, ListPayload } from '../../payloads';
|
|
4
4
|
import { Batch } from './batch';
|
|
5
5
|
import { Call } from './call';
|
|
6
|
+
/**
|
|
7
|
+
* Generates required amount of commands to process specified amount of entries
|
|
8
|
+
*/
|
|
6
9
|
export declare const fillWithCommands: <C extends Command>({ method, params }: C, start: number, toProcess: number, entriesPerCommand: number) => readonly {
|
|
7
10
|
readonly method: C["method"];
|
|
8
11
|
readonly params?: C["params"] | undefined;
|
|
9
12
|
}[];
|
|
13
|
+
/**
|
|
14
|
+
* Get the highest value from object or an array if there's any
|
|
15
|
+
*/
|
|
10
16
|
export declare const highest: (input: ReadonlyArray<number | undefined> | Record<string, number | undefined>) => number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Converts batch payload to a list payload
|
|
19
|
+
*/
|
|
11
20
|
export declare const batchToListPayload: <P>(payload: BatchPayload<Record<string, P> | readonly P[]>) => ListPayload<P>;
|
|
12
21
|
declare type Dependencies = {
|
|
13
22
|
readonly call: Call;
|
|
14
23
|
readonly batch: Batch;
|
|
15
24
|
};
|
|
16
25
|
export declare type List = <M extends ListableMethod>(method: M, params: MethodParams<M>) => Promise<ListPayload<MethodPayloadType<M>>>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets all entries by dispatching required amount of requests. Will fill figure out payload type based on the Method.
|
|
28
|
+
*/
|
|
17
29
|
declare const _default: ({ call, batch }: Dependencies) => List;
|
|
18
30
|
export default _default;
|
|
@@ -6,12 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.batchToListPayload = exports.highest = exports.fillWithCommands = void 0;
|
|
7
7
|
const lodash_range_1 = __importDefault(require("lodash.range"));
|
|
8
8
|
const MAX_ENTRIES_PER_COMMAND = 50;
|
|
9
|
+
/**
|
|
10
|
+
* Generates required amount of commands to process specified amount of entries
|
|
11
|
+
*/
|
|
9
12
|
const fillWithCommands = ({ method, params }, start, toProcess, entriesPerCommand) => {
|
|
10
13
|
const requiresCommands = Math.ceil((toProcess - start) / entriesPerCommand);
|
|
11
|
-
return lodash_range_1.default(0, requiresCommands)
|
|
14
|
+
return (0, lodash_range_1.default)(0, requiresCommands)
|
|
12
15
|
.map((i) => ({ method, params: { ...params, start: start + (entriesPerCommand * i) } }));
|
|
13
16
|
};
|
|
14
17
|
exports.fillWithCommands = fillWithCommands;
|
|
18
|
+
/**
|
|
19
|
+
* Get the highest value from object or an array if there's any
|
|
20
|
+
*/
|
|
15
21
|
const highest = (input) => Object.values(input).reduce((a, b) => a !== undefined && b !== undefined
|
|
16
22
|
? a > b ? a : b
|
|
17
23
|
: a !== undefined && b === undefined
|
|
@@ -20,31 +26,41 @@ const highest = (input) => Object.values(input).reduce((a, b) => a !== undefined
|
|
|
20
26
|
? b
|
|
21
27
|
: undefined, undefined);
|
|
22
28
|
exports.highest = highest;
|
|
29
|
+
/**
|
|
30
|
+
* Converts batch payload to a list payload
|
|
31
|
+
*/
|
|
23
32
|
const batchToListPayload = (payload) => {
|
|
24
33
|
var _a;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
35
|
const { result: { result, result_total, result_error, result_next }, time } = payload;
|
|
26
|
-
const flattenResult = Object.entries(result).reduce(
|
|
36
|
+
const flattenResult = Object.entries(result).reduce(
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
38
|
+
// @ts-expect-error ignore this for now
|
|
39
|
+
(flatten, [_key, r]) => !r ? flatten : [...flatten, ...r], []);
|
|
27
40
|
return {
|
|
28
41
|
error: Object.values(result_error).join('\n'),
|
|
29
|
-
next: exports.highest(result_next),
|
|
42
|
+
next: (0, exports.highest)(result_next),
|
|
30
43
|
result: flattenResult,
|
|
44
|
+
// @todo Not accurate, we do not care
|
|
31
45
|
time,
|
|
32
|
-
total: (_a = exports.highest(result_total)) !== null && _a !== void 0 ? _a : 0
|
|
46
|
+
total: (_a = (0, exports.highest)(result_total)) !== null && _a !== void 0 ? _a : 0
|
|
33
47
|
};
|
|
34
48
|
};
|
|
35
49
|
exports.batchToListPayload = batchToListPayload;
|
|
50
|
+
/**
|
|
51
|
+
* Gets all entries by dispatching required amount of requests. Will fill figure out payload type based on the Method.
|
|
52
|
+
*/
|
|
36
53
|
exports.default = ({ call, batch }) => {
|
|
37
54
|
const list = async (method, params) => {
|
|
38
55
|
var _a;
|
|
39
56
|
const start = (_a = params.start) !== null && _a !== void 0 ? _a : 0;
|
|
40
57
|
const listAll = async () => {
|
|
41
|
-
const batchCommands = exports.fillWithCommands({ method, params }, start, firstCall.total, MAX_ENTRIES_PER_COMMAND);
|
|
58
|
+
const batchCommands = (0, exports.fillWithCommands)({ method, params }, start, firstCall.total, MAX_ENTRIES_PER_COMMAND);
|
|
42
59
|
const payload = await batch(batchCommands);
|
|
43
|
-
return exports.batchToListPayload(payload);
|
|
60
|
+
return (0, exports.batchToListPayload)(payload);
|
|
44
61
|
};
|
|
45
62
|
const firstCall = await call(method, { ...params, start });
|
|
46
63
|
return !firstCall.next ? firstCall : await listAll();
|
|
47
64
|
};
|
|
48
65
|
return list;
|
|
49
66
|
};
|
|
50
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const methods_1 = require("../../methods");
|
|
27
|
+
const list_1 = __importStar(require("./list"));
|
|
28
|
+
describe('Client `fillWithCommands` method', () => {
|
|
29
|
+
it('should fill array with required amount of commands to process all entries', () => {
|
|
30
|
+
const command = { method: methods_1.Method.CRM_DEAL_LIST, params: { select: ['*'] } };
|
|
31
|
+
const start = 0;
|
|
32
|
+
const toProcess = 7;
|
|
33
|
+
const entriesPerCommand = 2;
|
|
34
|
+
expect((0, list_1.fillWithCommands)(command, start, toProcess, entriesPerCommand)).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
it('should properly take into account start', () => {
|
|
37
|
+
const command = { method: methods_1.Method.CRM_DEAL_LIST, params: { select: ['*'] } };
|
|
38
|
+
const start = 2;
|
|
39
|
+
const toProcess = 7;
|
|
40
|
+
const entriesPerCommand = 2;
|
|
41
|
+
expect((0, list_1.fillWithCommands)(command, start, toProcess, entriesPerCommand)).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
it('should override `params.start`', () => {
|
|
44
|
+
const wrongStart = 99;
|
|
45
|
+
const command = { method: methods_1.Method.CRM_DEAL_LIST, params: { start: wrongStart } };
|
|
46
|
+
const start = 0;
|
|
47
|
+
const toProcess = 2;
|
|
48
|
+
const entriesPerCommand = 1;
|
|
49
|
+
const commands = (0, list_1.fillWithCommands)(command, start, toProcess, entriesPerCommand);
|
|
50
|
+
expect(Object.values(commands).map((c) => c.params)).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe('Client `highest` method', () => {
|
|
54
|
+
it('should get highest value from object', () => {
|
|
55
|
+
expect((0, list_1.highest)({ a: undefined })).toBe(undefined);
|
|
56
|
+
expect((0, list_1.highest)({ a: undefined, b: undefined })).toBe(undefined);
|
|
57
|
+
expect((0, list_1.highest)({ a: 1, b: undefined })).toBe(1);
|
|
58
|
+
expect((0, list_1.highest)({ a: undefined, b: 1 })).toBe(1);
|
|
59
|
+
expect((0, list_1.highest)({ a: 1, b: 2 })).toBe(2);
|
|
60
|
+
expect((0, list_1.highest)({ a: 2, b: 1 })).toBe(2);
|
|
61
|
+
});
|
|
62
|
+
it('should get highest value from array', () => {
|
|
63
|
+
expect((0, list_1.highest)([undefined])).toBe(undefined);
|
|
64
|
+
expect((0, list_1.highest)([undefined, undefined])).toBe(undefined);
|
|
65
|
+
expect((0, list_1.highest)([1, undefined])).toBe(1);
|
|
66
|
+
expect((0, list_1.highest)([undefined, 1])).toBe(1);
|
|
67
|
+
expect((0, list_1.highest)([1, 2])).toBe(2);
|
|
68
|
+
expect((0, list_1.highest)([2, 1])).toBe(2);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('Client `batchToListPayload` method', () => {
|
|
72
|
+
it('should convert batch with named payloads to a list payload', () => {
|
|
73
|
+
const payload = {
|
|
74
|
+
result: {
|
|
75
|
+
result: {
|
|
76
|
+
a: [{ ID: '1' }, { ID: '2' }],
|
|
77
|
+
b: [{ ID: '3' }, { ID: '4' }]
|
|
78
|
+
},
|
|
79
|
+
result_error: { a: 'Expected error A', b: 'Expected error B' },
|
|
80
|
+
result_total: { a: 4, b: 4 },
|
|
81
|
+
result_next: { a: 2, b: 4 },
|
|
82
|
+
result_time: {
|
|
83
|
+
a: {
|
|
84
|
+
start: 1567196891.008149,
|
|
85
|
+
finish: 1567196891.022234,
|
|
86
|
+
duration: 0.014085054397583008,
|
|
87
|
+
processing: 0.013998985290527344,
|
|
88
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
89
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
90
|
+
},
|
|
91
|
+
b: {
|
|
92
|
+
start: 1567196891.022316,
|
|
93
|
+
finish: 1567196891.03225,
|
|
94
|
+
duration: 0.009933948516845703,
|
|
95
|
+
processing: 0.009846210479736328,
|
|
96
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
97
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
time: {
|
|
102
|
+
start: 1567196890.959017,
|
|
103
|
+
finish: 1567196891.223739,
|
|
104
|
+
duration: 0.2647218704223633,
|
|
105
|
+
processing: 0.21567082405090332,
|
|
106
|
+
date_start: '2019-08-30T23:28:10+03:00',
|
|
107
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
expect((0, list_1.batchToListPayload)(payload)).toMatchSnapshot();
|
|
111
|
+
});
|
|
112
|
+
it('should convert batch with payload of arrays to a list payload', () => {
|
|
113
|
+
const payload = {
|
|
114
|
+
result: {
|
|
115
|
+
result: [
|
|
116
|
+
[{ ID: '1' }, { ID: '2' }],
|
|
117
|
+
[{ ID: '3' }, { ID: '4' }]
|
|
118
|
+
],
|
|
119
|
+
result_error: ['Expected error 1', 'Expected error 2'],
|
|
120
|
+
result_total: [4, 4],
|
|
121
|
+
result_next: [2, 4],
|
|
122
|
+
result_time: [{
|
|
123
|
+
start: 1567196891.008149,
|
|
124
|
+
finish: 1567196891.022234,
|
|
125
|
+
duration: 0.014085054397583008,
|
|
126
|
+
processing: 0.013998985290527344,
|
|
127
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
128
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
129
|
+
}, {
|
|
130
|
+
start: 1567196891.022316,
|
|
131
|
+
finish: 1567196891.03225,
|
|
132
|
+
duration: 0.009933948516845703,
|
|
133
|
+
processing: 0.009846210479736328,
|
|
134
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
135
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
136
|
+
}]
|
|
137
|
+
},
|
|
138
|
+
time: {
|
|
139
|
+
start: 1567196890.959017,
|
|
140
|
+
finish: 1567196891.223739,
|
|
141
|
+
duration: 0.2647218704223633,
|
|
142
|
+
processing: 0.21567082405090332,
|
|
143
|
+
date_start: '2019-08-30T23:28:10+03:00',
|
|
144
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
expect((0, list_1.batchToListPayload)(payload)).toMatchSnapshot();
|
|
148
|
+
});
|
|
149
|
+
it('should handle undefined in `result`', () => {
|
|
150
|
+
const payload = {
|
|
151
|
+
result: {
|
|
152
|
+
result: [undefined, [{ ID: '1' }], undefined],
|
|
153
|
+
result_error: [],
|
|
154
|
+
result_total: [],
|
|
155
|
+
result_next: [],
|
|
156
|
+
result_time: [{
|
|
157
|
+
start: 1567196891.008149,
|
|
158
|
+
finish: 1567196891.022234,
|
|
159
|
+
duration: 0.014085054397583008,
|
|
160
|
+
processing: 0.013998985290527344,
|
|
161
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
162
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
163
|
+
}, {
|
|
164
|
+
start: 1567196891.022316,
|
|
165
|
+
finish: 1567196891.03225,
|
|
166
|
+
duration: 0.009933948516845703,
|
|
167
|
+
processing: 0.009846210479736328,
|
|
168
|
+
date_start: '2019-08-30T23:28:11+03:00',
|
|
169
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
170
|
+
}]
|
|
171
|
+
},
|
|
172
|
+
time: {
|
|
173
|
+
start: 1567196890.959017,
|
|
174
|
+
finish: 1567196891.223739,
|
|
175
|
+
duration: 0.2647218704223633,
|
|
176
|
+
processing: 0.21567082405090332,
|
|
177
|
+
date_start: '2019-08-30T23:28:10+03:00',
|
|
178
|
+
date_finish: '2019-08-30T23:28:11+03:00'
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
expect((0, list_1.batchToListPayload)(payload)).toMatchSnapshot();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('Client `list` method', () => {
|
|
185
|
+
it('should make one request when entries can be fetched in one go', async () => {
|
|
186
|
+
const callMock = jest.fn(() => Promise.resolve({ next: false }));
|
|
187
|
+
const batchMock = jest.fn(() => Promise.resolve({}));
|
|
188
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
189
|
+
await list(methods_1.Method.CRM_DEAL_LIST, {});
|
|
190
|
+
expect(callMock.mock.calls).toMatchSnapshot();
|
|
191
|
+
expect(batchMock).not.toBeCalled();
|
|
192
|
+
});
|
|
193
|
+
it('should make multiple requests when entries can not be fetched in one go', async () => {
|
|
194
|
+
const callMock = jest.fn(() => Promise.resolve({ next: 2, total: 120 }));
|
|
195
|
+
const batchMock = jest.fn(() => Promise.resolve({
|
|
196
|
+
result: {
|
|
197
|
+
result: ['done'],
|
|
198
|
+
result_error: [],
|
|
199
|
+
result_next: [],
|
|
200
|
+
result_time: [],
|
|
201
|
+
result_total: []
|
|
202
|
+
},
|
|
203
|
+
time: {}
|
|
204
|
+
}));
|
|
205
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
206
|
+
await list(methods_1.Method.CRM_DEAL_LIST, {});
|
|
207
|
+
expect(callMock.mock.calls).toMatchSnapshot();
|
|
208
|
+
expect(batchMock.mock.calls).toMatchSnapshot();
|
|
209
|
+
});
|
|
210
|
+
it('should return a first request payload when entities can be fetched in a single request', async () => {
|
|
211
|
+
const mockPayload = { next: false, result: 'test' };
|
|
212
|
+
const callMock = jest.fn(() => Promise.resolve(mockPayload));
|
|
213
|
+
const batchMock = jest.fn(() => Promise.resolve({}));
|
|
214
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
215
|
+
const payload = await list(methods_1.Method.CRM_DEAL_LIST, {});
|
|
216
|
+
expect(payload).toEqual(mockPayload);
|
|
217
|
+
});
|
|
218
|
+
it('should return a flatten payload when entities can not be fetched in a single request', async () => {
|
|
219
|
+
const mockPayload = {
|
|
220
|
+
result: {
|
|
221
|
+
result: {
|
|
222
|
+
a: [{ ID: '1' }, { ID: '2' }],
|
|
223
|
+
b: [{ ID: '3' }, { ID: '4' }]
|
|
224
|
+
},
|
|
225
|
+
result_error: { a: 'Expected error A', b: 'Expected error B' },
|
|
226
|
+
result_total: { a: 4, b: 4 },
|
|
227
|
+
result_next: { a: 2, b: 4 },
|
|
228
|
+
result_time: {
|
|
229
|
+
a: { start: 1567196891.008149 },
|
|
230
|
+
b: { start: 1567196891.022316 }
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
time: { start: 1567196890.959017 }
|
|
234
|
+
};
|
|
235
|
+
const callMock = jest.fn(() => Promise.resolve({ next: 2 }));
|
|
236
|
+
const batchMock = jest.fn(() => Promise.resolve(mockPayload));
|
|
237
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
238
|
+
const payload = await list(methods_1.Method.CRM_DEAL_LIST, {});
|
|
239
|
+
expect(payload).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
it('should default start to 0', async () => {
|
|
242
|
+
const callMock = jest.fn(() => Promise.resolve({ next: 2, total: 20 }));
|
|
243
|
+
const batchMock = jest.fn(() => Promise.resolve({
|
|
244
|
+
result: {
|
|
245
|
+
result: ['done'],
|
|
246
|
+
result_error: [],
|
|
247
|
+
result_next: [],
|
|
248
|
+
result_time: [],
|
|
249
|
+
result_total: []
|
|
250
|
+
},
|
|
251
|
+
time: {}
|
|
252
|
+
}));
|
|
253
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
254
|
+
await list(methods_1.Method.CRM_DEAL_LIST, {});
|
|
255
|
+
expect(callMock.mock.calls[0]).toMatchSnapshot();
|
|
256
|
+
expect(batchMock.mock.calls[0]).toMatchSnapshot();
|
|
257
|
+
});
|
|
258
|
+
it('should properly take into account start', async () => {
|
|
259
|
+
const callMock = jest.fn(() => Promise.resolve({ next: 2, total: 120 }));
|
|
260
|
+
const batchMock = jest.fn(() => Promise.resolve({
|
|
261
|
+
result: {
|
|
262
|
+
result: ['done'],
|
|
263
|
+
result_error: [],
|
|
264
|
+
result_next: [],
|
|
265
|
+
result_time: [],
|
|
266
|
+
result_total: []
|
|
267
|
+
},
|
|
268
|
+
time: {}
|
|
269
|
+
}));
|
|
270
|
+
const list = (0, list_1.default)({ call: callMock, batch: batchMock });
|
|
271
|
+
await list(methods_1.Method.CRM_DEAL_LIST, { start: 27 });
|
|
272
|
+
expect(callMock.mock.calls).toMatchSnapshot();
|
|
273
|
+
expect(batchMock.mock.calls).toMatchSnapshot();
|
|
274
|
+
});
|
|
275
|
+
it.todo('should cast first request payload to the <P>');
|
|
276
|
+
it.todo('should cast payload results to the <P>');
|
|
277
|
+
});
|
package/build/main/commands.js
CHANGED
package/build/main/methods.d.ts
CHANGED
|
@@ -59,6 +59,13 @@ export declare type ListParams = {
|
|
|
59
59
|
};
|
|
60
60
|
readonly select?: readonly string[];
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* A mega map of all supported Bitrix methods to their parameters. Used to resolve
|
|
64
|
+
* low-level client method required params and payload types.
|
|
65
|
+
* - `type` — a type that method associated with
|
|
66
|
+
* - `payload` — a payload that method returns
|
|
67
|
+
* - `params` — params that method accepts
|
|
68
|
+
*/
|
|
62
69
|
export declare type Methods = MethodsMap & CompaniesMethods & ContactsMethods & DealsMethods & LeadsMethods & StatusesMethods & UsersMethods & {
|
|
63
70
|
readonly [Method.BATCH]: {
|
|
64
71
|
readonly type: unknown;
|
|
@@ -66,8 +73,20 @@ export declare type Methods = MethodsMap & CompaniesMethods & ContactsMethods &
|
|
|
66
73
|
readonly params: Commands;
|
|
67
74
|
};
|
|
68
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve specified method data
|
|
78
|
+
*/
|
|
69
79
|
export declare type MethodData<M extends Method> = ExtractValue<Methods, M>;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve associated with specified method type
|
|
82
|
+
*/
|
|
70
83
|
export declare type MethodPayloadType<M extends Method> = MethodData<M>['type'];
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve specified method payload type
|
|
86
|
+
*/
|
|
71
87
|
export declare type MethodPayload<M extends Method> = MethodData<M>['payload'];
|
|
88
|
+
/**
|
|
89
|
+
* Retrieve specified method params
|
|
90
|
+
*/
|
|
72
91
|
export declare type MethodParams<M extends Method> = MethodData<M>['params'];
|
|
73
92
|
export {};
|
package/build/main/methods.js
CHANGED
package/build/main/payloads.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
+
if (!WEBHOOK_URL) {
|
|
9
|
+
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
+
}
|
|
11
|
+
const { companies } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
+
describe('Companies', () => {
|
|
13
|
+
describe('fields', () => {
|
|
14
|
+
it('should get all fields', async () => {
|
|
15
|
+
const { result } = await companies.fields();
|
|
16
|
+
expect(result).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|