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,391 @@
1
+ "use strict";
2
+ /**
3
+ * Bitrix24 Sale — Нода интернет-магазина
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.Bitrix24Sale = void 0;
17
+ const Helpers_1 = require("../Bitrix24/Helpers");
18
+ class Bitrix24Sale {
19
+ constructor() {
20
+ this.description = {
21
+ displayName: 'Bitrix24 Магазин',
22
+ name: 'bitrix24Sale',
23
+ icon: 'file:bitrix24.svg',
24
+ group: ['transform'],
25
+ version: 1,
26
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
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: 'Order',
48
+ value: 'order',
49
+ description: 'Manage Sales Orders',
50
+ },
51
+ {
52
+ name: 'Payment (Item)',
53
+ value: 'payment',
54
+ description: 'Manage Payments inside Orders',
55
+ },
56
+ {
57
+ name: 'Shipment (Item)',
58
+ value: 'shipment',
59
+ description: 'Manage Shipments inside Orders',
60
+ },
61
+ {
62
+ name: 'Basket (Product)',
63
+ value: 'basket',
64
+ description: 'Manage Products (Basket Items) in Order',
65
+ },
66
+ {
67
+ name: 'Delivery Service',
68
+ value: 'delivery',
69
+ description: 'List Delivery Services',
70
+ },
71
+ {
72
+ name: 'Payment System',
73
+ value: 'paysystem',
74
+ description: 'List Payment Systems',
75
+ },
76
+ {
77
+ name: 'Order Status',
78
+ value: 'status',
79
+ description: 'Manage Order Statuses',
80
+ },
81
+ {
82
+ name: 'Order Property',
83
+ value: 'property',
84
+ description: 'Manage Order Properties',
85
+ },
86
+ ],
87
+ default: 'order',
88
+ required: true,
89
+ },
90
+ {
91
+ displayName: 'Operation',
92
+ name: 'operation',
93
+ type: 'options',
94
+ noDataExpression: true,
95
+ options: [
96
+ {
97
+ name: 'Create',
98
+ value: 'create',
99
+ description: 'Create a record',
100
+ action: 'Create a record',
101
+ displayOptions: {
102
+ show: {
103
+ resource: ['order', 'status', 'property', 'payment', 'shipment', 'basket'],
104
+ },
105
+ },
106
+ },
107
+ {
108
+ name: 'Get',
109
+ value: 'get',
110
+ description: 'Get a record',
111
+ action: 'Get a record',
112
+ displayOptions: {
113
+ show: {
114
+ resource: ['order', 'payment', 'shipment', 'status', 'property', 'basket'],
115
+ },
116
+ },
117
+ },
118
+ {
119
+ name: 'List',
120
+ value: 'list',
121
+ description: 'List records',
122
+ action: 'List records',
123
+ displayOptions: {
124
+ show: {
125
+ resource: ['order', 'delivery', 'paysystem', 'status', 'property', 'payment', 'shipment', 'basket'],
126
+ },
127
+ },
128
+ },
129
+ {
130
+ name: 'Update',
131
+ value: 'update',
132
+ description: 'Update a record',
133
+ action: 'Update a record',
134
+ displayOptions: {
135
+ show: {
136
+ resource: ['order', 'payment', 'shipment', 'status', 'property', 'basket'],
137
+ },
138
+ },
139
+ },
140
+ {
141
+ name: 'Delete',
142
+ value: 'delete',
143
+ description: 'Delete a record',
144
+ action: 'Delete a record',
145
+ displayOptions: {
146
+ show: {
147
+ resource: ['order', 'payment', 'shipment', 'status', 'property', 'basket'],
148
+ },
149
+ },
150
+ },
151
+ ],
152
+ default: 'create',
153
+ required: true,
154
+ },
155
+ // Order Fields
156
+ {
157
+ displayName: 'Order ID',
158
+ name: 'id',
159
+ type: 'string',
160
+ default: '',
161
+ required: true,
162
+ displayOptions: {
163
+ show: {
164
+ resource: ['order'],
165
+ operation: ['get', 'update', 'delete'],
166
+ },
167
+ },
168
+ description: 'ID of the Order',
169
+ },
170
+ {
171
+ displayName: 'Order ID (Parent)',
172
+ name: 'orderId',
173
+ type: 'string',
174
+ default: '',
175
+ required: true,
176
+ displayOptions: {
177
+ show: {
178
+ resource: ['payment', 'shipment'],
179
+ operation: ['create'],
180
+ },
181
+ },
182
+ description: 'ID of the Order this item belongs to',
183
+ },
184
+ // Specific IDs for items
185
+ {
186
+ displayName: 'Item ID',
187
+ name: 'id',
188
+ type: 'string',
189
+ default: '',
190
+ required: true,
191
+ displayOptions: {
192
+ show: {
193
+ resource: ['payment', 'shipment', 'status', 'property', 'basket'],
194
+ operation: ['get', 'update', 'delete'],
195
+ },
196
+ },
197
+ description: 'ID of the Item (Payment, Shipment, etc.)',
198
+ },
199
+ {
200
+ displayName: 'Fields',
201
+ name: 'fields',
202
+ type: 'collection',
203
+ placeholder: 'Add Field',
204
+ default: {},
205
+ displayOptions: {
206
+ show: {
207
+ resource: ['order'],
208
+ operation: ['create', 'update'],
209
+ },
210
+ },
211
+ options: [
212
+ {
213
+ displayName: 'User ID',
214
+ name: 'USER_ID',
215
+ type: 'string',
216
+ default: '',
217
+ description: 'ID of the user who made the order',
218
+ },
219
+ {
220
+ displayName: 'Currency',
221
+ name: 'CURRENCY',
222
+ type: 'string',
223
+ default: 'RUB',
224
+ },
225
+ {
226
+ displayName: 'Comments',
227
+ name: 'COMMENTS',
228
+ type: 'string',
229
+ default: '',
230
+ },
231
+ {
232
+ displayName: 'Status ID',
233
+ name: 'STATUS_ID',
234
+ type: 'string',
235
+ default: 'N',
236
+ },
237
+ // Add more standard fields as needed
238
+ ],
239
+ },
240
+ // Generic List options
241
+ {
242
+ displayName: 'Limit',
243
+ name: 'limit',
244
+ type: 'number',
245
+ default: 50,
246
+ displayOptions: {
247
+ show: {
248
+ operation: ['list'],
249
+ },
250
+ },
251
+ },
252
+ {
253
+ displayName: 'Filter JSON',
254
+ name: 'filterJson',
255
+ type: 'json',
256
+ default: '{}',
257
+ displayOptions: {
258
+ show: {
259
+ operation: ['list'],
260
+ },
261
+ },
262
+ },
263
+ ],
264
+ };
265
+ }
266
+ async execute() {
267
+ const items = this.getInputData();
268
+ const returnData = [];
269
+ const resource = this.getNodeParameter('resource', 0);
270
+ const operation = this.getNodeParameter('operation', 0);
271
+ for (let i = 0; i < items.length; i++) {
272
+ try {
273
+ let endpoint = '';
274
+ let body = {};
275
+ const requestMethod = 'POST';
276
+ if (resource === 'order') {
277
+ if (operation === 'create')
278
+ endpoint = 'sale.order.add';
279
+ if (operation === 'get')
280
+ endpoint = 'sale.order.get';
281
+ if (operation === 'list')
282
+ endpoint = 'sale.order.list';
283
+ if (operation === 'update')
284
+ endpoint = 'sale.order.update';
285
+ if (operation === 'delete')
286
+ endpoint = 'sale.order.delete';
287
+ }
288
+ else if (resource === 'payment') {
289
+ endpoint = `sale.payment.${operation}`; // add, update, delete, get, list
290
+ if (operation === 'create')
291
+ endpoint = 'sale.payment.add';
292
+ // Payment add requires ORDER_ID in body
293
+ }
294
+ else if (resource === 'shipment') {
295
+ endpoint = `sale.shipment.${operation}`;
296
+ if (operation === 'create')
297
+ endpoint = 'sale.shipment.add';
298
+ }
299
+ else if (resource === 'basket') {
300
+ endpoint = `sale.basket.item.${operation}`; // add, delete, get, update
301
+ if (operation === 'list')
302
+ endpoint = 'sale.basket.item.getList'; // Special case
303
+ if (operation === 'create')
304
+ endpoint = 'sale.basket.item.add';
305
+ }
306
+ else if (resource === 'delivery') {
307
+ if (operation === 'list')
308
+ endpoint = 'sale.delivery.service.list';
309
+ }
310
+ else if (resource === 'paysystem') {
311
+ if (operation === 'list')
312
+ endpoint = 'sale.paysystem.list';
313
+ }
314
+ else if (resource === 'status') {
315
+ endpoint = `sale.status.${operation}`;
316
+ }
317
+ else if (resource === 'property') {
318
+ endpoint = `sale.property.${operation}`;
319
+ }
320
+ // ID Parameters
321
+ if (['get', 'delete', 'update'].includes(operation)) {
322
+ const id = this.getNodeParameter('id', i);
323
+ body.id = id;
324
+ }
325
+ if (operation === 'create' || operation === 'update') {
326
+ const fields = this.getNodeParameter('fields', i, {});
327
+ // Payment/Shipment Add requires ORDER_ID
328
+ if ((resource === 'payment' || resource === 'shipment') && operation === 'create') {
329
+ const orderId = this.getNodeParameter('orderId', i);
330
+ body.orderId = orderId;
331
+ }
332
+ // Property operations use 'fields' too
333
+ body.fields = fields;
334
+ }
335
+ if (operation === 'list') {
336
+ const limit = this.getNodeParameter('limit', i);
337
+ const filterJson = this.getNodeParameter('filterJson', i, '{}');
338
+ let filter = {};
339
+ try {
340
+ filter = JSON.parse(filterJson);
341
+ }
342
+ catch (e) { }
343
+ if (resource === 'paysystem' || resource === 'delivery') {
344
+ body = { filter, limit }; // These sometimes take 'select' too
345
+ }
346
+ else {
347
+ // standard list like orders
348
+ body = { filter, limit, order: { ID: 'DESC' } };
349
+ }
350
+ }
351
+ // Fallback for endpoint construction if likely consistent
352
+ if (!endpoint) {
353
+ endpoint = `sale.${resource}.${operation}`;
354
+ }
355
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, requestMethod, endpoint + '.json', body);
356
+ let result = response.result;
357
+ // Normalization
358
+ const resultObj = result;
359
+ if (resource === 'order' && operation === 'list' && resultObj?.orders) {
360
+ result = resultObj.orders;
361
+ }
362
+ if (Array.isArray(result)) {
363
+ for (const item of result) {
364
+ returnData.push({
365
+ json: item,
366
+ pairedItem: { item: i },
367
+ });
368
+ }
369
+ }
370
+ else {
371
+ returnData.push({
372
+ json: result,
373
+ pairedItem: { item: i },
374
+ });
375
+ }
376
+ }
377
+ catch (error) {
378
+ if (this.continueOnFail()) {
379
+ returnData.push({
380
+ json: { error: error.message },
381
+ pairedItem: { item: i },
382
+ });
383
+ continue;
384
+ }
385
+ throw error;
386
+ }
387
+ }
388
+ return [returnData];
389
+ }
390
+ }
391
+ exports.Bitrix24Sale = Bitrix24Sale;