n8n-nodes-chat2crm 0.1.5 → 0.1.7

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.
@@ -35,9 +35,63 @@ class Chat2CrmSend {
35
35
  type: 'multiOptions',
36
36
  required: true,
37
37
  description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
38
- typeOptions: {
39
- loadOptionsMethod: 'getStreams',
40
- },
38
+ options: [
39
+ {
40
+ name: 'Chat Incoming Message',
41
+ value: 'chat_incoming_message',
42
+ description: 'Messages to chat (DB 0)',
43
+ },
44
+ {
45
+ name: 'Chat Outgoing Message',
46
+ value: 'chat_outgoing_message',
47
+ description: 'Messages from chat to CRM (DB 0)',
48
+ },
49
+ {
50
+ name: 'Chat Outgoing Status',
51
+ value: 'chat_outgoing_status',
52
+ description: 'Status messages from chat (DB 0)',
53
+ },
54
+ {
55
+ name: 'CRM Contacts',
56
+ value: 'crm_contacts',
57
+ description: 'CRM contacts stream (DB 1)',
58
+ },
59
+ {
60
+ name: 'CRM Incoming Message',
61
+ value: 'crm_incoming_message',
62
+ description: 'Messages to CRM (DB 1)',
63
+ },
64
+ {
65
+ name: 'CRM Incoming Status',
66
+ value: 'crm_incoming_status',
67
+ description: 'Status messages to CRM (DB 0)',
68
+ },
69
+ {
70
+ name: 'CRM Lazy Incoming Message',
71
+ value: 'crm_lazy_incoming_message',
72
+ description: 'Lazy incoming messages to CRM (DB 1)',
73
+ },
74
+ {
75
+ name: 'CRM Outgoing Message',
76
+ value: 'crm_outgoing_message',
77
+ description: 'Messages from CRM to chat (DB 1)',
78
+ },
79
+ {
80
+ name: 'CRM Outgoing Status',
81
+ value: 'crm_outgoing_status',
82
+ description: 'Status messages from CRM (DB 0)',
83
+ },
84
+ {
85
+ name: 'N8N Incoming Message',
86
+ value: 'n8n_incoming_message',
87
+ description: 'Incoming messages to N8N (DB 0)',
88
+ },
89
+ {
90
+ name: 'N8N Outgoing Message',
91
+ value: 'n8n_outgoing_message',
92
+ description: 'Outgoing messages from N8N (DB 0)',
93
+ },
94
+ ],
41
95
  default: [],
42
96
  },
43
97
  {
@@ -283,14 +337,28 @@ class Chat2CrmSend {
283
337
  let messageData = {};
284
338
  try {
285
339
  if (typeof messageDataParam === 'string') {
286
- messageData = JSON.parse(messageDataParam);
340
+ // Если это строка, пытаемся распарсить JSON
341
+ if (messageDataParam.trim() === '') {
342
+ messageData = {};
343
+ }
344
+ else {
345
+ messageData = JSON.parse(messageDataParam);
346
+ }
287
347
  }
288
- else if (typeof messageDataParam === 'object') {
348
+ else if (typeof messageDataParam === 'object' && messageDataParam !== null) {
349
+ // Если это уже объект, используем его напрямую
289
350
  messageData = messageDataParam;
290
351
  }
352
+ else {
353
+ throw new n8n_workflow_1.ApplicationError('messageData must be a JSON object or string', { level: 'error' });
354
+ }
291
355
  }
292
356
  catch (error) {
293
- throw new n8n_workflow_1.ApplicationError(`Invalid JSON in messageData: ${error}`, { level: 'error' });
357
+ throw new n8n_workflow_1.ApplicationError(`Invalid JSON in messageData: ${error.message}`, { level: 'error' });
358
+ }
359
+ // Проверяем, что messageData не пустой
360
+ if (Object.keys(messageData).length === 0) {
361
+ throw new n8n_workflow_1.ApplicationError('messageData cannot be empty', { level: 'error' });
294
362
  }
295
363
  // Отправляем сообщение в каждый выбранный stream
296
364
  const sent = [];
@@ -307,6 +375,9 @@ class Chat2CrmSend {
307
375
  if (typeof value === 'object' && value !== null) {
308
376
  fields.push(JSON.stringify(value));
309
377
  }
378
+ else if (value === null || value === undefined) {
379
+ fields.push('');
380
+ }
310
381
  else {
311
382
  fields.push(String(value));
312
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-chat2crm",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "n8n node for Chat2Crm Redis integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",