n8n-nodes-pragma-bitrix24 1.0.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 (51) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +340 -0
  3. package/dist/credentials/Bitrix24Api.credentials.js +55 -0
  4. package/dist/nodes/Bitrix24/Bitrix24.node.js +1410 -0
  5. package/dist/nodes/Bitrix24/Company.js +17 -0
  6. package/dist/nodes/Bitrix24/Contact.js +31 -0
  7. package/dist/nodes/Bitrix24/Deal.js +17 -0
  8. package/dist/nodes/Bitrix24/Helpers.js +300 -0
  9. package/dist/nodes/Bitrix24/Lead.js +17 -0
  10. package/dist/nodes/Bitrix24/SmartProcess.js +1 -0
  11. package/dist/nodes/Bitrix24/bitrix24.svg +7 -0
  12. package/dist/nodes/Bitrix24/types.js +58 -0
  13. package/dist/nodes/Bitrix24AI/Bitrix24AI.node.js +205 -0
  14. package/dist/nodes/Bitrix24App/Bitrix24App.node.js +179 -0
  15. package/dist/nodes/Bitrix24Auxiliary/Bitrix24Auxiliary.node.js +566 -0
  16. package/dist/nodes/Bitrix24Booking/Bitrix24Booking.node.js +871 -0
  17. package/dist/nodes/Bitrix24Calendar/Bitrix24Calendar.node.js +471 -0
  18. package/dist/nodes/Bitrix24ChatBot/Bitrix24ChatBot.node.js +522 -0
  19. package/dist/nodes/Bitrix24Commerce/Bitrix24Commerce.node.js +431 -0
  20. package/dist/nodes/Bitrix24Department/Bitrix24Department.node.js +317 -0
  21. package/dist/nodes/Bitrix24Disk/Bitrix24Disk.node.js +334 -0
  22. package/dist/nodes/Bitrix24Document/Bitrix24Document.node.js +280 -0
  23. package/dist/nodes/Bitrix24Entity/Bitrix24Entity.node.js +263 -0
  24. package/dist/nodes/Bitrix24Group/Bitrix24Group.node.js +327 -0
  25. package/dist/nodes/Bitrix24Lists/Bitrix24Lists.node.js +406 -0
  26. package/dist/nodes/Bitrix24Log/Bitrix24Log.node.js +309 -0
  27. package/dist/nodes/Bitrix24Mail/Bitrix24Mail.node.js +109 -0
  28. package/dist/nodes/Bitrix24MessageService/Bitrix24MessageService.node.js +218 -0
  29. package/dist/nodes/Bitrix24OpenChannels/Bitrix24OpenChannels.node.js +379 -0
  30. package/dist/nodes/Bitrix24PaySystem/Bitrix24PaySystem.node.js +241 -0
  31. package/dist/nodes/Bitrix24Pipeline/Bitrix24Pipeline.node.js +553 -0
  32. package/dist/nodes/Bitrix24Pipeline/bitrix24.svg +7 -0
  33. package/dist/nodes/Bitrix24Sale/Bitrix24Sale.node.js +391 -0
  34. package/dist/nodes/Bitrix24Scrum/Bitrix24Scrum.node.js +555 -0
  35. package/dist/nodes/Bitrix24Scrum/bitrix24.svg +7 -0
  36. package/dist/nodes/Bitrix24Sign/Bitrix24Sign.node.js +132 -0
  37. package/dist/nodes/Bitrix24Social/Bitrix24Social.node.js +224 -0
  38. package/dist/nodes/Bitrix24Task/Bitrix24Task.node.js +444 -0
  39. package/dist/nodes/Bitrix24Telephony/Bitrix24Telephony.node.js +511 -0
  40. package/dist/nodes/Bitrix24Timeman/Bitrix24Timeman.node.js +196 -0
  41. package/dist/nodes/Bitrix24Tool/Bitrix24Tool.node.js +1035 -0
  42. package/dist/nodes/Bitrix24Tool/bitrix24.svg +7 -0
  43. package/dist/nodes/Bitrix24Trigger/Bitrix24Trigger.node.js +184 -0
  44. package/dist/nodes/Bitrix24User/Bitrix24User.node.js +351 -0
  45. package/dist/nodes/Bitrix24UserField/Bitrix24UserField.node.js +386 -0
  46. package/dist/nodes/Bitrix24UserField/bitrix24.svg +7 -0
  47. package/dist/nodes/shared/bitrix24.svg +7 -0
  48. package/dist/nodes/shared/localization.js +189 -0
  49. package/dist/nodes/shared/types.js +22 -0
  50. package/index.js +10 -0
  51. package/package.json +108 -0
