n8n-nodes-oxsr-technical-utils 4.2.31 → 4.2.32

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 (43) hide show
  1. package/dist/nodes/OXSRTechnicalUtils/OXSRTechnicalUtils.node.js +64 -9
  2. package/dist/nodes/OXSRTechnicalUtils/OXSRTechnicalUtils.node.js.map +1 -1
  3. package/dist/nodes/OXSRTechnicalUtils/actions/actions.js +40 -5
  4. package/dist/nodes/OXSRTechnicalUtils/actions/actions.js.map +1 -1
  5. package/dist/nodes/OXSRTechnicalUtils/actions/content.js +322 -136
  6. package/dist/nodes/OXSRTechnicalUtils/actions/content.js.map +1 -1
  7. package/dist/nodes/OXSRTechnicalUtils/actions/database.js +17 -2
  8. package/dist/nodes/OXSRTechnicalUtils/actions/database.js.map +1 -1
  9. package/dist/nodes/OXSRTechnicalUtils/actions/dbAdvanced.js +30 -3
  10. package/dist/nodes/OXSRTechnicalUtils/actions/dbAdvanced.js.map +1 -1
  11. package/dist/nodes/OXSRTechnicalUtils/actions/email.js +27 -4
  12. package/dist/nodes/OXSRTechnicalUtils/actions/email.js.map +1 -1
  13. package/dist/nodes/OXSRTechnicalUtils/actions/iaDev.js +48 -13
  14. package/dist/nodes/OXSRTechnicalUtils/actions/iaDev.js.map +1 -1
  15. package/dist/nodes/OXSRTechnicalUtils/actions/logs.js +25 -2
  16. package/dist/nodes/OXSRTechnicalUtils/actions/logs.js.map +1 -1
  17. package/dist/nodes/OXSRTechnicalUtils/actions/media.js +44 -14
  18. package/dist/nodes/OXSRTechnicalUtils/actions/media.js.map +1 -1
  19. package/dist/nodes/OXSRTechnicalUtils/actions/metrics.js +26 -3
  20. package/dist/nodes/OXSRTechnicalUtils/actions/metrics.js.map +1 -1
  21. package/dist/nodes/OXSRTechnicalUtils/actions/multisite.js +24 -1
  22. package/dist/nodes/OXSRTechnicalUtils/actions/multisite.js.map +1 -1
  23. package/dist/nodes/OXSRTechnicalUtils/actions/performance.js +46 -27
  24. package/dist/nodes/OXSRTechnicalUtils/actions/performance.js.map +1 -1
  25. package/dist/nodes/OXSRTechnicalUtils/actions/plugins.js +32 -9
  26. package/dist/nodes/OXSRTechnicalUtils/actions/plugins.js.map +1 -1
  27. package/dist/nodes/OXSRTechnicalUtils/actions/security.js +24 -1
  28. package/dist/nodes/OXSRTechnicalUtils/actions/security.js.map +1 -1
  29. package/dist/nodes/OXSRTechnicalUtils/actions/seo.js +56 -19
  30. package/dist/nodes/OXSRTechnicalUtils/actions/seo.js.map +1 -1
  31. package/dist/nodes/OXSRTechnicalUtils/actions/server.js +58 -31
  32. package/dist/nodes/OXSRTechnicalUtils/actions/server.js.map +1 -1
  33. package/dist/nodes/OXSRTechnicalUtils/actions/settings.js +61 -26
  34. package/dist/nodes/OXSRTechnicalUtils/actions/settings.js.map +1 -1
  35. package/dist/nodes/OXSRTechnicalUtils/actions/updates.js +24 -1
  36. package/dist/nodes/OXSRTechnicalUtils/actions/updates.js.map +1 -1
  37. package/dist/nodes/OXSRTechnicalUtils/actions/users.js +51 -16
  38. package/dist/nodes/OXSRTechnicalUtils/actions/users.js.map +1 -1
  39. package/dist/nodes/OXSRTechnicalUtils/actions/woo.js +29 -6
  40. package/dist/nodes/OXSRTechnicalUtils/actions/woo.js.map +1 -1
  41. package/dist/package.json +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +1 -1
@@ -28,20 +28,88 @@ function getOptionalNodeParameter(context, name, fallback) {
28
28
  }
29
29
  function firstNonEmptyParam(context, names, fallback) {
30
30
  for (const name of names) {
31
- try {
32
- const val = context.getNodeParameter(name);
33
- if (val !== undefined && val !== null && val !== '' && val !== 0)
34
- return val;
35
- }
36
- catch { }
37
31
  if (context.rawInput && name in context.rawInput) {
38
32
  const val = context.rawInput[name];
39
- if (val !== undefined && val !== null && val !== '' && val !== 0)
33
+ if (val !== undefined && val !== null && val !== '')
40
34
  return val;
41
35
  }
42
36
  }
37
+ for (const name of names) {
38
+ const val = getOptionalNodeParameter(context, name, undefined);
39
+ if (val !== undefined && val !== null && val !== '' && val !== 0 && val !== false)
40
+ return val;
41
+ }
43
42
  return fallback;
44
43
  }
