n8n-nodes-chat2crm 0.1.6 → 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.
@@ -337,14 +337,28 @@ class Chat2CrmSend {
337
337
  let messageData = {};
338
338
  try {
339
339
  if (typeof messageDataParam === 'string') {
340
- messageData = JSON.parse(messageDataParam);
340
+ // Если это строка, пытаемся распарсить JSON
341
+ if (messageDataParam.trim() === '') {
342
+ messageData = {};
343
+ }
344
+ else {
345
+ messageData = JSON.parse(messageDataParam);
346
+ }
341
347
  }
342
- else if (typeof messageDataParam === 'object') {
348
+ else if (typeof messageDataParam === 'object' && messageDataParam !== null) {
349
+ // Если это уже объект, используем его напрямую
343
350
  messageData = messageDataParam;
344
351
  }
352
+ else {
353
+ throw new n8n_workflow_1.ApplicationError('messageData must be a JSON object or string', { level: 'error' });
354
+ }
345
355
  }
346
356
  catch (error) {
347
- 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' });
348
362
  }
349
363
  // Отправляем сообщение в каждый выбранный stream
350
364
  const sent = [];
@@ -361,6 +375,9 @@ class Chat2CrmSend {
361
375
  if (typeof value === 'object' && value !== null) {
362
376
  fields.push(JSON.stringify(value));
363
377
  }
378
+ else if (value === null || value === undefined) {
379
+ fields.push('');
380
+ }
364
381
  else {
365
382
  fields.push(String(value));
366
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-chat2crm",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "n8n node for Chat2Crm Redis integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",