@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.
- package/README.md +53 -45
- package/build/main/bitrix.d.ts +25 -16
- package/build/main/bitrix.integration.test.js +0 -1
- package/build/main/bitrix.js +40 -13
- package/build/main/bitrix.unit.test.js +24 -9
- package/build/main/client/client.unit.test.js +13 -10
- package/build/main/client/hooks/addAccessToken.d.ts +5 -2
- package/build/main/client/hooks/addAccessToken.js +3 -1
- package/build/main/client/hooks/addAccessToken.unit.test.js +13 -12
- package/build/main/client/index.d.ts +10 -1
- package/build/main/client/index.js +23 -11
- package/build/main/client/methods/batch.d.ts +24 -5
- package/build/main/client/methods/batch.js +49 -17
- package/build/main/client/methods/batch.unit.test.js +103 -45
- package/build/main/client/methods/call.d.ts +11 -4
- package/build/main/client/methods/call.js +16 -6
- package/build/main/client/methods/call.unit.test.js +36 -21
- package/build/main/client/methods/list.d.ts +15 -3
- package/build/main/client/methods/list.js +36 -14
- package/build/main/client/methods/list.unit.test.js +42 -27
- package/build/main/commands.d.ts +2 -2
- package/build/main/commands.js +0 -1
- package/build/main/methods.d.ts +27 -8
- package/build/main/methods.js +1 -1
- package/build/main/payloads.d.ts +8 -8
- package/build/main/payloads.js +0 -1
- package/build/main/services/common.d.ts +5 -4
- package/build/main/services/common.js +0 -1
- package/build/main/services/companies/entities.d.ts +7 -6
- package/build/main/services/companies/entities.js +0 -1
- package/build/main/services/companies/index.d.ts +7 -6
- package/build/main/services/companies/index.integration.test.js +2 -3
- package/build/main/services/companies/index.js +0 -1
- package/build/main/services/companies/index.unit.test.js +1 -2
- package/build/main/services/companies/methods.d.ts +4 -4
- package/build/main/services/companies/methods.js +0 -1
- package/build/main/services/contacts/entities.d.ts +4 -3
- package/build/main/services/contacts/entities.js +0 -1
- package/build/main/services/contacts/index.d.ts +7 -6
- package/build/main/services/contacts/index.integration.test.js +2 -3
- package/build/main/services/contacts/index.js +0 -1
- package/build/main/services/contacts/index.unit.test.js +1 -2
- package/build/main/services/contacts/methods.d.ts +4 -4
- package/build/main/services/contacts/methods.js +0 -1
- package/build/main/services/currencies/entities.d.ts +2 -2
- package/build/main/services/currencies/entities.js +0 -1
- package/build/main/services/deals/entities.d.ts +2 -2
- package/build/main/services/deals/entities.js +0 -1
- package/build/main/services/deals/index.d.ts +7 -6
- package/build/main/services/deals/index.integration.test.js +2 -3
- package/build/main/services/deals/index.js +0 -1
- package/build/main/services/deals/index.unit.test.js +1 -2
- package/build/main/services/deals/methods.d.ts +4 -4
- package/build/main/services/deals/methods.js +0 -1
- package/build/main/services/leads/entities.d.ts +2 -2
- package/build/main/services/leads/entities.js +0 -1
- package/build/main/services/leads/index.d.ts +7 -6
- package/build/main/services/leads/index.integration.test.js +2 -3
- package/build/main/services/leads/index.js +0 -1
- package/build/main/services/leads/index.unit.test.js +1 -2
- package/build/main/services/leads/methods.d.ts +4 -4
- package/build/main/services/leads/methods.js +0 -1
- package/build/main/services/statuses/entities.d.ts +5 -4
- package/build/main/services/statuses/entities.js +0 -1
- package/build/main/services/statuses/index.d.ts +7 -11
- package/build/main/services/statuses/index.integration.test.js +8 -4
- package/build/main/services/statuses/index.js +0 -1
- package/build/main/services/statuses/index.unit.test.js +1 -2
- package/build/main/services/statuses/methods.d.ts +6 -6
- package/build/main/services/statuses/methods.js +0 -1
- package/build/main/services/users/entities.d.ts +4 -3
- package/build/main/services/users/entities.js +0 -1
- package/build/main/services/users/index.d.ts +3 -3
- package/build/main/services/users/index.integration.test.js +2 -3
- package/build/main/services/users/index.js +0 -1
- package/build/main/services/users/index.unit.test.js +1 -2
- package/build/main/services/users/methods.d.ts +4 -4
- package/build/main/services/users/methods.js +0 -1
- package/build/main/utils/Diff.js +0 -1
- package/build/main/utils/ExtractValue.d.ts +6 -1
- package/build/main/utils/ExtractValue.js +0 -1
- package/build/main/utils/isArray.d.ts +1 -1
- package/build/main/utils/isArray.js +1 -1
- package/build/module/bitrix.d.ts +25 -16
- package/build/module/bitrix.integration.test.js +0 -1
- package/build/module/bitrix.js +19 -3
- package/build/module/bitrix.unit.test.js +0 -1
- package/build/module/client/client.unit.test.js +9 -6
- package/build/module/client/hooks/addAccessToken.d.ts +5 -2
- package/build/module/client/hooks/addAccessToken.js +3 -1
- package/build/module/client/hooks/addAccessToken.unit.test.js +9 -8
- package/build/module/client/index.d.ts +10 -1
- package/build/module/client/index.js +19 -7
- package/build/module/client/methods/batch.d.ts +24 -5
- package/build/module/client/methods/batch.js +28 -3
- package/build/module/client/methods/batch.unit.test.js +61 -19
- package/build/module/client/methods/call.d.ts +11 -4
- package/build/module/client/methods/call.js +10 -3
- package/build/module/client/methods/call.unit.test.js +1 -2
- package/build/module/client/methods/list.d.ts +15 -3
- package/build/module/client/methods/list.js +21 -5
- package/build/module/client/methods/list.unit.test.js +0 -1
- package/build/module/commands.d.ts +2 -2
- package/build/module/commands.js +1 -1
- package/build/module/methods.d.ts +27 -8
- package/build/module/methods.js +0 -1
- package/build/module/payloads.d.ts +8 -8
- package/build/module/payloads.js +1 -1
- package/build/module/services/common.d.ts +5 -4
- package/build/module/services/common.js +1 -1
- package/build/module/services/companies/entities.d.ts +7 -6
- package/build/module/services/companies/entities.js +1 -1
- package/build/module/services/companies/index.d.ts +7 -6
- package/build/module/services/companies/index.integration.test.js +1 -2
- package/build/module/services/companies/index.js +0 -1
- package/build/module/services/companies/index.unit.test.js +0 -1
- package/build/module/services/companies/methods.d.ts +4 -4
- package/build/module/services/companies/methods.js +0 -1
- package/build/module/services/contacts/entities.d.ts +4 -3
- package/build/module/services/contacts/entities.js +1 -1
- package/build/module/services/contacts/index.d.ts +7 -6
- package/build/module/services/contacts/index.integration.test.js +1 -2
- package/build/module/services/contacts/index.js +0 -1
- package/build/module/services/contacts/index.unit.test.js +0 -1
- package/build/module/services/contacts/methods.d.ts +4 -4
- package/build/module/services/contacts/methods.js +0 -1
- package/build/module/services/currencies/entities.d.ts +2 -2
- package/build/module/services/currencies/entities.js +1 -1
- package/build/module/services/deals/entities.d.ts +2 -2
- package/build/module/services/deals/entities.js +1 -1
- package/build/module/services/deals/index.d.ts +7 -6
- package/build/module/services/deals/index.integration.test.js +1 -2
- package/build/module/services/deals/index.js +0 -1
- package/build/module/services/deals/index.unit.test.js +0 -1
- package/build/module/services/deals/methods.d.ts +4 -4
- package/build/module/services/deals/methods.js +0 -1
- package/build/module/services/leads/entities.d.ts +2 -2
- package/build/module/services/leads/entities.js +1 -1
- package/build/module/services/leads/index.d.ts +7 -6
- package/build/module/services/leads/index.integration.test.js +1 -2
- package/build/module/services/leads/index.js +0 -1
- package/build/module/services/leads/index.unit.test.js +0 -1
- package/build/module/services/leads/methods.d.ts +4 -4
- package/build/module/services/leads/methods.js +0 -1
- package/build/module/services/statuses/entities.d.ts +5 -4
- package/build/module/services/statuses/entities.js +1 -1
- package/build/module/services/statuses/index.d.ts +7 -11
- package/build/module/services/statuses/index.integration.test.js +7 -3
- package/build/module/services/statuses/index.js +0 -1
- package/build/module/services/statuses/index.unit.test.js +0 -1
- package/build/module/services/statuses/methods.d.ts +6 -6
- package/build/module/services/statuses/methods.js +0 -1
- package/build/module/services/users/entities.d.ts +4 -3
- package/build/module/services/users/entities.js +1 -1
- package/build/module/services/users/index.d.ts +3 -3
- package/build/module/services/users/index.integration.test.js +1 -2
- package/build/module/services/users/index.js +0 -1
- package/build/module/services/users/index.unit.test.js +0 -1
- package/build/module/services/users/methods.d.ts +4 -4
- package/build/module/services/users/methods.js +0 -1
- package/build/module/utils/Diff.js +1 -1
- package/build/module/utils/ExtractValue.d.ts +6 -1
- package/build/module/utils/ExtractValue.js +1 -1
- package/build/module/utils/isArray.d.ts +1 -1
- package/build/module/utils/isArray.js +1 -1
- package/package.json +64 -60
- package/build/main/bitrix.integration.test.js.map +0 -1
- package/build/main/bitrix.js.map +0 -1
- package/build/main/bitrix.unit.test.js.map +0 -1
- package/build/main/client/client.unit.test.js.map +0 -1
- package/build/main/client/hooks/addAccessToken.js.map +0 -1
- package/build/main/client/hooks/addAccessToken.unit.test.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/batch.unit.test.js.map +0 -1
- package/build/main/client/methods/call.js.map +0 -1
- package/build/main/client/methods/call.unit.test.js.map +0 -1
- package/build/main/client/methods/list.js.map +0 -1
- package/build/main/client/methods/list.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/companies/index.js.map +0 -1
- package/build/main/services/companies/index.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/contacts/index.js.map +0 -1
- package/build/main/services/contacts/index.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/deals/index.js.map +0 -1
- package/build/main/services/deals/index.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/leads/index.js.map +0 -1
- package/build/main/services/leads/index.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/statuses/index.js.map +0 -1
- package/build/main/services/statuses/index.unit.test.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.integration.test.js.map +0 -1
- package/build/main/services/users/index.js.map +0 -1
- package/build/main/services/users/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/bitrix.js.map +0 -1
- package/build/module/bitrix.unit.test.js.map +0 -1
- package/build/module/client/client.unit.test.js.map +0 -1
- package/build/module/client/hooks/addAccessToken.js.map +0 -1
- package/build/module/client/hooks/addAccessToken.unit.test.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/batch.unit.test.js.map +0 -1
- package/build/module/client/methods/call.js.map +0 -1
- package/build/module/client/methods/call.unit.test.js.map +0 -1
- package/build/module/client/methods/list.js.map +0 -1
- package/build/module/client/methods/list.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/companies/index.js.map +0 -1
- package/build/module/services/companies/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/contacts/index.js.map +0 -1
- package/build/module/services/contacts/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/deals/index.js.map +0 -1
- package/build/module/services/deals/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/leads/index.js.map +0 -1
- package/build/module/services/leads/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/statuses/index.js.map +0 -1
- package/build/module/services/statuses/index.unit.test.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.integration.test.js.map +0 -1
- package/build/module/services/users/index.js.map +0 -1
- package/build/module/services/users/index.unit.test.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
|
@@ -28,9 +28,12 @@ describe('Client `chunkCommands` method', () => {
|
|
|
28
28
|
});
|
|
29
29
|
it('should by default chunk with a size of `MAX_COMMANDS_PER_BATCH`', () => {
|
|
30
30
|
const commandsSets = 2;
|
|
31
|
-
const commands = range(0, MAX_COMMANDS_PER_BATCH * commandsSets).map(() => ({
|
|
31
|
+
const commands = range(0, MAX_COMMANDS_PER_BATCH * commandsSets).map(() => ({
|
|
32
|
+
method: Method.CRM_DEAL_GET
|
|
33
|
+
}));
|
|
32
34
|
const chunked = chunkCommands(commands);
|
|
33
35
|
expect(chunked.length).toBe(commandsSets);
|
|
36
|
+
// @ts-ignore we have asserted it length
|
|
34
37
|
expect(chunked[0].length).toBe(MAX_COMMANDS_PER_BATCH);
|
|
35
38
|
});
|
|
36
39
|
});
|
|
@@ -62,10 +65,7 @@ describe('Client `prepareCommandsQueries` method', () => {
|
|
|
62
65
|
expect(prepareCommandsQueries(commands)).toMatchSnapshot();
|
|
63
66
|
});
|
|
64
67
|
it('should work with array of commands', () => {
|
|
65
|
-
const commands = [
|
|
66
|
-
{ method: Method.CRM_DEAL_GET },
|
|
67
|
-
{ method: Method.CRM_DEAL_LIST }
|
|
68
|
-
];
|
|
68
|
+
const commands = [{ method: Method.CRM_DEAL_GET }, { method: Method.CRM_DEAL_LIST }];
|
|
69
69
|
expect(prepareCommandsQueries(commands)).toMatchSnapshot();
|
|
70
70
|
});
|
|
71
71
|
it('should return empty query object when no commands provided', () => {
|
|
@@ -160,21 +160,24 @@ describe('Client `mergeBatchPayloads` method', () => {
|
|
|
160
160
|
result_error: [],
|
|
161
161
|
result_total: [8, 8],
|
|
162
162
|
result_next: [2, 4],
|
|
163
|
-
result_time: [
|
|
163
|
+
result_time: [
|
|
164
|
+
{
|
|
164
165
|
start: 1567196891.008149,
|
|
165
166
|
finish: 1567196891.022234,
|
|
166
167
|
duration: 0.014085054397583008,
|
|
167
168
|
processing: 0.013998985290527344,
|
|
168
169
|
date_start: '2019-08-30T23:28:11+03:00',
|
|
169
170
|
date_finish: '2019-08-30T23:28:11+03:00'
|
|
170
|
-
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
171
173
|
start: 1567196891.022316,
|
|
172
174
|
finish: 1567196891.03225,
|
|
173
175
|
duration: 0.009933948516845703,
|
|
174
176
|
processing: 0.009846210479736328,
|
|
175
177
|
date_start: '2019-08-30T23:28:11+03:00',
|
|
176
178
|
date_finish: '2019-08-30T23:28:11+03:00'
|
|
177
|
-
}
|
|
179
|
+
}
|
|
180
|
+
]
|
|
178
181
|
},
|
|
179
182
|
time: {
|
|
180
183
|
start: 1567196890.959017,
|
|
@@ -194,21 +197,24 @@ describe('Client `mergeBatchPayloads` method', () => {
|
|
|
194
197
|
result_error: [],
|
|
195
198
|
result_total: [8, 8],
|
|
196
199
|
result_next: [6, 8],
|
|
197
|
-
result_time: [
|
|
200
|
+
result_time: [
|
|
201
|
+
{
|
|
198
202
|
start: 1567196891.032315,
|
|
199
203
|
finish: 1567196891.035297,
|
|
200
204
|
duration: 0.002981901168823242,
|
|
201
205
|
processing: 0.002897024154663086,
|
|
202
206
|
date_start: '2019-08-30T23:28:11+03:00',
|
|
203
207
|
date_finish: '2019-08-30T23:28:11+03:00'
|
|
204
|
-
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
205
210
|
start: 1567196891.03536,
|
|
206
211
|
finish: 1567196891.039936,
|
|
207
212
|
duration: 0.004575967788696289,
|
|
208
213
|
processing: 0.00450897216796875,
|
|
209
214
|
date_start: '2019-08-30T23:28:11+03:00',
|
|
210
215
|
date_finish: '2019-08-30T23:28:11+03:00'
|
|
211
|
-
}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
212
218
|
},
|
|
213
219
|
time: {
|
|
214
220
|
start: 1567196890.959517,
|
|
@@ -224,7 +230,7 @@ describe('Client `mergeBatchPayloads` method', () => {
|
|
|
224
230
|
});
|
|
225
231
|
const TEST_URI = 'https://test.com/rest';
|
|
226
232
|
const batch = Batch({
|
|
227
|
-
get: got.extend({
|
|
233
|
+
get: got.extend({ prefixUrl: TEST_URI, responseType: 'json' }).get
|
|
228
234
|
});
|
|
229
235
|
const RESPONSE_200 = 200;
|
|
230
236
|
describe('Client `batch` method', () => {
|
|
@@ -236,6 +242,9 @@ describe('Client `batch` method', () => {
|
|
|
236
242
|
two: { method: Method.CRM_DEAL_LIST }
|
|
237
243
|
};
|
|
238
244
|
const scope = nock(TEST_URI)
|
|
245
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
246
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
247
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
239
248
|
.get(`/${Method.BATCH}?cmd%5Bone%5D=${commands.one.method}%3FID%3D${dealId}&cmd%5Btwo%5D=${commands.two.method}`)
|
|
240
249
|
.reply(RESPONSE_200, payload);
|
|
241
250
|
await batch(commands);
|
|
@@ -249,6 +258,9 @@ describe('Client `batch` method', () => {
|
|
|
249
258
|
1: { method: Method.CRM_DEAL_LIST }
|
|
250
259
|
};
|
|
251
260
|
const scope = nock(TEST_URI)
|
|
261
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
262
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely
|
|
263
|
+
// connected to the `[]` since it does not appear when only one bracket present
|
|
252
264
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}%3FID%3D${dealId}&cmd%5B1%5D=${commands[1].method}`)
|
|
253
265
|
.reply(RESPONSE_200, payload);
|
|
254
266
|
await batch(commands);
|
|
@@ -262,6 +274,9 @@ describe('Client `batch` method', () => {
|
|
|
262
274
|
{ method: Method.CRM_DEAL_LIST }
|
|
263
275
|
];
|
|
264
276
|
const scope = nock(TEST_URI)
|
|
277
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
278
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely
|
|
279
|
+
// connected to the `[]` since it does not appear when only one bracket present
|
|
265
280
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}%3FID%3D${dealId}&cmd%5B1%5D=${commands[1].method}`)
|
|
266
281
|
.reply(RESPONSE_200, payload);
|
|
267
282
|
await batch(commands);
|
|
@@ -276,6 +291,9 @@ describe('Client `batch` method', () => {
|
|
|
276
291
|
two: { method: Method.CRM_DEAL_LIST }
|
|
277
292
|
};
|
|
278
293
|
const scope = nock(TEST_URI)
|
|
294
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
295
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
296
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
279
297
|
.get(`/${Method.BATCH}?cmd%5Bone%5D=${commands.one.method}%3FID%3D${dealId}`)
|
|
280
298
|
.reply(RESPONSE_200, payload)
|
|
281
299
|
.get(`/${Method.BATCH}?cmd%5Btwo%5D=${commands.two.method}`)
|
|
@@ -292,6 +310,9 @@ describe('Client `batch` method', () => {
|
|
|
292
310
|
1: { method: Method.CRM_DEAL_LIST }
|
|
293
311
|
};
|
|
294
312
|
const scope = nock(TEST_URI)
|
|
313
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
314
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely
|
|
315
|
+
// connected to the `[]` since it does not appear when only one bracket present
|
|
295
316
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}%3FID%3D${dealId}`)
|
|
296
317
|
.reply(RESPONSE_200, payload)
|
|
297
318
|
.get(`/${Method.BATCH}?cmd%5B1%5D=${commands[1].method}`)
|
|
@@ -308,6 +329,9 @@ describe('Client `batch` method', () => {
|
|
|
308
329
|
{ method: Method.CRM_DEAL_LIST }
|
|
309
330
|
];
|
|
310
331
|
const scope = nock(TEST_URI)
|
|
332
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
333
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely
|
|
334
|
+
// connected to the `[]` since it does not appear when only one bracket present
|
|
311
335
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}%3FID%3D${dealId}`)
|
|
312
336
|
.reply(RESPONSE_200, payload)
|
|
313
337
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[1].method}`)
|
|
@@ -331,10 +355,14 @@ describe('Client `batch` method', () => {
|
|
|
331
355
|
time: {}
|
|
332
356
|
};
|
|
333
357
|
nock(TEST_URI)
|
|
358
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
359
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
360
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
334
361
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}&cmd%5B1%5D=${commands[1].method}`)
|
|
335
362
|
.reply(RESPONSE_200, payload);
|
|
336
363
|
expect(await batch(commands)).toEqual(payload);
|
|
337
364
|
});
|
|
365
|
+
// @todo Test this also for named and numbered commands
|
|
338
366
|
it('should merge payloads when more then max allowed commands provided', async () => {
|
|
339
367
|
const maxAllowedCommands = 1;
|
|
340
368
|
const commands = {
|
|
@@ -362,6 +390,9 @@ describe('Client `batch` method', () => {
|
|
|
362
390
|
time: {}
|
|
363
391
|
};
|
|
364
392
|
nock(TEST_URI)
|
|
393
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
394
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
395
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
365
396
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}`)
|
|
366
397
|
.reply(RESPONSE_200, payload1)
|
|
367
398
|
.get(`/${Method.BATCH}?cmd%5B1%5D=${commands[1].method}`)
|
|
@@ -384,6 +415,9 @@ describe('Client `batch` method', () => {
|
|
|
384
415
|
two: { method: Method.CRM_DEAL_LIST }
|
|
385
416
|
};
|
|
386
417
|
nock(TEST_URI)
|
|
418
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
419
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
420
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
387
421
|
.get(`/${Method.BATCH}?cmd%5Bone%5D=${commands.one.method}&cmd%5Btwo%5D=${commands.two.method}`)
|
|
388
422
|
.reply(RESPONSE_200, payload);
|
|
389
423
|
return expect(batch(commands)).rejects.toMatchSnapshot();
|
|
@@ -392,7 +426,10 @@ describe('Client `batch` method', () => {
|
|
|
392
426
|
const payload = {
|
|
393
427
|
result: {
|
|
394
428
|
result: ['done'],
|
|
395
|
-
result_error: [
|
|
429
|
+
result_error: [
|
|
430
|
+
'Expected error from numbered `batch` 0',
|
|
431
|
+
'Expected error from numbered `batch` 1'
|
|
432
|
+
]
|
|
396
433
|
}
|
|
397
434
|
};
|
|
398
435
|
const commands = {
|
|
@@ -400,6 +437,9 @@ describe('Client `batch` method', () => {
|
|
|
400
437
|
1: { method: Method.CRM_DEAL_LIST }
|
|
401
438
|
};
|
|
402
439
|
nock(TEST_URI)
|
|
440
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
441
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
442
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
403
443
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}&cmd%5B1%5D=${commands[1].method}`)
|
|
404
444
|
.reply(RESPONSE_200, payload);
|
|
405
445
|
return expect(batch(commands)).rejects.toMatchSnapshot();
|
|
@@ -408,17 +448,19 @@ describe('Client `batch` method', () => {
|
|
|
408
448
|
const payload = {
|
|
409
449
|
result: {
|
|
410
450
|
result: ['done'],
|
|
411
|
-
result_error: [
|
|
451
|
+
result_error: [
|
|
452
|
+
'Expected error from array of command `batch` 0',
|
|
453
|
+
'Expected error from array of command `batch` 1'
|
|
454
|
+
]
|
|
412
455
|
}
|
|
413
456
|
};
|
|
414
|
-
const commands = [
|
|
415
|
-
{ method: Method.CRM_DEAL_GET },
|
|
416
|
-
{ method: Method.CRM_DEAL_LIST }
|
|
417
|
-
];
|
|
457
|
+
const commands = [{ method: Method.CRM_DEAL_GET }, { method: Method.CRM_DEAL_LIST }];
|
|
418
458
|
nock(TEST_URI)
|
|
459
|
+
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
460
|
+
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
461
|
+
// to the `[]`, since it does not appear when only one bracket present
|
|
419
462
|
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}&cmd%5B1%5D=${commands[1].method}`)
|
|
420
463
|
.reply(RESPONSE_200, payload);
|
|
421
464
|
return expect(batch(commands)).rejects.toMatchSnapshot();
|
|
422
465
|
});
|
|
423
466
|
});
|
|
424
|
-
//# sourceMappingURL=batch.unit.test.js.map
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import got from 'got';
|
|
2
2
|
import { Method, MethodParams, MethodPayload } from '../../methods';
|
|
3
3
|
import { Payload } from '../../payloads';
|
|
4
|
+
/**
|
|
5
|
+
* Checks wether payload have any errors and if it does — throws them
|
|
6
|
+
* Bitrix payload types do not provide discriminators, so we're forced to type cast them
|
|
7
|
+
*/
|
|
4
8
|
export declare const handlePayload: <P extends Payload<unknown>>(payload: P) => P;
|
|
5
9
|
export declare type Call = <M extends Method>(method: M, params: MethodParams<M>) => Promise<MethodPayload<M>>;
|
|
6
|
-
|
|
7
|
-
readonly get:
|
|
8
|
-
}
|
|
10
|
+
declare type Dependencies = {
|
|
11
|
+
readonly get: typeof got.get;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Dispatches a request with specified method and params. Will fill figure out payload type based on the Method
|
|
15
|
+
*/
|
|
9
16
|
declare const _default: ({ get }: Dependencies) => Call;
|
|
10
17
|
export default _default;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { stringify as toQuery } from 'qs';
|
|
2
2
|
import isArray from '../../utils/isArray';
|
|
3
|
+
/**
|
|
4
|
+
* Checks wether payload have any errors and if it does — throws them
|
|
5
|
+
* Bitrix payload types do not provide discriminators, so we're forced to type cast them
|
|
6
|
+
*/
|
|
3
7
|
export const handlePayload = (payload) => {
|
|
4
8
|
if (payload.error) {
|
|
5
|
-
throw new Error(`[call] failed to get the resource: ${payload.error}.`);
|
|
9
|
+
throw new Error(`[call] failed to get the resource: ${payload.error ?? ''}.`);
|
|
6
10
|
}
|
|
7
11
|
if (payload.result && payload.result.result_error) {
|
|
8
12
|
const resultErrors = payload.result.result_error;
|
|
9
13
|
const errors = isArray(resultErrors) ? resultErrors : Object.values(resultErrors);
|
|
10
14
|
if (errors.length > 0) {
|
|
15
|
+
// @todo We can give better formatting to display errored commands. But it's not important for now
|
|
11
16
|
throw new Error(`[batch] failed to process. Received errors in ${errors.length} commands:\n${errors.join('\n')}`);
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
return payload;
|
|
15
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Dispatches a request with specified method and params. Will fill figure out payload type based on the Method
|
|
23
|
+
*/
|
|
16
24
|
export default ({ get }) => {
|
|
17
|
-
const call = (method, params) => get(method, {
|
|
25
|
+
const call = (method, params) => get(method, { searchParams: toQuery(params) })
|
|
18
26
|
.then(({ body }) => handlePayload(body));
|
|
19
27
|
return call;
|
|
20
28
|
};
|
|
21
|
-
//# sourceMappingURL=call.js.map
|
|
@@ -4,7 +4,7 @@ import { Method } from '../../methods';
|
|
|
4
4
|
import Call, { handlePayload } from './call';
|
|
5
5
|
const TEST_URI = 'https://test.com/rest';
|
|
6
6
|
const call = Call({
|
|
7
|
-
get: got.extend({
|
|
7
|
+
get: got.extend({ prefixUrl: TEST_URI, responseType: 'json' }).get
|
|
8
8
|
});
|
|
9
9
|
const RESPONSE_200 = 200;
|
|
10
10
|
describe('Client `handlePayload` method', () => {
|
|
@@ -153,4 +153,3 @@ describe('Client `call` method', () => {
|
|
|
153
153
|
});
|
|
154
154
|
it.todo('should cast payload to the <P>');
|
|
155
155
|
});
|
|
156
|
-
//# sourceMappingURL=call.unit.test.js.map
|
|
@@ -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
|
}[];
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Get the highest value from object or an array if there's any
|
|
15
|
+
*/
|
|
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;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import range from 'lodash.range';
|
|
2
2
|
const MAX_ENTRIES_PER_COMMAND = 50;
|
|
3
|
+
/**
|
|
4
|
+
* Generates required amount of commands to process specified amount of entries
|
|
5
|
+
*/
|
|
3
6
|
export const fillWithCommands = ({ method, params }, start, toProcess, entriesPerCommand) => {
|
|
4
7
|
const requiresCommands = Math.ceil((toProcess - start) / entriesPerCommand);
|
|
5
8
|
return range(0, requiresCommands)
|
|
6
9
|
.map((i) => ({ method, params: { ...params, start: start + (entriesPerCommand * i) } }));
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Get the highest value from object or an array if there's any
|
|
13
|
+
*/
|
|
8
14
|
export const highest = (input) => Object.values(input).reduce((a, b) => a !== undefined && b !== undefined
|
|
9
15
|
? a > b ? a : b
|
|
10
16
|
: a !== undefined && b === undefined
|
|
@@ -12,28 +18,38 @@ export const highest = (input) => Object.values(input).reduce((a, b) => a !== un
|
|
|
12
18
|
: a === undefined && b !== undefined
|
|
13
19
|
? b
|
|
14
20
|
: undefined, undefined);
|
|
21
|
+
/**
|
|
22
|
+
* Converts batch payload to a list payload
|
|
23
|
+
*/
|
|
15
24
|
export const batchToListPayload = (payload) => {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
26
|
const { result: { result, result_total, result_error, result_next }, time } = payload;
|
|
17
|
-
const flattenResult = Object.entries(result).reduce(
|
|
27
|
+
const flattenResult = Object.entries(result).reduce(
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
29
|
+
// @ts-expect-error ignore this for now
|
|
30
|
+
(flatten, [_key, r]) => !r ? flatten : [...flatten, ...r], []);
|
|
18
31
|
return {
|
|
19
32
|
error: Object.values(result_error).join('\n'),
|
|
20
33
|
next: highest(result_next),
|
|
21
34
|
result: flattenResult,
|
|
35
|
+
// @todo Not accurate, we do not care
|
|
22
36
|
time,
|
|
23
|
-
total: highest(result_total)
|
|
37
|
+
total: highest(result_total) ?? 0
|
|
24
38
|
};
|
|
25
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Gets all entries by dispatching required amount of requests. Will fill figure out payload type based on the Method.
|
|
42
|
+
*/
|
|
26
43
|
export default ({ call, batch }) => {
|
|
27
44
|
const list = async (method, params) => {
|
|
28
|
-
const start = params.start
|
|
45
|
+
const start = params.start ?? 0;
|
|
29
46
|
const listAll = async () => {
|
|
30
47
|
const batchCommands = fillWithCommands({ method, params }, start, firstCall.total, MAX_ENTRIES_PER_COMMAND);
|
|
31
48
|
const payload = await batch(batchCommands);
|
|
32
49
|
return batchToListPayload(payload);
|
|
33
50
|
};
|
|
34
51
|
const firstCall = await call(method, { ...params, start });
|
|
35
|
-
return !firstCall.next ? firstCall : listAll();
|
|
52
|
+
return !firstCall.next ? firstCall : await listAll();
|
|
36
53
|
};
|
|
37
54
|
return list;
|
|
38
55
|
};
|
|
39
|
-
//# sourceMappingURL=list.js.map
|
package/build/module/commands.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -42,14 +42,14 @@ export declare enum Method {
|
|
|
42
42
|
declare const LISTABLE_METHODS: readonly [Method.CRM_COMPANY_LIST, Method.CRM_CONTACT_LIST, Method.CRM_DEAL_LIST, Method.CRM_LEAD_LIST];
|
|
43
43
|
export declare type ListableMethod = typeof LISTABLE_METHODS[number];
|
|
44
44
|
export declare type GettableMethod = Diff<Method, ListableMethod>;
|
|
45
|
-
|
|
45
|
+
declare type MethodsMap = {
|
|
46
46
|
readonly [key: string]: {
|
|
47
47
|
readonly type: unknown;
|
|
48
48
|
readonly payload: unknown;
|
|
49
|
-
readonly params: Record<string,
|
|
49
|
+
readonly params: Record<string, unknown>;
|
|
50
50
|
};
|
|
51
|
-
}
|
|
52
|
-
export
|
|
51
|
+
};
|
|
52
|
+
export declare type ListParams = {
|
|
53
53
|
readonly start?: number;
|
|
54
54
|
readonly order?: {
|
|
55
55
|
readonly [key: string]: string;
|
|
@@ -57,17 +57,36 @@ export interface ListParams {
|
|
|
57
57
|
readonly filter?: {
|
|
58
58
|
readonly [key: string]: string | number;
|
|
59
59
|
};
|
|
60
|
-
readonly select?:
|
|
61
|
-
}
|
|
62
|
-
|
|
60
|
+
readonly select?: readonly string[];
|
|
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
|
+
*/
|
|
69
|
+
export declare type Methods = MethodsMap & CompaniesMethods & ContactsMethods & DealsMethods & LeadsMethods & StatusesMethods & UsersMethods & {
|
|
63
70
|
readonly [Method.BATCH]: {
|
|
64
71
|
readonly type: unknown;
|
|
65
72
|
readonly payload: BatchPayload<unknown>;
|
|
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/module/methods.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare type PayloadTime = {
|
|
2
2
|
readonly start: number;
|
|
3
3
|
readonly finish: number;
|
|
4
4
|
readonly duration: number;
|
|
5
5
|
readonly processing: number;
|
|
6
6
|
readonly date_start: string;
|
|
7
7
|
readonly date_finish: string;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
};
|
|
9
|
+
export declare type GetPayload<P> = {
|
|
10
10
|
readonly result: P;
|
|
11
11
|
readonly time: PayloadTime;
|
|
12
|
-
}
|
|
13
|
-
export
|
|
12
|
+
};
|
|
13
|
+
export declare type ListPayload<P> = {
|
|
14
14
|
readonly result: readonly P[];
|
|
15
15
|
readonly error?: string;
|
|
16
16
|
readonly total: number;
|
|
17
17
|
readonly next?: number;
|
|
18
18
|
readonly time: PayloadTime;
|
|
19
|
-
}
|
|
20
|
-
export
|
|
19
|
+
};
|
|
20
|
+
export declare type BatchPayload<C> = {
|
|
21
21
|
readonly result: {
|
|
22
22
|
readonly result: {
|
|
23
23
|
readonly [P in keyof C]?: C[P];
|
|
@@ -36,5 +36,5 @@ export interface BatchPayload<C> {
|
|
|
36
36
|
} | readonly PayloadTime[];
|
|
37
37
|
};
|
|
38
38
|
readonly time: PayloadTime;
|
|
39
|
-
}
|
|
39
|
+
};
|
|
40
40
|
export declare type Payload<P> = GetPayload<P> | ListPayload<P> | BatchPayload<P>;
|
package/build/module/payloads.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ export declare type NumberString = string;
|
|
|
2
2
|
export declare type ISODate = string;
|
|
3
3
|
export declare type BoolString = 'Y' | 'N';
|
|
4
4
|
export declare type GenderString = 'M' | 'F' | '';
|
|
5
|
-
export
|
|
5
|
+
export declare type Fields = {
|
|
6
6
|
readonly [key: string]: {
|
|
7
7
|
readonly type: string;
|
|
8
8
|
readonly isRequired: boolean;
|
|
@@ -12,10 +12,11 @@ export interface Fields {
|
|
|
12
12
|
readonly isDynamic: boolean;
|
|
13
13
|
readonly title: string;
|
|
14
14
|
};
|
|
15
|
-
}
|
|
16
|
-
export
|
|
15
|
+
};
|
|
16
|
+
export declare type MultiField = {
|
|
17
17
|
readonly ID: NumberString;
|
|
18
18
|
readonly VALUE_TYPE: string;
|
|
19
19
|
readonly VALUE: string;
|
|
20
20
|
readonly TYPE_ID: string;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
|
+
export declare type MultiFieldArray = ReadonlyArray<Pick<MultiField, 'VALUE' | 'VALUE_TYPE'>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoolString, ISODate, MultiField, NumberString } from '../common';
|
|
2
|
-
export
|
|
2
|
+
export declare type Company = {
|
|
3
|
+
readonly [key: string]: string | boolean | null | readonly MultiField[];
|
|
3
4
|
readonly ID: NumberString;
|
|
4
5
|
readonly COMPANY_TYPE: string | null;
|
|
5
6
|
readonly TITLE: string | null;
|
|
@@ -8,10 +9,10 @@ export interface Company {
|
|
|
8
9
|
readonly HAS_PHONE: BoolString;
|
|
9
10
|
readonly HAS_EMAIL: BoolString;
|
|
10
11
|
readonly HAS_IMOL: BoolString;
|
|
11
|
-
readonly PHONE:
|
|
12
|
-
readonly EMAIL:
|
|
13
|
-
readonly WEB:
|
|
14
|
-
readonly IM:
|
|
12
|
+
readonly PHONE: readonly MultiField[];
|
|
13
|
+
readonly EMAIL: readonly MultiField[];
|
|
14
|
+
readonly WEB: readonly MultiField[];
|
|
15
|
+
readonly IM: readonly MultiField[];
|
|
15
16
|
readonly ASSIGNED_BY_ID: NumberString;
|
|
16
17
|
readonly CREATED_BY_ID: NumberString;
|
|
17
18
|
readonly MODIFY_BY_ID: NumberString;
|
|
@@ -50,4 +51,4 @@ export interface Company {
|
|
|
50
51
|
readonly UTM_CAMPAIGN: string | null;
|
|
51
52
|
readonly UTM_CONTENT: string | null;
|
|
52
53
|
readonly UTM_TERM: string | null;
|
|
53
|
-
}
|
|
54
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { Call } from '../../client/methods/call';
|
|
2
2
|
import { List } from '../../client/methods/list';
|
|
3
|
-
|
|
3
|
+
import { Method, MethodParams } from '../../methods';
|
|
4
|
+
declare type Dependencies = {
|
|
4
5
|
readonly call: Call;
|
|
5
6
|
readonly list: List;
|
|
6
|
-
}
|
|
7
|
+
};
|
|
7
8
|
declare const _default: ({ call, list }: Dependencies) => {
|
|
8
9
|
fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
|
|
9
10
|
create: <D extends {
|
|
10
11
|
readonly fields: Partial<import("./entities").Company>;
|
|
11
12
|
readonly params?: {
|
|
12
|
-
readonly REGISTER_SONET_EVENT:
|
|
13
|
+
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
13
14
|
} | undefined;
|
|
14
15
|
}>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("../../payloads").GetPayload<number>>;
|
|
15
16
|
get: (id: string) => Promise<import("../../payloads").GetPayload<import("./entities").Company>>;
|
|
16
|
-
list: (params?:
|
|
17
|
+
list: (params?: MethodParams<Method.CRM_COMPANY_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Company>>;
|
|
17
18
|
update: <D_1 extends {
|
|
18
19
|
readonly id: string;
|
|
19
|
-
readonly fields: Record<string,
|
|
20
|
+
readonly fields: Record<string, unknown>;
|
|
20
21
|
readonly params?: {
|
|
21
|
-
readonly REGISTER_SONET_EVENT:
|
|
22
|
+
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
22
23
|
} | undefined;
|
|
23
24
|
}>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("../../payloads").GetPayload<boolean>>;
|
|
24
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Bitrix from './../../bitrix';
|
|
2
|
-
const WEBHOOK_URL = process.env
|
|
2
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
3
3
|
if (!WEBHOOK_URL) {
|
|
4
4
|
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
5
5
|
}
|
|
@@ -12,4 +12,3 @@ describe('Companies', () => {
|
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
|
-
//# sourceMappingURL=index.integration.test.js.map
|