n8n-nodes-mautic-advanced 1.2.1 → 1.3.2

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.
@@ -14,25 +14,6 @@ class MauticAdvancedApi {
14
14
  default: '',
15
15
  placeholder: 'https://name.mautic.net',
16
16
  },
17
- {
18
- displayName: 'Mautic Version',
19
- name: 'mauticVersion',
20
- type: 'options',
21
- default: 'v6',
22
- options: [
23
- {
24
- name: 'v6 or lower',
25
- value: 'v6',
26
- description: 'Use legacy v1 API endpoints.',
27
- },
28
- {
29
- name: 'v7 or higher',
30
- value: 'v7',
31
- description: 'Use v2 API endpoints where available.',
32
- },
33
- ],
34
- description: 'Select the major Mautic version of this instance so the node can route API calls correctly.',
35
- },
36
17
  {
37
18
  displayName: 'Username',
38
19
  name: 'username',
@@ -21,25 +21,6 @@ class MauticAdvancedOAuth2Api {
21
21
  default: '',
22
22
  placeholder: 'https://name.mautic.net',
23
23
  },
24
- {
25
- displayName: 'Mautic Version',
26
- name: 'mauticVersion',
27
- type: 'options',
28
- default: 'v6',
29
- options: [
30
- {
31
- name: 'v6 or lower',
32
- value: 'v6',
33
- description: 'Use legacy v1 API endpoints.',
34
- },
35
- {
36
- name: 'v7 or higher',
37
- value: 'v7',
38
- description: 'Use v2 API endpoints where available.',
39
- },
40
- ],
41
- description: 'Select the major Mautic version of this instance so the node can route API calls correctly.',
42
- },
43
24
  {
44
25
  displayName: 'Authorization URL',
45
26
  name: 'authUrl',
@@ -1,8 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateJSON = exports.serialiseMauticWhere = exports.mauticApiRequestAllItems = exports.DEFAULT_MAUTIC_PAGE_SIZE = exports.mauticApiRequest = void 0;
3
+ exports.validateJSON = exports.serialiseMauticWhere = exports.mauticApiRequestAllItems = exports.DEFAULT_MAUTIC_PAGE_SIZE = exports.mauticApiRequest = exports.getMauticVersion = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
5
  const authenticatedRequest_1 = require("./utils/authenticatedRequest");
6
+ const versionCache = new Map();
7
+ const VERSION_CACHE_TTL_MS = 5 * 60 * 1000;
8
+ function normalizeInstanceUrl(raw) {
9
+ const trimmed = raw.trim();
10
+ if (!trimmed)
11
+ return '';
12
+ try {
13
+ const u = new URL(trimmed);
14
+ u.protocol = u.protocol.toLowerCase();
15
+ u.hostname = u.hostname.toLowerCase();
16
+ u.hash = '';
17
+ u.search = '';
18
+ u.pathname = u.pathname.replace(/\/+$/, '');
19
+ return u.toString().replace(/\/+$/, '');
20
+ }
21
+ catch {
22
+ return trimmed.replace(/\/+$/, '');
23
+ }
24
+ }
25
+ async function getMauticVersion(context) {
26
+ const authMethod = context.getNodeParameter('authentication', 0, 'credentials');
27
+ const credentialType = authMethod === 'credentials' ? 'mauticAdvancedApi' : 'mauticAdvancedOAuth2Api';
28
+ const credentials = await context.getCredentials(credentialType);
29
+ const baseUrl = normalizeInstanceUrl(credentials.url || '');
30
+ const cacheKey = `${credentialType}:${baseUrl}`;
31
+ const cached = versionCache.get(cacheKey);
32
+ if (cached && Date.now() < cached.expiresAt) {
33
+ return cached.version;
34
+ }
35
+ let version;
36
+ try {
37
+ await mauticApiRequest.call(context, 'GET', '/v2/companies', {}, { page: 1 }, undefined, {
38
+ Accept: 'application/json',
39
+ });
40
+ version = 'v7';
41
+ }
42
+ catch (error) {
43
+ // 403 = v2 route exists but no permission → still v7; 404 = route absent → v6
44
+ version = error?.httpCode === '403' ? 'v7' : 'v6';
45
+ }
46
+ versionCache.set(cacheKey, { version, expiresAt: Date.now() + VERSION_CACHE_TTL_MS });
47
+ return version;
48
+ }
49
+ exports.getMauticVersion = getMauticVersion;
6
50
  async function mauticApiRequest(method, endpoint, body = {}, query, uri, headers) {
7
51
  const authenticationMethod = this.getNodeParameter('authentication', 0, 'credentials');
8
52
  const options = {
@@ -17,7 +61,7 @@ async function mauticApiRequest(method, endpoint, body = {}, query, uri, headers
17
61
  }
18
62
  try {
19
63
  const returnData = await (0, authenticatedRequest_1.requestMauticAuthenticated)(this, authenticationMethod, options);
20
- if (returnData.errors) {
64
+ if (returnData?.errors) {
21
65
  // They seem to sometimes return 200 status but still error.
22
66
  // Preserve the full error object including details for better error handling
23
67
  throw new n8n_workflow_1.NodeApiError(this.getNode(), returnData, {
@@ -69,13 +69,9 @@ function buildFilters(params) {
69
69
  async function apiRequest(context, method, endpoint, body = {}, query = {}) {
70
70
  return GenericFunctions_1.mauticApiRequest.call(context, method, endpoint, body, query);
71
71
  }
72
- // Detect mautic version from credentials
73
72
  async function getMauticVersionFromContext(context) {
74
73
  try {
75
- const authMethod = context.getNodeParameter('authentication', 0, 'credentials');
76
- const credName = authMethod === 'oAuth2' ? 'mauticAdvancedOAuth2Api' : 'mauticAdvancedApi';
77
- const credentials = await context.getCredentials(credName);
78
- return credentials.mauticVersion || 'v6';
74
+ return await (0, GenericFunctions_1.getMauticVersion)(context);
79
75
  }
80
76
  catch {
81
77
  return 'v6';
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeCompanyOperation = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
5
  const ApiHelpers_1 = require("../utils/ApiHelpers");
6
+ const GenericFunctions_1 = require("../GenericFunctions");
6
7
  const DataHelpers_1 = require("../utils/DataHelpers");
7
8
  async function executeCompanyOperation(context, operation, i) {
8
9
  let responseData;
@@ -36,44 +37,93 @@ exports.executeCompanyOperation = executeCompanyOperation;
36
37
  async function createCompany(context, itemIndex) {
37
38
  const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
38
39
  const name = (0, ApiHelpers_1.getRequiredParam)(context, 'name', itemIndex);
39
- const body = { companyname: name };
40
+ const mauticVersion = await (0, GenericFunctions_1.getMauticVersion)(context);
40
41
  const additionalFields = (0, ApiHelpers_1.getOptionalParam)(context, 'additionalFields', itemIndex, {});
41
- const { addressUi, customFieldsUi, companyEmail, fax, industry, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = additionalFields;
42
- if (addressUi?.addressValues) {
43
- const { addressValues } = addressUi;
44
- body.companyaddress1 = addressValues.address1;
45
- body.companyaddress2 = addressValues.address2;
46
- body.companycity = addressValues.city;
47
- body.companystate = addressValues.state;
48
- body.companycountry = addressValues.country;
49
- body.companyzipcode = addressValues.zipCode;
50
- }
51
- if (companyEmail)
52
- body.companyemail = companyEmail;
53
- if (fax)
54
- body.companyfax = fax;
55
- if (industry)
56
- body.companyindustry = industry;
57
- if (numberOfEmployees)
58
- body.companynumber_of_employees = numberOfEmployees;
59
- if (owner)
60
- body.owner = owner;
61
- if (phone)
62
- body.companyphone = phone;
63
- if (website)
64
- body.companywebsite = website;
65
- if (annualRevenue)
66
- body.companyannual_revenue = annualRevenue;
67
- if (description)
68
- body.companydescription = description;
42
+ const { addressUi, customFieldsUi, companyEmail, fax, industry, isPublished, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = additionalFields;
43
+ const body = {};
44
+ if (mauticVersion === 'v7') {
45
+ body.name = name;
46
+ if (addressUi?.addressValues) {
47
+ const { addressValues } = addressUi;
48
+ if (addressValues.address1)
49
+ body.address1 = addressValues.address1;
50
+ if (addressValues.address2)
51
+ body.address2 = addressValues.address2;
52
+ if (addressValues.city)
53
+ body.city = addressValues.city;
54
+ if (addressValues.state)
55
+ body.state = addressValues.state;
56
+ if (addressValues.country)
57
+ body.country = addressValues.country;
58
+ if (addressValues.zipCode)
59
+ body.zipcode = addressValues.zipCode;
60
+ }
61
+ if (companyEmail)
62
+ body.email = companyEmail;
63
+ if (industry)
64
+ body.industry = industry;
65
+ if (isPublished !== undefined)
66
+ body.isPublished = isPublished;
67
+ if (owner)
68
+ body.owner = `/api/v2/users/${owner}`;
69
+ if (phone)
70
+ body.phone = phone;
71
+ if (website)
72
+ body.website = website;
73
+ if (description)
74
+ body.description = description;
75
+ // fax, numberOfEmployees, annualRevenue not in v7 Company entity write group — omitted
76
+ }
77
+ else {
78
+ body.companyname = name;
79
+ if (addressUi?.addressValues) {
80
+ const { addressValues } = addressUi;
81
+ body.companyaddress1 = addressValues.address1;
82
+ body.companyaddress2 = addressValues.address2;
83
+ body.companycity = addressValues.city;
84
+ body.companystate = addressValues.state;
85
+ body.companycountry = addressValues.country;
86
+ body.companyzipcode = addressValues.zipCode;
87
+ }
88
+ if (companyEmail)
89
+ body.companyemail = companyEmail;
90
+ if (fax)
91
+ body.companyfax = fax;
92
+ if (industry)
93
+ body.companyindustry = industry;
94
+ if (numberOfEmployees)
95
+ body.companynumber_of_employees = numberOfEmployees;
96
+ if (owner)
97
+ body.owner = owner;
98
+ if (phone)
99
+ body.companyphone = phone;
100
+ if (website)
101
+ body.companywebsite = website;
102
+ if (annualRevenue)
103
+ body.companyannual_revenue = annualRevenue;
104
+ if (description)
105
+ body.companydescription = description;
106
+ }
69
107
  if (customFieldsUi?.customFieldValues) {
70
108
  const { customFieldValues } = customFieldsUi;
71
109
  const data = customFieldValues.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
72
110
  Object.assign(body, data);
73
111
  }
74
- Object.assign(body, rest);
75
- const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', '/companies/new', body);
76
- let result = response.company;
112
+ // v7 API Platform rejects unknown fields; rest only applies to v1
113
+ if (mauticVersion !== 'v7')
114
+ Object.assign(body, rest);
115
+ let result;
116
+ if (mauticVersion === 'v7') {
117
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', '/v2/companies', body, {}, undefined, {
118
+ 'Content-Type': 'application/json',
119
+ Accept: 'application/json',
120
+ });
121
+ result = response;
122
+ }
123
+ else {
124
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', '/companies/new', body);
125
+ result = response.company;
126
+ }
77
127
  if (simple) {
78
128
  result = toSimpleCompany(result);
79
129
  }
@@ -82,70 +132,168 @@ async function createCompany(context, itemIndex) {
82
132
  async function updateCompany(context, itemIndex) {
83
133
  const companyId = (0, ApiHelpers_1.getRequiredParam)(context, 'companyId', itemIndex);
84
134
  const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
135
+ const mauticVersion = await (0, GenericFunctions_1.getMauticVersion)(context);
85
136
  const body = {};
86
137
  const updateFields = (0, ApiHelpers_1.getOptionalParam)(context, 'updateFields', itemIndex, {});
87
- const { addressUi, customFieldsUi, companyEmail, name, fax, industry, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = updateFields;
88
- if (addressUi?.addressValues) {
89
- const { addressValues } = addressUi;
90
- body.companyaddress1 = addressValues.address1;
91
- body.companyaddress2 = addressValues.address2;
92
- body.companycity = addressValues.city;
93
- body.companystate = addressValues.state;
94
- body.companycountry = addressValues.country;
95
- body.companyzipcode = addressValues.zipCode;
96
- }
97
- if (companyEmail)
98
- body.companyemail = companyEmail;
99
- if (name)
100
- body.companyname = name;
101
- if (fax)
102
- body.companyfax = fax;
103
- if (industry)
104
- body.companyindustry = industry;
105
- if (numberOfEmployees)
106
- body.companynumber_of_employees = numberOfEmployees;
107
- if (owner)
108
- body.owner = owner;
109
- if (phone)
110
- body.companyphone = phone;
111
- if (website)
112
- body.companywebsite = website;
113
- if (annualRevenue)
114
- body.companyannual_revenue = annualRevenue;
115
- if (description)
116
- body.companydescription = description;
138
+ const { addressUi, customFieldsUi, companyEmail, name, fax, industry, isPublished, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = updateFields;
139
+ if (mauticVersion === 'v7') {
140
+ if (name)
141
+ body.name = name;
142
+ if (addressUi?.addressValues) {
143
+ const { addressValues } = addressUi;
144
+ if (addressValues.address1)
145
+ body.address1 = addressValues.address1;
146
+ if (addressValues.address2)
147
+ body.address2 = addressValues.address2;
148
+ if (addressValues.city)
149
+ body.city = addressValues.city;
150
+ if (addressValues.state)
151
+ body.state = addressValues.state;
152
+ if (addressValues.country)
153
+ body.country = addressValues.country;
154
+ if (addressValues.zipCode)
155
+ body.zipcode = addressValues.zipCode;
156
+ }
157
+ if (companyEmail)
158
+ body.email = companyEmail;
159
+ if (industry)
160
+ body.industry = industry;
161
+ if (isPublished !== undefined)
162
+ body.isPublished = isPublished;
163
+ if (owner)
164
+ body.owner = `/api/v2/users/${owner}`;
165
+ if (phone)
166
+ body.phone = phone;
167
+ if (website)
168
+ body.website = website;
169
+ if (description)
170
+ body.description = description;
171
+ // fax, numberOfEmployees, annualRevenue not in v7 Company entity write group — omitted
172
+ }
173
+ else {
174
+ if (name)
175
+ body.companyname = name;
176
+ if (addressUi?.addressValues) {
177
+ const { addressValues } = addressUi;
178
+ body.companyaddress1 = addressValues.address1;
179
+ body.companyaddress2 = addressValues.address2;
180
+ body.companycity = addressValues.city;
181
+ body.companystate = addressValues.state;
182
+ body.companycountry = addressValues.country;
183
+ body.companyzipcode = addressValues.zipCode;
184
+ }
185
+ if (companyEmail)
186
+ body.companyemail = companyEmail;
187
+ if (fax)
188
+ body.companyfax = fax;
189
+ if (industry)
190
+ body.companyindustry = industry;
191
+ if (numberOfEmployees)
192
+ body.companynumber_of_employees = numberOfEmployees;
193
+ if (owner)
194
+ body.owner = owner;
195
+ if (phone)
196
+ body.companyphone = phone;
197
+ if (website)
198
+ body.companywebsite = website;
199
+ if (annualRevenue)
200
+ body.companyannual_revenue = annualRevenue;
201
+ if (description)
202
+ body.companydescription = description;
203
+ }
117
204
  if (customFieldsUi?.customFieldValues) {
118
205
  const { customFieldValues } = customFieldsUi;
119
206
  const data = customFieldValues.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
120
207
  Object.assign(body, data);
121
208
  }
122
- Object.assign(body, rest);
123
- const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'PATCH', `/companies/${companyId}/edit`, body);
124
- let result = response.company;
209
+ // v7 API Platform rejects unknown fields; rest only applies to v1
210
+ if (mauticVersion !== 'v7')
211
+ Object.assign(body, rest);
212
+ let result;
213
+ if (mauticVersion === 'v7') {
214
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'PATCH', `/v2/companies/${companyId}`, body, {}, undefined, { 'Content-Type': 'application/merge-patch+json', Accept: 'application/json' });
215
+ result = response;
216
+ }
217
+ else {
218
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'PATCH', `/companies/${companyId}/edit`, body);
219
+ result = response.company;
220
+ }
125
221
  if (simple) {
126
222
  result = toSimpleCompany(result);
127
223
  }
128
224
  return result;
129
225
  }
226
+ // Extract owner from a v7 company object. Requests without Accept: application/json
227
+ // return JSON-LD where the owner IRI (/api/v2/users/{id}) lets us resolve the user ID.
228
+ function extractOwnerFromV7(v7Item) {
229
+ if (!v7Item || v7Item.owner === null || v7Item.owner === undefined)
230
+ return null;
231
+ const iri = v7Item.owner?.['@id'];
232
+ if (iri) {
233
+ const match = /\/(\d+)$/.exec(iri);
234
+ if (match)
235
+ return { id: Number(match[1]) };
236
+ }
237
+ // No @id (non-Hydra response) — return partial FormEntity data as-is
238
+ return v7Item.owner;
239
+ }
240
+ // Fetch all companies from v7 and return a map of companyId → owner.
241
+ // Called without Accept: application/json so the response includes JSON-LD @id on the owner.
242
+ async function buildV7OwnerMap(context) {
243
+ const ownerMap = new Map();
244
+ let page = 1;
245
+ const MAX_PAGES = 100;
246
+ while (page <= MAX_PAGES) {
247
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', '/v2/companies', {}, { page });
248
+ const items = Array.isArray(response)
249
+ ? response
250
+ : (response?.['hydra:member'] ?? []);
251
+ if (!items.length)
252
+ break;
253
+ for (const item of items) {
254
+ const id = Number(item.id);
255
+ if (id)
256
+ ownerMap.set(id, extractOwnerFromV7(item));
257
+ }
258
+ const total = response?.['hydra:totalItems'];
259
+ if (typeof total === 'number' && ownerMap.size >= total)
260
+ break;
261
+ page++;
262
+ }
263
+ return ownerMap;
264
+ }
130
265
  async function getCompany(context, itemIndex) {
131
266
  const companyId = (0, ApiHelpers_1.getRequiredParam)(context, 'companyId', itemIndex);
132
267
  const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
133
- const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', `/companies/${companyId}`);
134
- let result = response.company;
135
- if (simple) {
136
- result = toSimpleCompany(result);
268
+ const mauticVersion = await (0, GenericFunctions_1.getMauticVersion)(context);
269
+ // v1: custom fields via fields.all
270
+ const v1Response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', `/companies/${companyId}`);
271
+ let result = v1Response.company;
272
+ if (mauticVersion === 'v7') {
273
+ try {
274
+ // No Accept: application/json — JSON-LD response includes owner @id for user ID extraction
275
+ const v7Company = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', `/v2/companies/${companyId}`);
276
+ result = { ...result, owner: extractOwnerFromV7(v7Company) };
277
+ }
278
+ catch {
279
+ // enrichment failed — proceed with v1 data (owner: null)
280
+ }
137
281
  }
282
+ if (simple)
283
+ result = toSimpleCompany(result);
138
284
  return (0, DataHelpers_1.convertNumericStrings)(result);
139
285
  }
140
286
  async function getAllCompanies(context, itemIndex) {
141
287
  const returnAll = (0, ApiHelpers_1.getOptionalParam)(context, 'returnAll', itemIndex, false);
142
288
  const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
289
+ const mauticVersion = await (0, GenericFunctions_1.getMauticVersion)(context);
143
290
  const additionalFields = (0, ApiHelpers_1.getOptionalParam)(context, 'additionalFields', itemIndex, {});
144
291
  const qs = (0, DataHelpers_1.buildQueryFromOptions)(additionalFields);
145
292
  if (!qs.orderBy)
146
293
  qs.orderBy = 'id';
147
294
  if (!qs.orderByDir)
148
295
  qs.orderByDir = 'asc';
296
+ // v1: custom fields via fields.all
149
297
  let responseData;
150
298
  if (returnAll) {
151
299
  const limit = (0, ApiHelpers_1.getOptionalParam)(context, 'limit', itemIndex, undefined);
@@ -157,6 +305,19 @@ async function getAllCompanies(context, itemIndex) {
157
305
  const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', '/companies', {}, qs);
158
306
  responseData = (response.companies ? Object.values(response.companies) : []);
159
307
  }
308
+ if (mauticVersion === 'v7') {
309
+ try {
310
+ // v7 enrichment: overlay owner on each v1 result using a single paginated v7 fetch
311
+ const ownerMap = await buildV7OwnerMap(context);
312
+ responseData = responseData.map((company) => ({
313
+ ...company,
314
+ owner: ownerMap.get(Number(company.id)) ?? null,
315
+ }));
316
+ }
317
+ catch {
318
+ // enrichment failed — proceed with v1 data (owner: null)
319
+ }
320
+ }
160
321
  if (simple) {
161
322
  responseData = responseData.map((item) => toSimpleCompany(item));
162
323
  }
@@ -165,6 +326,14 @@ async function getAllCompanies(context, itemIndex) {
165
326
  async function deleteCompany(context, itemIndex) {
166
327
  const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
167
328
  const companyId = (0, ApiHelpers_1.getRequiredParam)(context, 'companyId', itemIndex);
329
+ const mauticVersion = await (0, GenericFunctions_1.getMauticVersion)(context);
330
+ if (mauticVersion === 'v7') {
331
+ // v7 DELETE returns 204 no body
332
+ await (0, ApiHelpers_1.makeApiRequest)(context, 'DELETE', `/v2/companies/${companyId}`, {}, {}, undefined, {
333
+ Accept: 'application/json',
334
+ });
335
+ return { id: Number(companyId) };
336
+ }
168
337
  const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'DELETE', `/companies/${companyId}/delete`);
169
338
  let result = response.company;
170
339
  if (simple) {
@@ -173,9 +342,19 @@ async function deleteCompany(context, itemIndex) {
173
342
  return result;
174
343
  }
175
344
  function toSimpleCompany(company) {
345
+ if (company?.fields?.all) {
346
+ // v1: fields nested under company.fields.all
347
+ return {
348
+ id: company.id,
349
+ owner: company.owner ?? null,
350
+ ...company.fields.all,
351
+ };
352
+ }
353
+ // v7: fields are at the top level; owner is a User object
354
+ const { id, owner, score, socialCache, dateAdded, dateModified, isPublished, ...fields } = company;
176
355
  return {
177
- id: company.id,
178
- owner: company.owner ?? null,
179
- ...company.fields.all,
356
+ id,
357
+ owner: owner ?? null,
358
+ ...fields,
180
359
  };
181
360
  }
@@ -3,18 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteTagV2 = exports.getAllTagsV2 = exports.getTagV2 = exports.updateTagV2 = exports.createTagV2 = exports.deleteTagV1 = exports.getAllTagsV1 = exports.getTagV1 = exports.updateTagV1 = exports.createTagV1 = exports.getMauticVersion = void 0;
4
4
  const ApiHelpers_1 = require("../utils/ApiHelpers");
5
5
  const DataHelpers_1 = require("../utils/DataHelpers");
6
- async function getMauticVersion(context) {
7
- const authenticationMethod = context.getNodeParameter('authentication', 0, 'credentials');
8
- if (authenticationMethod === 'credentials') {
9
- const credentials = await context.getCredentials('mauticAdvancedApi');
10
- const version = credentials.mauticVersion || 'v6';
11
- return version === 'v7' ? 'v7' : 'v6';
12
- }
13
- const credentials = await context.getCredentials('mauticAdvancedOAuth2Api');
14
- const version = credentials.mauticVersion || 'v6';
15
- return version === 'v7' ? 'v7' : 'v6';
16
- }
17
- exports.getMauticVersion = getMauticVersion;
6
+ const GenericFunctions_1 = require("../GenericFunctions");
7
+ Object.defineProperty(exports, "getMauticVersion", { enumerable: true, get: function () { return GenericFunctions_1.getMauticVersion; } });
18
8
  // -----------------------------
19
9
  // v1 tag helpers (legacy API)
20
10
  // -----------------------------
@@ -30,9 +30,6 @@ function normalizeCredentialUrl(value) {
30
30
  return withoutTrailingSlashes(trimmed);
31
31
  }
32
32
  }
33
- function getMauticVersion(credentials) {
34
- return String(credentials.mauticVersion || 'v6');
35
- }
36
33
  function credentialRefPart(value) {
37
34
  if (typeof value === 'string' && value) {
38
35
  return value;
@@ -64,7 +61,6 @@ function getCacheKey(authenticationMethod, credentialType, credentialReference,
64
61
  credentialType,
65
62
  credentialReference,
66
63
  normalizeCredentialUrl(credentials.url),
67
- getMauticVersion(credentials),
68
64
  datasetKey,
69
65
  ]);
70
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-mautic-advanced",
3
- "version": "1.2.1",
3
+ "version": "1.3.2",
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",