@@ -0,0 +1,431 @@
1
+ "use strict";
2
+ /**
3
+ * Bitrix24 Commerce — Нода управления товарами и заказами
4
+ *
5
+ * Bitrix24 PRAGMA.by nodes for n8n
6
+ * Профессиональная интеграция с Битрикс24.
7
+ *
8
+ * @author PRAGMA & Азбука Решений
9
+ * @copyright 2026 PRAGMA (https://pragma.by/) & Азбука Решений (https://abc-solution.ru/)
10
+ *
11
+ * Контакты:
12
+ * 🇧🇾 PRAGMA: +375 (44) 702-70-90 | https://pragma.by/
13
+ * 🇷🇺 Азбука Решений: +7 (939) 555-19-60 | https://abc-solution.ru/
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Bitrix24Commerce = void 0;
17
+ const Helpers_1 = require("../Bitrix24/Helpers");
18
+ class Bitrix24Commerce {
19
+ constructor() {
20
+ this.description = {
21
+ displayName: 'Bitrix24 Торговля',
22
+ name: 'bitrix24Commerce',
23
+ icon: 'file:bitrix24.svg',
24
+ group: ['transform'],
25
+ version: 1,
26
+ subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
27
+ description: 'Управление каталогом товаров, заказами и складскими документами',
28
+ defaults: {
29
+ name: 'Bitrix24 Торговля',
30
+ },
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ credentials: [
34
+ {
35
+ name: 'bitrix24Api',
36
+ required: true,
37
+ },
38
+ ],
39
+ properties: [
40
+ {
41
+ displayName: 'Resource',
42
+ name: 'resource',
43
+ type: 'options',
44
+ noDataExpression: true,
45
+ options: [
46
+ {
47
+ name: 'Catalog Product',
48
+ value: 'product',
49
+ },
50
+ {
51
+ name: 'Store Order',
52
+ value: 'order',
53
+ },
54
+ {
55
+ name: 'Store Document',
56
+ value: 'store_document',
57
+ description: 'Arrival, Deduction, Moving',
58
+ },
59
+ {
60
+ name: 'Shipment',
61
+ value: 'shipment',
62
+ },
63
+ {
64
+ name: 'Inventory (Store)',
65
+ value: 'store',
66
+ },
67
+ {
68
+ name: 'Price Type',
69
+ value: 'price_type',
70
+ },
71
+ {
72
+ name: 'Payment System',
73
+ value: 'pay_system',
74
+ },
75
+ {
76
+ name: 'Payment',
77
+ value: 'payment',
78
+ },
79
+ ],
80
+ default: 'product',
81
+ },
82
+ {
83
+ displayName: 'Operation',
84
+ name: 'operation',
85
+ type: 'options',
86
+ noDataExpression: true,
87
+ options: [
88
+ {
89
+ name: 'Get',
90
+ value: 'get',
91
+ action: 'Get a record',
92
+ displayOptions: {
93
+ show: {
94
+ resource: ['product', 'order', 'payment', 'store_document', 'shipment', 'store'],
95
+ },
96
+ },
97
+ },
98
+ {
99
+ name: 'List',
100
+ value: 'list',
101
+ action: 'List records',
102
+ displayOptions: {
103
+ show: {
104
+ resource: ['product', 'order', 'store_document', 'shipment', 'store', 'price_type', 'pay_system'],
105
+ },
106
+ },
107
+ },
108
+ {
109
+ name: 'Create',
110
+ value: 'create',
111
+ action: 'Create a record',
112
+ displayOptions: {
113
+ show: {
114
+ resource: ['order', 'store_document'],
115
+ },
116
+ },
117
+ },
118
+ {
119
+ name: 'Update Price',
120
+ value: 'updatePrice',
121
+ action: 'Update product price',
122
+ displayOptions: {
123
+ show: {
124
+ resource: ['product'],
125
+ },
126
+ },
127
+ },
128
+ ],
129
+ default: 'list',
130
+ },
131
+ // ----------------------------------
132
+ // Product: Get/List
133
+ // ----------------------------------
134
+ {
135
+ displayName: 'Product ID',
136
+ name: 'productId',
137
+ type: 'string',
138
+ default: '',
139
+ required: true,
140
+ displayOptions: {
141
+ show: {
142
+ resource: ['product'],
143
+ operation: ['get', 'updatePrice'],
144
+ },
145
+ },
146
+ },
147
+ {
148
+ displayName: 'New Price',
149
+ name: 'price',
150
+ type: 'number',
151
+ default: 0,
152
+ displayOptions: {
153
+ show: {
154
+ resource: ['product'],
155
+ operation: ['updatePrice'],
156
+ },
157
+ },
158
+ description: 'New price for the product (Base Price)',
159
+ },
160
+ {
161
+ displayName: 'Currency',
162
+ name: 'currency',
163
+ type: 'string',
164
+ default: 'USD',
165
+ displayOptions: {
166
+ show: {
167
+ resource: ['product'],
168
+ operation: ['updatePrice'],
169
+ },
170
+ },
171
+ },
172
+ // ----------------------------------
173
+ // Store Document Fields
174
+ // ----------------------------------
175
+ {
176
+ displayName: 'Document Type',
177
+ name: 'docType',
178
+ type: 'options',
179
+ options: [
180
+ { name: 'Arrival', value: 'A' },
181
+ { name: 'Deduction', value: 'D' },
182
+ { name: 'Moving', value: 'M' },
183
+ ],
184
+ default: 'A',
185
+ displayOptions: {
186
+ show: {
187
+ resource: ['store_document'],
188
+ operation: ['create'],
189
+ },
190
+ },
191
+ },
192
+ {
193
+ displayName: 'Store ID (Target)',
194
+ name: 'storeId',
195
+ type: 'string',
196
+ default: '',
197
+ displayOptions: {
198
+ show: {
199
+ resource: ['store_document', 'store'],
200
+ operation: ['create', 'update', 'get'],
201
+ },
202
+ },
203
+ },
204
+ {
205
+ displayName: 'Total Amount',
206
+ name: 'totalAmount',
207
+ type: 'number',
208
+ default: 0,
209
+ displayOptions: {
210
+ show: {
211
+ resource: ['store_document'],
212
+ operation: ['create'],
213
+ },
214
+ },
215
+ },
216
+ // ----------------------------------
217
+ // Common JSON for complex inputs
218
+ // ----------------------------------
219
+ {
220
+ displayName: 'Order ID',
221
+ name: 'orderId',
222
+ type: 'string',
223
+ default: '',
224
+ required: true,
225
+ displayOptions: {
226
+ show: {
227
+ resource: ['order', 'payment'],
228
+ operation: ['get'],
229
+ },
230
+ },
231
+ },
232
+ {
233
+ displayName: 'User ID (Customer)',
234
+ name: 'userId',
235
+ type: 'string',
236
+ default: '',
237
+ displayOptions: {
238
+ show: {
239
+ resource: ['order'],
240
+ operation: ['create'],
241
+ },
242
+ },
243
+ description: 'ID of the user who made the order',
244
+ },
245
+ {
246
+ displayName: 'Comment',
247
+ name: 'comment',
248
+ type: 'string',
249
+ default: '',
250
+ displayOptions: {
251
+ show: {
252
+ resource: ['order'],
253
+ operation: ['create'],
254
+ },
255
+ },
256
+ },
257
+ // ----------------------------------
258
+ // JSON Fields for Complex Ops
259
+ // ----------------------------------
260
+ {
261
+ displayName: 'JSON Parameters',
262
+ name: 'jsonParameters',
263
+ type: 'json',
264
+ default: '{}',
265
+ description: 'Additional parameters for List (Filter/Select) or Create (Fields)',
266
+ },
267
+ ],
268
+ };
269
+ }
270
+ async execute() {
271
+ const items = this.getInputData();
272
+ const returnData = [];
273
+ const resource = this.getNodeParameter('resource', 0);
274
+ const operation = this.getNodeParameter('operation', 0);
275
+ for (let i = 0; i < items.length; i++) {
276
+ try {
277
+ if (resource === 'product') {
278
+ if (operation === 'get') {
279
+ const id = this.getNodeParameter('productId', i);
280
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.product.get', { id });
281
+ returnData.push(response.result);
282
+ }
283
+ if (operation === 'list') {
284
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
285
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.product.list', params);
286
+ const resultData = response.result;
287
+ const list = resultData?.products || [];
288
+ list.forEach(item => returnData.push(item));
289
+ }
290
+ if (operation === 'updatePrice') {
291
+ const id = this.getNodeParameter('productId', i);
292
+ const price = this.getNodeParameter('price', i);
293
+ const currency = this.getNodeParameter('currency', i);
294
+ // Requires updating the Price Record linked to Product
295
+ // First, check if price exists or just use catalog.price.update logic (if ID known)
296
+ // Simplification: catalog.product.update often allows updating fields.
297
+ // But Price is separate. We need 'catalog.price.list' then 'catalog.price.update'.
298
+ // Find price ID for Base Price (Group 1 usually)
299
+ const prices = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.price.list', {
300
+ filter: { PRODUCT_ID: id }
301
+ });
302
+ let result;
303
+ const pricesResult = prices.result;
304
+ const pricesArr = pricesResult?.prices || [];
305
+ if (pricesArr.length > 0) {
306
+ // Update existing
307
+ const priceId = pricesArr[0].id;
308
+ result = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.price.update', {
309
+ id: priceId,
310
+ fields: { PRICE: price, CURRENCY: currency }
311
+ });
312
+ }
313
+ else {
314
+ // Create new
315
+ result = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.price.add', {
316
+ fields: {
317
+ PRODUCT_ID: id,
318
+ CATALOG_GROUP_ID: 1, // Base Price
319
+ PRICE: price,
320
+ CURRENCY: currency
321
+ }
322
+ });
323
+ }
324
+ returnData.push({ success: true, result: result.result });
325
+ }
326
+ }
327
+ if (resource === 'order') {
328
+ if (operation === 'get') {
329
+ const id = this.getNodeParameter('orderId', i);
330
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.order.get', { id });
331
+ returnData.push(response.result);
332
+ }
333
+ if (operation === 'list') {
334
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
335
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.order.list', params);
336
+ const ordersResult = response.result;
337
+ const list = ordersResult?.orders || [];
338
+ list.forEach(item => returnData.push(item));
339
+ }
340
+ if (operation === 'create') {
341
+ const userId = this.getNodeParameter('userId', i);
342
+ const comment = this.getNodeParameter('comment', i);
343
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
344
+ const fields = {
345
+ USER_ID: userId,
346
+ COMMENTS: comment,
347
+ ...params
348
+ };
349
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.order.add', { fields });
350
+ returnData.push({ id: response.result });
351
+ }
352
+ }
353
+ // ----------------------------------
354
+ // Resource: Store Document
355
+ // ----------------------------------
356
+ if (resource === 'store_document') {
357
+ if (operation === 'list') {
358
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
359
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.document.list', params);
360
+ const docsResult = response.result;
361
+ const list = docsResult?.documents || [];
362
+ list.forEach(item => returnData.push(item));
363
+ }
364
+ if (operation === 'create') {
365
+ const docType = this.getNodeParameter('docType', i);
366
+ // catalog.document.add logic requires specific fields
367
+ // Usually: DOC_TYPE, CONTRACTOR_ID, RESPONSIBLE_ID, DATE_DOCUMENT, etc.
368
+ // We'll use generic JSON for deep fields, but map type clearly.
369
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
370
+ const fields = {
371
+ DOC_TYPE: docType,
372
+ ...params
373
+ };
374
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.document.add', { fields });
375
+ returnData.push({ id: response.result });
376
+ }
377
+ }
378
+ // ----------------------------------
379
+ // Resource: Shipment
380
+ // ----------------------------------
381
+ if (resource === 'shipment') {
382
+ if (operation === 'list') {
383
+ const params = JSON.parse(this.getNodeParameter('jsonParameters', i, '{}'));
384
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.shipment.list', params);
385
+ const shipmentsResult = response.result;
386
+ const list = shipmentsResult?.shipments || [];
387
+ list.forEach(item => returnData.push(item));
388
+ }
389
+ }
390
+ // ----------------------------------
391
+ // Resource: Store, Price Type, Pay System
392
+ // ----------------------------------
393
+ if (resource === 'store') {
394
+ if (operation === 'list') {
395
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.store.list', {});
396
+ response.result.forEach(item => returnData.push(item));
397
+ }
398
+ }
399
+ if (resource === 'price_type') {
400
+ if (operation === 'list') {
401
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'catalog.price.type.list', {});
402
+ response.result.forEach(item => returnData.push(item));
403
+ }
404
+ }
405
+ if (resource === 'pay_system') {
406
+ if (operation === 'list') {
407
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.pay_system.list', {});
408
+ response.result.forEach(item => returnData.push(item));
409
+ }
410
+ }
411
+ if (resource === 'payment') {
412
+ if (operation === 'get') {
413
+ const id = this.getNodeParameter('orderId', i); // Payment usually linked to Order or has own ID
414
+ // sale.payment.get?
415
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'sale.payment.get', { id });
416
+ returnData.push(response.result);
417
+ }
418
+ }
419
+ }
420
+ catch (error) {
421
+ if (this.continueOnFail()) {
422
+ returnData.push({ error: error.message });
423
+ continue;
424
+ }
425
+ throw error;
426
+ }
427
+ }
428
+ return [this.helpers.returnJsonArray(returnData)];
429
+ }
430
+ }
431
+ exports.Bitrix24Commerce = Bitrix24Commerce;