44
+ function parseBoolean(value) {
45
+ if (typeof value === 'boolean')
46
+ return value;
47
+ if (typeof value === 'number')
48
+ return value !== 0;
49
+ const raw = String(value !== null && value !== void 0 ? value : '').trim().toLowerCase();
50
+ if (['true', '1', 'yes', 'y', 'si', 'sí', 'on'].includes(raw))
51
+ return true;
52
+ if (['false', '0', 'no', 'n', 'off', ''].includes(raw))
53
+ return false;
54
+ return Boolean(value);
55
+ }
56
+ function parseLooseList(value) {
57
+ if (Array.isArray(value)) {
58
+ return value
59
+ .flatMap((item) => parseLooseList(item))
60
+ .map((item) => item.trim())
61
+ .filter((item) => item !== '');
62
+ }
63
+ const raw = String(value !== null && value !== void 0 ? value : '').trim();
64
+ if (!raw)
65
+ return [];
66
+ if (raw.startsWith('[')) {
67
+ try {
68
+ const parsed = JSON.parse(raw);
69
+ if (Array.isArray(parsed))
70
+ return parseLooseList(parsed);
71
+ }
72
+ catch { }
73
+ }
74
+ return raw
75
+ .split(/[\n,;]+/g)
76
+ .map((item) => item.trim())
77
+ .filter((item) => item !== '');
78
+ }
79
+ function parseNumberList(value) {
80
+ return parseLooseList(value)
81
+ .map((item) => Number(item))
82
+ .filter((item) => Number.isFinite(item) && item > 0)
83
+ .map((item) => Math.trunc(item));
84
+ }
85
+ function parseObjectList(value) {
86
+ var _a, _b;
87
+ if (Array.isArray(value)) {
88
+ return value.filter((item) => typeof item === 'object' && item !== null && !Array.isArray(item));
89
+ }
90
+ const raw = String(value !== null && value !== void 0 ? value : '').trim();
91
+ if (!raw)
92
+ return [];
93
+ try {
94
+ const parsed = JSON.parse(raw);
95
+ if (Array.isArray(parsed))
96
+ return parseObjectList(parsed);
97
+ if (parsed && typeof parsed === 'object') {
98
+ const rows = (_b = (_a = parsed.posts) !== null && _a !== void 0 ? _a : parsed.updates) !== null && _b !== void 0 ? _b : parsed.items;
99
+ if (Array.isArray(rows))
100
+ return parseObjectList(rows);
101
+ }
102
+ }
103
+ catch { }
104
+ return [];
105
+ }
106
+ function firstObjectValue(row, names) {
107
+ for (const name of names) {
108
+ if (name in row && row[name] !== undefined && row[name] !== null && row[name] !== '')
109
+ return row[name];
110
+ }
111
+ return undefined;
112
+ }
45
113
  function extractFirstImgSrcFromHtml(html) {
46
114
  const match = html.match(/<img[^>]+src\s*=\s*["']([^"']+)["']/i);
47
115
  if (!match || !match[1])
@@ -49,11 +117,11 @@ function extractFirstImgSrcFromHtml(html) {
49
117
  return normalizeMenuItemUrl(match[1]);
50
118
  }
51
119
  async function execute(context, _credentials) {
52
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43;
120
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46;
53
121
  if (context.operation === 'getPosts') {
54
- const status = String((_a = context.getNodeParameter('status')) !== null && _a !== void 0 ? _a : 'publish');
55
- const limitRaw = Number((_b = context.getNodeParameter('limit')) !== null && _b !== void 0 ? _b : 20);
56
- const offsetRaw = Number((_c = context.getNodeParameter('offset')) !== null && _c !== void 0 ? _c : 0);
122
+ const status = String((_a = firstNonEmptyParam(context, ['status', 'Status'], 'publish')) !== null && _a !== void 0 ? _a : 'publish');
123
+ const limitRaw = Number((_b = firstNonEmptyParam(context, ['limit', 'Limit'], 20)) !== null && _b !== void 0 ? _b : 20);
124
+ const offsetRaw = Number((_c = firstNonEmptyParam(context, ['offset', 'Offset'], 0)) !== null && _c !== void 0 ? _c : 0);
57
125
  const limit = Math.max(1, Number.isFinite(limitRaw) ? Math.trunc(limitRaw) : 20);
58
126
  const offset = Math.max(0, Number.isFinite(offsetRaw) ? Math.trunc(offsetRaw) : 0);
59
127
  const data = await context.callPlugin('GET', 'content/posts', { status, limit, offset });
@@ -68,8 +136,8 @@ async function execute(context, _credentials) {
68
136
  return data;
69
137
  }
70
138
  if (context.operation === 'checkInternalLinks') {
71
- const limitRaw = Number((_d = getOptionalNodeParameter(context, 'internalLinksLimit', getOptionalNodeParameter(context, 'Limit', getOptionalNodeParameter(context, 'limit', 25)))) !== null && _d !== void 0 ? _d : 25);
72
- const status = String((_e = getOptionalNodeParameter(context, 'internalLinksStatus', getOptionalNodeParameter(context, 'status', 'publish'))) !== null && _e !== void 0 ? _e : 'publish').trim();
139
+ const limitRaw = Number((_d = firstNonEmptyParam(context, ['internalLinksLimit', 'Limit', 'limit'], 25)) !== null && _d !== void 0 ? _d : 25);
140
+ const status = String((_e = firstNonEmptyParam(context, ['internalLinksStatus', 'status'], 'publish')) !== null && _e !== void 0 ? _e : 'publish').trim();
73
141
  const limit = Math.max(1, Number.isFinite(limitRaw) ? Math.trunc(limitRaw) : 25);
74
142
  const data = await context.callPlugin('GET', 'content/internal-links', { limit, status });
75
143
  return data;
@@ -84,9 +152,9 @@ async function execute(context, _credentials) {
84
152
  const status = String((_k = firstNonEmptyParam(context, ['replaceStatus', 'status'], 'publish')) !== null && _k !== void 0 ? _k : 'publish').trim();
85
153
  const limit_raw = Number((_l = firstNonEmptyParam(context, ['replaceLimit', 'limit'], 50)) !== null && _l !== void 0 ? _l : 50);
86
154
  const limit = Math.max(1, Number.isFinite(limit_raw) ? Math.trunc(limit_raw) : 50);
87
- const case_sensitive = Boolean(firstNonEmptyParam(context, ['replaceCaseSensitive', 'Replace_Case_Sensitive', 'Case_Sensitive', 'Case_Sensitive__Alias_MCP_', 'case_sensitive'], false));
88
- const in_title = Boolean(firstNonEmptyParam(context, ['replaceInTitle', 'In_Title', 'In_Title__Alias_MCP_', 'in_title'], false));
89
- const simulate = Boolean(firstNonEmptyParam(context, ['replaceSimulate', 'Simulate', 'simulate'], false));
155
+ const case_sensitive = parseBoolean(firstNonEmptyParam(context, ['replaceCaseSensitive', 'Replace_Case_Sensitive', 'Case_Sensitive', 'Case_Sensitive__Alias_MCP_', 'case_sensitive'], false));
156
+ const in_title = parseBoolean(firstNonEmptyParam(context, ['replaceInTitle', 'In_Title', 'In_Title__Alias_MCP_', 'in_title'], false));
157
+ const simulate = parseBoolean(firstNonEmptyParam(context, ['replaceSimulate', 'Simulate', 'simulate'], false));
90
158
  const data = await context.callPlugin('POST', 'content/replace-text', undefined, {
91
159
  search_text,
92
160
  replace_text,
@@ -102,16 +170,16 @@ async function execute(context, _credentials) {
102
170
  return data;
103
171
  }
104
172
  if (context.operation === 'createPost') {
105
- const title = String((_m = getOptionalNodeParameter(context, 'title', getOptionalNodeParameter(context, 'Title', ''))) !== null && _m !== void 0 ? _m : '').trim();
106
- const slug = String((_o = getOptionalNodeParameter(context, 'slug', getOptionalNodeParameter(context, 'Slug', ''))) !== null && _o !== void 0 ? _o : '').trim();
107
- const content = String((_p = getOptionalNodeParameter(context, 'contentBody', getOptionalNodeParameter(context, 'Content', ''))) !== null && _p !== void 0 ? _p : '');
108
- const status = String((_q = getOptionalNodeParameter(context, 'statusWrite', getOptionalNodeParameter(context, 'Status__Write_', getOptionalNodeParameter(context, 'status', 'draft')))) !== null && _q !== void 0 ? _q : 'draft').trim();
109
- const type = String((_r = getOptionalNodeParameter(context, 'postType', getOptionalNodeParameter(context, 'type', 'post'))) !== null && _r !== void 0 ? _r : 'post').trim();
110
- const seo_title = String((_s = getOptionalNodeParameter(context, 'seoTitle', getOptionalNodeParameter(context, 'SEO_Title', ''))) !== null && _s !== void 0 ? _s : '').trim();
111
- const seo_description = String((_t = getOptionalNodeParameter(context, 'seoDescription', getOptionalNodeParameter(context, 'SEO_Description', ''))) !== null && _t !== void 0 ? _t : '').trim();
112
- const featured_image_id = Number((_u = getOptionalNodeParameter(context, 'featuredImageId', getOptionalNodeParameter(context, 'Featured_Image_ID', getOptionalNodeParameter(context, 'featured_image_id', getOptionalNodeParameter(context, 'Media_ID', 0))))) !== null && _u !== void 0 ? _u : 0);
113
- const featured_image_url = normalizeMenuItemUrl(getOptionalNodeParameter(context, 'featuredImageUrl', getOptionalNodeParameter(context, 'Featured_Image_URL', getOptionalNodeParameter(context, 'featured_image_url', getOptionalNodeParameter(context, 'Media_URL', '')))));
114
- const categoriesRaw = String((_v = getOptionalNodeParameter(context, 'categoriesCsv', getOptionalNodeParameter(context, 'Categories_CSV', ''))) !== null && _v !== void 0 ? _v : '').trim();
173
+ const title = String((_m = firstNonEmptyParam(context, ['title', 'Title'], '')) !== null && _m !== void 0 ? _m : '').trim();
174
+ const slug = String((_o = firstNonEmptyParam(context, ['slug', 'Slug'], '')) !== null && _o !== void 0 ? _o : '').trim();
175
+ const content = String((_p = firstNonEmptyParam(context, ['contentBody', 'Content', 'content'], '')) !== null && _p !== void 0 ? _p : '');
176
+ const status = String((_q = firstNonEmptyParam(context, ['statusWrite', 'Status__Write_', 'status'], 'draft')) !== null && _q !== void 0 ? _q : 'draft').trim();
177
+ const type = String((_r = firstNonEmptyParam(context, ['postType', 'type'], 'post')) !== null && _r !== void 0 ? _r : 'post').trim();
178
+ const seo_title = String((_s = firstNonEmptyParam(context, ['seoTitle', 'SEO_Title', 'seo_title'], '')) !== null && _s !== void 0 ? _s : '').trim();
179
+ const seo_description = String((_t = firstNonEmptyParam(context, ['seoDescription', 'SEO_Description', 'seo_description'], '')) !== null && _t !== void 0 ? _t : '').trim();
180
+ const featured_image_id = Number((_u = firstNonEmptyParam(context, ['featuredImageId', 'Featured_Image_ID', 'featured_image_id', 'Media_ID'], 0)) !== null && _u !== void 0 ? _u : 0);
181
+ const featured_image_url = normalizeMenuItemUrl(firstNonEmptyParam(context, ['featuredImageUrl', 'Featured_Image_URL', 'featured_image_url', 'Media_URL'], ''));
182
+ const categoriesRaw = String((_v = firstNonEmptyParam(context, ['categoriesCsv', 'Categories_CSV', 'Categories', 'categories'], '')) !== null && _v !== void 0 ? _v : '').trim();
115
183
  const categories = categoriesRaw
116
184
  ? categoriesRaw.split(',').map((x) => Number(x.trim())).filter((n) => Number.isFinite(n) && n > 0)
117
185
  : [];
@@ -130,105 +198,217 @@ async function execute(context, _credentials) {
130
198
  return data;
131
199
  }
132
200
  if (context.operation === 'updatePost') {
133
- const postIdRaw = Number((_w = firstNonEmptyParam(context, ['postId', 'Post_ID', 'post_id'], 0)) !== null && _w !== void 0 ? _w : 0);
134
- const post_id = Number.isFinite(postIdRaw) ? Math.trunc(postIdRaw) : 0;
201
+ const targets = [];
202
+ const seenTargets = new Set();
203
+ const addTarget = (target) => {
204
+ var _a, _b;
205
+ const postId = Number((_a = target.post_id) !== null && _a !== void 0 ? _a : 0);
206
+ const postUrl = normalizeMenuItemUrl((_b = target.post_url) !== null && _b !== void 0 ? _b : '');
207
+ if (postId <= 0 && postUrl === '')
208
+ return;
209
+ const key = postId > 0 ? `id:${postId}` : `url:${postUrl.toLowerCase()}`;
210
+ if (seenTargets.has(key))
211
+ return;
212
+ seenTargets.add(key);
213
+ targets.push({
214
+ ...(postId > 0 ? { post_id: Math.trunc(postId) } : {}),
215
+ ...(postUrl !== '' ? { post_url: postUrl } : {}),
216
+ ...(target.featured_image_id !== undefined ? { featured_image_id: target.featured_image_id } : {}),
217
+ ...(target.featured_image_url !== undefined && target.featured_image_url !== '' ? { featured_image_url: target.featured_image_url } : {}),
218
+ ...(target.clear_featured_image ? { clear_featured_image: true } : {}),
219
+ });
220
+ };
221
+ const updateRows = parseObjectList(firstNonEmptyParam(context, ['postUpdatesJson', 'Post_Updates_JSON', 'updatesJson', 'Updates_JSON', 'postsJson', 'Posts_JSON'], ''));
222
+ for (const row of updateRows) {
223
+ const rowPostIdRaw = Number((_w = firstObjectValue(row, ['post_id', 'Post_ID', 'postId', 'id'])) !== null && _w !== void 0 ? _w : 0);
224
+ const rowFeaturedIdRaw = firstObjectValue(row, ['featured_image_id', 'Featured_Image_ID', 'featuredImageId', 'Media_ID']);
225
+ const rowFeaturedId = rowFeaturedIdRaw !== undefined ? Number(rowFeaturedIdRaw) : NaN;
226
+ const rowFeaturedUrl = normalizeMenuItemUrl((_x = firstObjectValue(row, ['featured_image_url', 'Featured_Image_URL', 'featuredImageUrl', 'Media_URL'])) !== null && _x !== void 0 ? _x : '');
227
+ addTarget({
228
+ post_id: Number.isFinite(rowPostIdRaw) ? Math.trunc(rowPostIdRaw) : 0,
229
+ post_url: normalizeMenuItemUrl((_y = firstObjectValue(row, ['post_url', 'Post_URL', 'postUrl', 'url'])) !== null && _y !== void 0 ? _y : ''),
230
+ ...(Number.isFinite(rowFeaturedId) && rowFeaturedId > 0 ? { featured_image_id: Math.trunc(rowFeaturedId) } : {}),
231
+ ...(rowFeaturedUrl !== '' ? { featured_image_url: rowFeaturedUrl } : {}),
232
+ ...(parseBoolean((_z = firstObjectValue(row, ['clear_featured_image', 'Clear_Featured_Image', 'clearFeaturedImage'])) !== null && _z !== void 0 ? _z : false)
233
+ ? { clear_featured_image: true }
234
+ : {}),
235
+ });
236
+ }
237
+ const postIdRaw = Number((_0 = firstNonEmptyParam(context, ['postId', 'Post_ID', 'post_id'], 0)) !== null && _0 !== void 0 ? _0 : 0);
238
+ if (Number.isFinite(postIdRaw) && postIdRaw > 0)
239
+ addTarget({ post_id: Math.trunc(postIdRaw) });
240
+ for (const id of parseNumberList(firstNonEmptyParam(context, ['postIdsCsv', 'Post_IDs_CSV', 'Post_Ids_CSV', 'post_ids_csv', 'post_ids'], ''))) {
241
+ addTarget({ post_id: id });
242
+ }
135
243
  const post_url = normalizeMenuItemUrl(firstNonEmptyParam(context, ['postUrl', 'Post_URL', 'post_url'], ''));
136
- const slug = String((_x = firstNonEmptyParam(context, ['slug', 'Slug', 'post_name'], '')) !== null && _x !== void 0 ? _x : '').trim();
137
- let title = String((_y = firstNonEmptyParam(context, ['title', 'Title'], '')) !== null && _y !== void 0 ? _y : '').trim();
138
- let content = String((_z = firstNonEmptyParam(context, ['contentBody', 'Content', 'content'], '')) !== null && _z !== void 0 ? _z : '');
244
+ if (post_url !== '')
245
+ addTarget({ post_url });
246
+ for (const url of parseLooseList(firstNonEmptyParam(context, ['postUrlsCsv', 'Post_URLs_CSV', 'post_urls_csv', 'post_urls'], ''))
247
+ .map((item) => normalizeMenuItemUrl(item))
248
+ .filter((item) => item !== '')) {
249
+ addTarget({ post_url: url });
250
+ }
251
+ const featuredImageIds = parseNumberList(firstNonEmptyParam(context, ['featuredImageIdsCsv', 'Featured_Image_IDs_CSV', 'featured_image_ids_csv', 'mediaIdsCsv', 'Media_IDs_CSV'], ''));
252
+ const featuredImageUrls = parseLooseList(firstNonEmptyParam(context, ['featuredImageUrlsCsv', 'Featured_Image_URLs_CSV', 'featured_image_urls_csv', 'mediaUrlsCsv', 'Media_URLs_CSV'], ''))
253
+ .map((item) => normalizeMenuItemUrl(item))
254
+ .filter((item) => item !== '');
255
+ const singleFeaturedImageIdRaw = Number((_1 = firstNonEmptyParam(context, ['featuredImageId', 'Featured_Image_ID', 'featured_image_id', 'Media_ID'], NaN)) !== null && _1 !== void 0 ? _1 : NaN);
256
+ const singleFeaturedImageId = Number.isFinite(singleFeaturedImageIdRaw) && singleFeaturedImageIdRaw > 0 ? Math.trunc(singleFeaturedImageIdRaw) : 0;
257
+ const singleFeaturedImageUrl = normalizeMenuItemUrl(firstNonEmptyParam(context, ['featuredImageUrl', 'Featured_Image_URL', 'featured_image_url', 'Media_URL'], ''));
258
+ const clearFeaturedImage = parseBoolean(firstNonEmptyParam(context, ['clearFeaturedImage', 'Clear_Featured_Image', 'clear_featured_image'], false));
259
+ targets.forEach((target, index) => {
260
+ if (target.featured_image_id === undefined && featuredImageIds[index] !== undefined) {
261
+ target.featured_image_id = featuredImageIds[index];
262
+ }
263
+ if (target.featured_image_url === undefined && featuredImageUrls[index] !== undefined) {
264
+ target.featured_image_url = featuredImageUrls[index];
265
+ }
266
+ if (target.featured_image_id === undefined && target.featured_image_url === undefined && singleFeaturedImageId > 0) {
267
+ target.featured_image_id = singleFeaturedImageId;
268
+ }
269
+ if (target.featured_image_url === undefined && target.featured_image_id === undefined && singleFeaturedImageUrl !== '') {
270
+ target.featured_image_url = singleFeaturedImageUrl;
271
+ }
272
+ if (clearFeaturedImage)
273
+ target.clear_featured_image = true;
274
+ });
275
+ const slug = String((_2 = firstNonEmptyParam(context, ['slug', 'Slug', 'post_name'], '')) !== null && _2 !== void 0 ? _2 : '').trim();
276
+ let title = String((_3 = firstNonEmptyParam(context, ['title', 'Title'], '')) !== null && _3 !== void 0 ? _3 : '').trim();
277
+ let content = String((_4 = firstNonEmptyParam(context, ['contentBody', 'Content', 'content'], '')) !== null && _4 !== void 0 ? _4 : '');
139
278
  const aiProvidedContent = content !== '';
140
- const status = String((_0 = firstNonEmptyParam(context, ['statusWrite', 'Status__Write_', 'status'], '')) !== null && _0 !== void 0 ? _0 : '').trim();
141
- let seo_title = String((_1 = firstNonEmptyParam(context, ['seoTitle', 'SEO_Title', 'seo_title'], '')) !== null && _1 !== void 0 ? _1 : '').trim();
142
- let seo_description = String((_2 = firstNonEmptyParam(context, ['seoDescription', 'SEO_Description', 'seo_description'], '')) !== null && _2 !== void 0 ? _2 : '').trim();
143
- const featuredImageIdRaw = Number((_3 = firstNonEmptyParam(context, ['featuredImageId', 'Featured_Image_ID', 'featured_image_id', 'Media_ID'], NaN)) !== null && _3 !== void 0 ? _3 : NaN);
144
- const featured_image_id = Number.isFinite(featuredImageIdRaw) ? Math.trunc(featuredImageIdRaw) : NaN;
145
- const clearFeaturedImage = Boolean(firstNonEmptyParam(context, ['clearFeaturedImage', 'Clear_Featured_Image', 'clear_featured_image'], false));
146
- const featured_image_url = normalizeMenuItemUrl(firstNonEmptyParam(context, ['featuredImageUrl', 'Featured_Image_URL', 'featured_image_url', 'Media_URL'], ''));
147
- const hasFeaturedId = Number.isFinite(featured_image_id) && featured_image_id > 0;
148
- const hasFeaturedUrl = featured_image_url !== '';
149
- const hasFeaturedIntent = hasFeaturedId || hasFeaturedUrl || clearFeaturedImage;
150
- if (hasFeaturedIntent && post_id > 0 && (title === '' || content === '' || seo_title === '' || seo_description === '')) {
279
+ const status = String((_5 = firstNonEmptyParam(context, ['statusWrite', 'Status__Write_', 'status'], '')) !== null && _5 !== void 0 ? _5 : '').trim();
280
+ let seo_title = String((_6 = firstNonEmptyParam(context, ['seoTitle', 'SEO_Title', 'seo_title'], '')) !== null && _6 !== void 0 ? _6 : '').trim();
281
+ let seo_description = String((_7 = firstNonEmptyParam(context, ['seoDescription', 'SEO_Description', 'seo_description'], '')) !== null && _7 !== void 0 ? _7 : '').trim();
282
+ const firstTarget = (_8 = targets[0]) !== null && _8 !== void 0 ? _8 : {};
283
+ const firstTargetPostId = Number((_9 = firstTarget.post_id) !== null && _9 !== void 0 ? _9 : 0);
284
+ const firstTargetHasFeaturedIntent = firstTarget.featured_image_id !== undefined || firstTarget.featured_image_url !== undefined || Boolean(firstTarget.clear_featured_image);
285
+ if (targets.length === 0) {
286
+ throw new Error('post_id, post_url, postIdsCsv, postUrlsCsv o postUpdatesJson es obligatorio para updatePost');
287
+ }
288
+ if (firstTargetHasFeaturedIntent && firstTargetPostId > 0 && targets.length === 1 && (title === '' || content === '' || seo_title === '' || seo_description === '')) {
151
289
  try {
152
- const source = (await context.callPlugin('GET', 'content/source', { post_id }));
290
+ const source = (await context.callPlugin('GET', 'content/source', { post_id: firstTargetPostId }));
153
291
  if (title === '') {
154
- title = String((_4 = source.title) !== null && _4 !== void 0 ? _4 : '').trim();
292
+ title = String((_10 = source.title) !== null && _10 !== void 0 ? _10 : '').trim();
155
293
  }
156
294
  if (content === '') {
157
- content = String((_5 = source.raw_content) !== null && _5 !== void 0 ? _5 : '');
295
+ content = String((_11 = source.raw_content) !== null && _11 !== void 0 ? _11 : '');
158
296
  }
159
- const seo = ((_6 = source.seo) !== null && _6 !== void 0 ? _6 : {});
297
+ const seo = ((_12 = source.seo) !== null && _12 !== void 0 ? _12 : {});
160
298
  if (seo_title === '') {
161
- seo_title = String((_7 = seo.title) !== null && _7 !== void 0 ? _7 : '').trim();
299
+ seo_title = String((_13 = seo.title) !== null && _13 !== void 0 ? _13 : '').trim();
162
300
  }
163
301
  if (seo_description === '') {
164
- seo_description = String((_8 = seo.description) !== null && _8 !== void 0 ? _8 : '').trim();
302
+ seo_description = String((_14 = seo.description) !== null && _14 !== void 0 ? _14 : '').trim();
165
303
  }
166
304
  }
167
305
  catch { }
168
306
  }
169
307
  let inferredFeaturedFromContent = '';
170
- if (!hasFeaturedUrl && !hasFeaturedId) {
308
+ if (singleFeaturedImageUrl === '' && singleFeaturedImageId <= 0) {
171
309
  inferredFeaturedFromContent = extractFirstImgSrcFromHtml(content);
172
310
  }
173
- const categoriesRaw = String((_9 = firstNonEmptyParam(context, ['categoriesCsv', 'Categories', 'categories', 'Categories_CSV', 'categories_csv'], '')) !== null && _9 !== void 0 ? _9 : '').trim();
174
- const payload = {};
175
- if (post_id > 0)
176
- payload.post_id = post_id;
177
- if (post_url !== '')
178
- payload.post_url = post_url;
179
- if (post_id <= 0 && post_url === '') {
180
- throw new Error('post_id o post_url es obligatorio para updatePost');
181
- }
182
- if (slug !== '')
183
- payload.slug = slug;
184
- if (title !== '')
185
- payload.title = title;
186
- if (status !== '')
187
- payload.status = status;
188
- if (seo_title !== '')
189
- payload.seo_title = seo_title;
190
- if (seo_description !== '')
191
- payload.seo_description = seo_description;
192
- if (categoriesRaw !== '')
193
- payload.categories = categoriesRaw;
194
- if (hasFeaturedId)
195
- payload.featured_image_id = featured_image_id;
196
- if (hasFeaturedUrl)
197
- payload.featured_image_url = featured_image_url;
198
- if (clearFeaturedImage)
199
- payload.featured_image_id = 0;
200
- if (!hasFeaturedUrl && !hasFeaturedId && inferredFeaturedFromContent !== '') {
201
- payload.featured_image_url = inferredFeaturedFromContent;
202
- }
203
- if (aiProvidedContent) {
204
- payload.content = content;
205
- payload.force_content_replace = true;
206
- }
207
- const data = await context.callPlugin('POST', 'content/update-post', undefined, payload);
208
- const hasFeaturedCheck = hasFeaturedId || hasFeaturedUrl || inferredFeaturedFromContent !== '' || clearFeaturedImage;
209
- if (hasFeaturedCheck) {
210
- const updated = Boolean(data.featured_image_updated);
211
- const alreadyAssigned = Boolean(data.featured_image_already_assigned);
212
- const returnedId = Number((_10 = data.featured_image_id) !== null && _10 !== void 0 ? _10 : 0);
213
- const currentId = Number((_11 = data.featured_image_current_id) !== null && _11 !== void 0 ? _11 : 0);
214
- const assignedOk = clearFeaturedImage
311
+ const categoriesRaw = String((_15 = firstNonEmptyParam(context, ['categoriesCsv', 'Categories', 'categories', 'Categories_CSV', 'categories_csv'], '')) !== null && _15 !== void 0 ? _15 : '').trim();
312
+ const buildPayload = (target) => {
313
+ const payload = {};
314
+ if (target.post_id && target.post_id > 0)
315
+ payload.post_id = target.post_id;
316
+ if (target.post_url && target.post_url !== '')
317
+ payload.post_url = target.post_url;
318
+ if (slug !== '')
319
+ payload.slug = slug;
320
+ if (title !== '')
321
+ payload.title = title;
322
+ if (status !== '')
323
+ payload.status = status;
324
+ if (seo_title !== '')
325
+ payload.seo_title = seo_title;
326
+ if (seo_description !== '')
327
+ payload.seo_description = seo_description;
328
+ if (categoriesRaw !== '')
329
+ payload.categories = categoriesRaw;
330
+ if (target.clear_featured_image) {
331
+ payload.featured_image_id = 0;
332
+ }
333
+ else if (target.featured_image_id !== undefined && target.featured_image_id > 0) {
334
+ payload.featured_image_id = target.featured_image_id;
335
+ }
336
+ else if (target.featured_image_url !== undefined && target.featured_image_url !== '') {
337
+ payload.featured_image_url = target.featured_image_url;
338
+ }
339
+ else if (inferredFeaturedFromContent !== '') {
340
+ payload.featured_image_url = inferredFeaturedFromContent;
341
+ }
342
+ if (aiProvidedContent) {
343
+ payload.content = content;
344
+ payload.force_content_replace = true;
345
+ }
346
+ return {
347
+ payload,
348
+ hasFeaturedCheck: target.clear_featured_image === true ||
349
+ (target.featured_image_id !== undefined && target.featured_image_id > 0) ||
350
+ (target.featured_image_url !== undefined && target.featured_image_url !== '') ||
351
+ inferredFeaturedFromContent !== '',
352
+ expectsClear: target.clear_featured_image === true,
353
+ };
354
+ };
355
+ const assertFeaturedOk = (data, expectsClear) => {
356
+ var _a, _b, _c;
357
+ const updated = parseBoolean(data.featured_image_updated);
358
+ const alreadyAssigned = parseBoolean(data.featured_image_already_assigned);
359
+ const returnedId = Number((_a = data.featured_image_id) !== null && _a !== void 0 ? _a : 0);
360
+ const currentId = Number((_b = data.featured_image_current_id) !== null && _b !== void 0 ? _b : 0);
361
+ const assignedOk = expectsClear
215
362
  ? (updated || (Number.isFinite(currentId) && currentId === 0))
216
363
  : ((Number.isFinite(currentId) && currentId > 0 && Number.isFinite(returnedId) && returnedId > 0 && currentId === returnedId) ||
217
364
  updated ||
218
365
  alreadyAssigned);
219
366
  if (!assignedOk) {
220
- const debugError = String((_12 = data.featured_image_error) !== null && _12 !== void 0 ? _12 : '').trim();
367
+ const debugError = String((_c = data.featured_image_error) !== null && _c !== void 0 ? _c : '').trim();
221
368
  const triedUrls = data.featured_image_tried_urls;
222
369
  const triedText = Array.isArray(triedUrls) && triedUrls.length > 0 ? ` URLs probadas: ${triedUrls.join(', ')}` : '';
223
370
  const suffix = debugError !== '' ? ` Motivo: ${debugError}.` : '';
224
371
  throw new Error(`No se pudo asignar la imagen destacada.${suffix}${triedText}`.trim());
225
372
  }
373
+ };
374
+ if (targets.length === 1) {
375
+ const { payload, hasFeaturedCheck, expectsClear } = buildPayload(targets[0]);
376
+ const data = (await context.callPlugin('POST', 'content/update-post', undefined, payload));
377
+ if (hasFeaturedCheck)
378
+ assertFeaturedOk(data, expectsClear);
379
+ return data;
226
380
  }
227
- return data;
381
+ const results = [];
382
+ for (let index = 0; index < targets.length; index++) {
383
+ const target = targets[index];
384
+ const { payload, hasFeaturedCheck, expectsClear } = buildPayload(target);
385
+ try {
386
+ const data = (await context.callPlugin('POST', 'content/update-post', undefined, payload));
387
+ if (hasFeaturedCheck)
388
+ assertFeaturedOk(data, expectsClear);
389
+ results.push({ success: true, index, ...data });
390
+ }
391
+ catch (error) {
392
+ results.push({
393
+ success: false,
394
+ index,
395
+ post_id: (_16 = target.post_id) !== null && _16 !== void 0 ? _16 : 0,
396
+ post_url: (_17 = target.post_url) !== null && _17 !== void 0 ? _17 : '',
397
+ error: error instanceof Error ? error.message : String(error),
398
+ });
399
+ }
400
+ }
401
+ const failed = results.filter((row) => row.success === false).length;
402
+ return {
403
+ success: failed === 0,
404
+ updated_count: results.length - failed,
405
+ failed_count: failed,
406
+ results,
407
+ };
228
408
  }
229
409
  if (context.operation === 'deletePost') {
230
- const post_id = Number((_13 = context.getNodeParameter('postId')) !== null && _13 !== void 0 ? _13 : 0);
231
- const force = Boolean((_14 = context.getNodeParameter('force')) !== null && _14 !== void 0 ? _14 : false);
410
+ const post_id = Number((_18 = firstNonEmptyParam(context, ['postId', 'Post_ID', 'post_id'], 0)) !== null && _18 !== void 0 ? _18 : 0);
411
+ const force = parseBoolean(firstNonEmptyParam(context, ['force', 'Force_Delete', 'Force'], false));
232
412
  try {
233
413
  const data = await context.callPlugin('DELETE', 'content/delete-post', { post_id, force });
234
414
  return data;
@@ -257,9 +437,9 @@ async function execute(context, _credentials) {
257
437
  return data;
258
438
  }
259
439
  if (context.operation === 'bulkStatus') {
260
- const idsCsv = String((_15 = context.getNodeParameter('postIdsCsv')) !== null && _15 !== void 0 ? _15 : '').trim();
261
- const status = String((_16 = context.getNodeParameter('statusWrite')) !== null && _16 !== void 0 ? _16 : 'draft');
262
- const post_ids = idsCsv.split(',').map((x) => Number(x.trim())).filter((n) => Number.isFinite(n) && n > 0);
440
+ const idsCsv = firstNonEmptyParam(context, ['postIdsCsv', 'Post_IDs_CSV', 'Post_Ids_CSV', 'post_ids_csv', 'post_ids'], '');
441
+ const status = String((_19 = firstNonEmptyParam(context, ['statusWrite', 'Status__Write_', 'status'], 'draft')) !== null && _19 !== void 0 ? _19 : 'draft').trim();
442
+ const post_ids = parseNumberList(idsCsv);
263
443
  const data = await context.callPlugin('POST', 'content/bulk-status', undefined, { post_ids, status });
264
444
  return data;
265
445
  }
@@ -296,24 +476,25 @@ async function execute(context, _credentials) {
296
476
  return data;
297
477
  }
298
478
  if (context.operation === 'getContentSource') {
299
- const post_id = Number((_17 = getOptionalNodeParameter(context, 'sourcePostId', getOptionalNodeParameter(context, 'Source_Post_ID', getOptionalNodeParameter(context, 'post_id', 0)))) !== null && _17 !== void 0 ? _17 : 0);
300
- const focus_keyword = String((_18 = getOptionalNodeParameter(context, 'sourceFocusKeyword', getOptionalNodeParameter(context, 'Source_Focus_Keyword', getOptionalNodeParameter(context, 'focus_keyword', '')))) !== null && _18 !== void 0 ? _18 : '').trim();
479
+ const post_id = Number((_20 = firstNonEmptyParam(context, ['sourcePostId', 'Source_Post_ID', 'post_id', 'Post_ID'], 0)) !== null && _20 !== void 0 ? _20 : 0);
480
+ const focus_keyword = String((_21 = firstNonEmptyParam(context, ['sourceFocusKeyword', 'Source_Focus_Keyword', 'focus_keyword'], '')) !== null && _21 !== void 0 ? _21 : '').trim();
301
481
  return (await context.callPlugin('GET', 'content/source', {
302
482
  post_id,
303
483
  ...(focus_keyword !== '' ? { focus_keyword } : {}),
304
484
  }));
305
485
  }
306
486
  if (context.operation === 'updateContentSource') {
307
- const post_id = Number((_19 = getOptionalNodeParameter(context, 'sourcePostId', getOptionalNodeParameter(context, 'Source_Post_ID', getOptionalNodeParameter(context, 'post_id', 0)))) !== null && _19 !== void 0 ? _19 : 0);
308
- const raw_content = String((_20 = getOptionalNodeParameter(context, 'rawContent', getOptionalNodeParameter(context, 'Raw_Content', ''))) !== null && _20 !== void 0 ? _20 : '');
309
- const title = String((_21 = getOptionalNodeParameter(context, 'sourceTitle', getOptionalNodeParameter(context, 'Title', ''))) !== null && _21 !== void 0 ? _21 : '').trim();
310
- const seo_title = String((_22 = getOptionalNodeParameter(context, 'seoTitle', getOptionalNodeParameter(context, 'SEO_Title', ''))) !== null && _22 !== void 0 ? _22 : '').trim();
311
- const seo_description = String((_23 = getOptionalNodeParameter(context, 'seoDescription', getOptionalNodeParameter(context, 'SEO_Description', ''))) !== null && _23 !== void 0 ? _23 : '').trim();
312
- const focus_keyword = String((_24 = getOptionalNodeParameter(context, 'sourceFocusKeyword', getOptionalNodeParameter(context, 'Source_Focus_Keyword', getOptionalNodeParameter(context, 'focus_keyword', '')))) !== null && _24 !== void 0 ? _24 : '').trim();
313
- const auto_optimize_seo = Boolean(getOptionalNodeParameter(context, 'sourceAutoOptimizeSeo', getOptionalNodeParameter(context, 'Auto_Optimize_SEO', false)));
314
- const featured_image_id_raw = Number((_25 = getOptionalNodeParameter(context, 'featuredImageId', getOptionalNodeParameter(context, 'Featured_Image_ID', getOptionalNodeParameter(context, 'featured_image_id', getOptionalNodeParameter(context, 'Media_ID', 0))))) !== null && _25 !== void 0 ? _25 : 0);
315
- const featured_image_id = Number.isFinite(featured_image_id_raw) ? Math.trunc(featured_image_id_raw) : 0;
316
- const featured_image_url = normalizeMenuItemUrl(getOptionalNodeParameter(context, 'featuredImageUrl', getOptionalNodeParameter(context, 'Featured_Image_URL', getOptionalNodeParameter(context, 'featured_image_url', getOptionalNodeParameter(context, 'Media_URL', '')))));
487
+ const post_id = Number((_22 = firstNonEmptyParam(context, ['sourcePostId', 'Source_Post_ID', 'post_id', 'Post_ID'], 0)) !== null && _22 !== void 0 ? _22 : 0);
488
+ const raw_content = String((_23 = firstNonEmptyParam(context, ['rawContent', 'Raw_Content', 'content'], '')) !== null && _23 !== void 0 ? _23 : '');
489
+ const title = String((_24 = firstNonEmptyParam(context, ['sourceTitle', 'Title', 'title'], '')) !== null && _24 !== void 0 ? _24 : '').trim();
490
+ const seo_title = String((_25 = firstNonEmptyParam(context, ['seoTitle', 'SEO_Title', 'seo_title'], '')) !== null && _25 !== void 0 ? _25 : '').trim();
491
+ const seo_description = String((_26 = firstNonEmptyParam(context, ['seoDescription', 'SEO_Description', 'seo_description'], '')) !== null && _26 !== void 0 ? _26 : '').trim();
492
+ const focus_keyword = String((_27 = firstNonEmptyParam(context, ['sourceFocusKeyword', 'Source_Focus_Keyword', 'focus_keyword'], '')) !== null && _27 !== void 0 ? _27 : '').trim();
493
+ const auto_optimize_seo = parseBoolean(firstNonEmptyParam(context, ['sourceAutoOptimizeSeo', 'Auto_Optimize_SEO', 'auto_optimize_seo'], false));
494
+ const featured_image_id_raw = Number((_28 = firstNonEmptyParam(context, ['featuredImageId', 'Featured_Image_ID', 'featured_image_id', 'Media_ID'], NaN)) !== null && _28 !== void 0 ? _28 : NaN);
495
+ const featured_image_id = Number.isFinite(featured_image_id_raw) && featured_image_id_raw > 0 ? Math.trunc(featured_image_id_raw) : 0;
496
+ const featured_image_url = normalizeMenuItemUrl(firstNonEmptyParam(context, ['featuredImageUrl', 'Featured_Image_URL', 'featured_image_url', 'Media_URL'], ''));
497
+ const clear_featured_image = parseBoolean(firstNonEmptyParam(context, ['clearFeaturedImage', 'Clear_Featured_Image', 'clear_featured_image'], false));
317
498
  const payload = {
318
499
  post_id,
319
500
  raw_content,
@@ -326,21 +507,26 @@ async function execute(context, _credentials) {
326
507
  if (featured_image_url !== '') {
327
508
  payload.featured_image_url = featured_image_url;
328
509
  }
329
- else {
510
+ else if (featured_image_id > 0) {
330
511
  payload.featured_image_id = featured_image_id;
331
512
  }
513
+ else if (clear_featured_image) {
514
+ payload.featured_image_id = 0;
515
+ }
332
516
  const data = (await context.callPlugin('POST', 'content/source', undefined, payload));
333
- const hasFeaturedCheck = featured_image_url !== '' || featured_image_id > 0;
517
+ const hasFeaturedCheck = featured_image_url !== '' || featured_image_id > 0 || clear_featured_image;
334
518
  if (hasFeaturedCheck) {
335
- const updated = Boolean(data.featured_image_updated);
336
- const alreadyAssigned = Boolean(data.featured_image_already_assigned);
337
- const returnedId = Number((_26 = data.featured_image_id) !== null && _26 !== void 0 ? _26 : 0);
338
- const currentId = Number((_27 = data.featured_image_current_id) !== null && _27 !== void 0 ? _27 : 0);
339
- const assignedOk = (Number.isFinite(currentId) && currentId > 0 && Number.isFinite(returnedId) && returnedId > 0 && currentId === returnedId) ||
340
- updated ||
341
- alreadyAssigned;
519
+ const updated = parseBoolean(data.featured_image_updated);
520
+ const alreadyAssigned = parseBoolean(data.featured_image_already_assigned);
521
+ const returnedId = Number((_29 = data.featured_image_id) !== null && _29 !== void 0 ? _29 : 0);
522
+ const currentId = Number((_30 = data.featured_image_current_id) !== null && _30 !== void 0 ? _30 : 0);
523
+ const assignedOk = clear_featured_image
524
+ ? (updated || (Number.isFinite(currentId) && currentId === 0))
525
+ : ((Number.isFinite(currentId) && currentId > 0 && Number.isFinite(returnedId) && returnedId > 0 && currentId === returnedId) ||
526
+ updated ||
527
+ alreadyAssigned);
342
528
  if (!assignedOk) {
343
- const debugError = String((_28 = data.featured_image_error) !== null && _28 !== void 0 ? _28 : '').trim();
529
+ const debugError = String((_31 = data.featured_image_error) !== null && _31 !== void 0 ? _31 : '').trim();
344
530
  const triedUrls = data.featured_image_tried_urls;
345
531
  const triedText = Array.isArray(triedUrls) && triedUrls.length > 0 ? ` URLs probadas: ${triedUrls.join(', ')}` : '';
346
532
  const suffix = debugError !== '' ? ` Motivo: ${debugError}.` : '';
@@ -350,30 +536,30 @@ async function execute(context, _credentials) {
350
536
  return data;
351
537
  }
352
538
  if (context.operation === 'getMenus') {
353
- const menuFilterRaw = Number((_29 = getOptionalNodeParameter(context, 'menuIdFilter', 0)) !== null && _29 !== void 0 ? _29 : 0);
354
- const menuRaw = Number((_30 = getOptionalNodeParameter(context, 'menuId', 0)) !== null && _30 !== void 0 ? _30 : 0);
539
+ const menuFilterRaw = Number((_32 = firstNonEmptyParam(context, ['menuIdFilter', 'menu_id_filter', 'Menu_ID_Filter'], 0)) !== null && _32 !== void 0 ? _32 : 0);
540
+ const menuRaw = Number((_33 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _33 !== void 0 ? _33 : 0);
355
541
  const menu_id = menuFilterRaw > 0 ? menuFilterRaw : menuRaw;
356
542
  return (await context.callPlugin('GET', 'content/menus', menu_id > 0 ? { menu_id } : undefined));
357
543
  }
358
544
  if (context.operation === 'getMenuItems') {
359
- const menu_id = Number((_31 = context.getNodeParameter('menuId')) !== null && _31 !== void 0 ? _31 : 0);
545
+ const menu_id = Number((_34 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _34 !== void 0 ? _34 : 0);
360
546
  return (await context.callPlugin('GET', 'content/menus/items', { menu_id }));
361
547
  }
362
548
  if (context.operation === 'createMenu') {
363
- const name = String((_32 = context.getNodeParameter('menuName')) !== null && _32 !== void 0 ? _32 : '').trim();
364
- const location = String((_33 = context.getNodeParameter('menuLocation')) !== null && _33 !== void 0 ? _33 : '').trim();
549
+ const name = String((_35 = firstNonEmptyParam(context, ['menuName', 'name', 'Menu_Name'], '')) !== null && _35 !== void 0 ? _35 : '').trim();
550
+ const location = String((_36 = firstNonEmptyParam(context, ['menuLocation', 'location', 'Menu_Location'], '')) !== null && _36 !== void 0 ? _36 : '').trim();
365
551
  return (await context.callPlugin('POST', 'content/menus', undefined, { name, location }));
366
552
  }
367
553
  if (context.operation === 'assignMenu') {
368
- const menu_id = Number((_34 = context.getNodeParameter('menuId')) !== null && _34 !== void 0 ? _34 : 0);
369
- const location = String((_35 = context.getNodeParameter('menuLocation')) !== null && _35 !== void 0 ? _35 : '').trim();
554
+ const menu_id = Number((_37 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _37 !== void 0 ? _37 : 0);
555
+ const location = String((_38 = firstNonEmptyParam(context, ['menuLocation', 'location', 'Menu_Location'], '')) !== null && _38 !== void 0 ? _38 : '').trim();
370
556
  return (await context.callPlugin('POST', 'content/menus/assign', undefined, { menu_id, location }));
371
557
  }
372
558
  if (context.operation === 'addMenuLink') {
373
- const menu_id = Number((_36 = context.getNodeParameter('menuId')) !== null && _36 !== void 0 ? _36 : 0);
374
- const title = String((_37 = context.getNodeParameter('menuItemTitle')) !== null && _37 !== void 0 ? _37 : '').trim();
375
- const url = normalizeMenuItemUrl(context.getNodeParameter('menuItemUrl'));
376
- const parent_item_id = Number((_38 = context.getNodeParameter('menuParentItemId')) !== null && _38 !== void 0 ? _38 : 0);
559
+ const menu_id = Number((_39 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _39 !== void 0 ? _39 : 0);
560
+ const title = String((_40 = firstNonEmptyParam(context, ['menuItemTitle', 'title', 'Title'], '')) !== null && _40 !== void 0 ? _40 : '').trim();
561
+ const url = normalizeMenuItemUrl(firstNonEmptyParam(context, ['menuItemUrl', 'url', 'URL'], ''));
562
+ const parent_item_id = Number((_41 = firstNonEmptyParam(context, ['menuParentItemId', 'parent_item_id', 'Parent_Item_ID'], 0)) !== null && _41 !== void 0 ? _41 : 0);
377
563
  const payload = { menu_id, title, url, parent_item_id };
378
564
  const endpointCandidates = [
379
565
  'content/menus/item-link',
@@ -398,9 +584,9 @@ async function execute(context, _credentials) {
398
584
  throw new Error('No se encontró una ruta REST compatible para añadir enlaces al menú');
399
585
  }
400
586
  if (context.operation === 'addMenuCategories') {
401
- const menu_id = Number((_39 = context.getNodeParameter('menuId')) !== null && _39 !== void 0 ? _39 : 0);
402
- const parent_item_id = Number((_40 = context.getNodeParameter('menuParentItemId')) !== null && _40 !== void 0 ? _40 : 0);
403
- const categoryCsv = String((_41 = context.getNodeParameter('menuCategoryIdsCsv')) !== null && _41 !== void 0 ? _41 : '').trim();
587
+ const menu_id = Number((_42 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _42 !== void 0 ? _42 : 0);
588
+ const parent_item_id = Number((_43 = firstNonEmptyParam(context, ['menuParentItemId', 'parent_item_id', 'Parent_Item_ID'], 0)) !== null && _43 !== void 0 ? _43 : 0);
589
+ const categoryCsv = String((_44 = firstNonEmptyParam(context, ['menuCategoryIdsCsv', 'category_ids', 'Category_IDs_CSV'], '')) !== null && _44 !== void 0 ? _44 : '').trim();
404
590
  const category_ids = categoryCsv
405
591
  .split(',')
406
592
  .map((x) => Number(x.trim()))
@@ -412,8 +598,8 @@ async function execute(context, _credentials) {
412
598
  }));
413
599
  }
414
600
  if (context.operation === 'deleteMenuItemsByText') {
415
- const menu_id = Number((_42 = context.getNodeParameter('menuId')) !== null && _42 !== void 0 ? _42 : 0);
416
- const text = String((_43 = context.getNodeParameter('menuItemFilterText')) !== null && _43 !== void 0 ? _43 : '').trim();
601
+ const menu_id = Number((_45 = firstNonEmptyParam(context, ['menuId', 'menu_id', 'Menu_ID'], 0)) !== null && _45 !== void 0 ? _45 : 0);
602
+ const text = String((_46 = firstNonEmptyParam(context, ['menuItemFilterText', 'text', 'Text'], '')) !== null && _46 !== void 0 ? _46 : '').trim();
417
603
  const endpointCandidates = ['content/menus/items/by-text', 'content/menus/delete-by-text'];
418
604
  for (const endpoint of endpointCandidates) {
419
605
  try {