n8n-nodes-mautic-advanced 0.3.5 → 0.3.6

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.
@@ -262,6 +262,47 @@ async function getContactCompanies(context, itemIndex) {
262
262
  const contactId = (0, ApiHelpers_1.getRequiredParam)(context, 'contactId', itemIndex);
263
263
  return await (0, ApiHelpers_1.makePaginatedRequest)(context, 'companies', 'GET', `/contacts/${contactId}/companies`);
264
264
  }
265
+ function normalizeTagsInput(tagsInput) {
266
+ // Handle different input formats for tags
267
+ // If it's already an array of strings, return as is
268
+ if (Array.isArray(tagsInput) && tagsInput.every((tag) => typeof tag === 'string')) {
269
+ return tagsInput;
270
+ }
271
+ // If it's a string, split by comma
272
+ if (typeof tagsInput === 'string') {
273
+ return tagsInput
274
+ .split(',')
275
+ .map((tag) => tag.trim())
276
+ .filter((tag) => tag.length > 0);
277
+ }
278
+ // If it's an array of objects with 'tag' property
279
+ if (Array.isArray(tagsInput) && tagsInput.every((item) => typeof item === 'object' && item.tag)) {
280
+ return tagsInput.map((item) => item.tag);
281
+ }
282
+ // If it's a complex object (like user's input with inputA/inputB)
283
+ if (typeof tagsInput === 'object' && tagsInput !== null) {
284
+ const tags = [];
285
+ // Handle inputA and inputB structure
286
+ if (tagsInput.inputA && Array.isArray(tagsInput.inputA)) {
287
+ tags.push(...tagsInput.inputA.map((item) => item.tag || item).filter(Boolean));
288
+ }
289
+ if (tagsInput.inputB && Array.isArray(tagsInput.inputB)) {
290
+ tags.push(...tagsInput.inputB.map((item) => item.tag || item).filter(Boolean));
291
+ }
292
+ // If no inputA/inputB, try to extract from any array properties
293
+ if (tags.length === 0) {
294
+ Object.values(tagsInput).forEach((value) => {
295
+ if (Array.isArray(value)) {
296
+ tags.push(...value.map((item) => item.tag || item).filter(Boolean));
297
+ }
298
+ });
299
+ }
300
+ // Remove duplicates and return
301
+ return [...new Set(tags)];
302
+ }
303
+ // Fallback: return empty array
304
+ return [];
305
+ }
265
306
  function addContactFields(body, fields) {
266
307
  const addressUi = fields.addressUi;
267
308
  if (addressUi?.addressValues) {
@@ -296,7 +337,7 @@ function addContactFields(body, fields) {
296
337
  if (fields.preferredChannel)
297
338
  body.preferred_channel = fields.preferredChannel;
298
339
  if (fields.tags)
299
- body.tags = fields.tags.split(',');
340
+ body.tags = normalizeTagsInput(fields.tags);
300
341
  const customFieldsUi = fields.customFieldsUi;
301
342
  if (customFieldsUi?.customFieldValues) {
302
343
  const { customFieldValues } = customFieldsUi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-mautic-advanced",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Enhanced n8n node for Mautic with comprehensive API coverage including tags, campaigns, categories, and advanced contact management",
5
5
  "keywords": [
6
6
  "n8n",