n8n-nodes-oxsr-technical-utils 4.2.30 → 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.
- package/dist/nodes/OXSRTechnicalUtils/OXSRTechnicalUtils.node.js +64 -9
- package/dist/nodes/OXSRTechnicalUtils/OXSRTechnicalUtils.node.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/actions.js +40 -5
- package/dist/nodes/OXSRTechnicalUtils/actions/actions.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/content.js +322 -136
- package/dist/nodes/OXSRTechnicalUtils/actions/content.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/database.js +17 -2
- package/dist/nodes/OXSRTechnicalUtils/actions/database.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/dbAdvanced.js +30 -3
- package/dist/nodes/OXSRTechnicalUtils/actions/dbAdvanced.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/email.js +27 -4
- package/dist/nodes/OXSRTechnicalUtils/actions/email.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/iaDev.js +48 -13
- package/dist/nodes/OXSRTechnicalUtils/actions/iaDev.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/logs.js +25 -2
- package/dist/nodes/OXSRTechnicalUtils/actions/logs.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/media.js +44 -14
- package/dist/nodes/OXSRTechnicalUtils/actions/media.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/metrics.js +26 -3
- package/dist/nodes/OXSRTechnicalUtils/actions/metrics.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/multisite.js +24 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/multisite.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/performance.js +46 -27
- package/dist/nodes/OXSRTechnicalUtils/actions/performance.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/plugins.js +32 -9
- package/dist/nodes/OXSRTechnicalUtils/actions/plugins.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/security.js +24 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/security.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/seo.js +56 -19
- package/dist/nodes/OXSRTechnicalUtils/actions/seo.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/server.js +58 -31
- package/dist/nodes/OXSRTechnicalUtils/actions/server.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/settings.js +61 -26
- package/dist/nodes/OXSRTechnicalUtils/actions/settings.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/updates.js +24 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/updates.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/users.js +51 -16
- package/dist/nodes/OXSRTechnicalUtils/actions/users.js.map +1 -1
- package/dist/nodes/OXSRTechnicalUtils/actions/woo.js +29 -6
- package/dist/nodes/OXSRTechnicalUtils/actions/woo.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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 !== ''
|
|
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
|
|
55
|
-
const limitRaw = Number((_b = context
|
|
56
|
-
const offsetRaw = Number((_c = context
|
|
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 =
|
|
72
|
-
const status = String((_e =
|
|
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 =
|
|
88
|
-
const in_title =
|
|
89
|
-
const simulate =
|
|
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 =
|
|
106
|
-
const slug = String((_o =
|
|
107
|
-
const content = String((_p =
|
|
108
|
-
const status = String((_q =
|
|
109
|
-
const type = String((_r =
|
|
110
|
-
const seo_title = String((_s =
|
|
111
|
-
const seo_description = String((_t =
|
|
112
|
-
const featured_image_id = Number((_u =
|
|
113
|
-
const featured_image_url = normalizeMenuItemUrl(
|
|
114
|
-
const categoriesRaw = String((_v =
|
|
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
|
|
134
|
-
const
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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((
|
|
141
|
-
let seo_title = String((
|
|
142
|
-
let seo_description = String((
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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((
|
|
292
|
+
title = String((_10 = source.title) !== null && _10 !== void 0 ? _10 : '').trim();
|
|
155
293
|
}
|
|
156
294
|
if (content === '') {
|
|
157
|
-
content = String((
|
|
295
|
+
content = String((_11 = source.raw_content) !== null && _11 !== void 0 ? _11 : '');
|
|
158
296
|
}
|
|
159
|
-
const seo = ((
|
|
297
|
+
const seo = ((_12 = source.seo) !== null && _12 !== void 0 ? _12 : {});
|
|
160
298
|
if (seo_title === '') {
|
|
161
|
-
seo_title = String((
|
|
299
|
+
seo_title = String((_13 = seo.title) !== null && _13 !== void 0 ? _13 : '').trim();
|
|
162
300
|
}
|
|
163
301
|
if (seo_description === '') {
|
|
164
|
-
seo_description = String((
|
|
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 (
|
|
308
|
+
if (singleFeaturedImageUrl === '' && singleFeaturedImageId <= 0) {
|
|
171
309
|
inferredFeaturedFromContent = extractFirstImgSrcFromHtml(content);
|
|
172
310
|
}
|
|
173
|
-
const categoriesRaw = String((
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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((
|
|
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
|
-
|
|
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((
|
|
231
|
-
const force =
|
|
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 =
|
|
261
|
-
const status = String((
|
|
262
|
-
const post_ids = idsCsv
|
|
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((
|
|
300
|
-
const focus_keyword = String((
|
|
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((
|
|
308
|
-
const raw_content = String((
|
|
309
|
-
const title = String((
|
|
310
|
-
const seo_title = String((
|
|
311
|
-
const seo_description = String((
|
|
312
|
-
const focus_keyword = String((
|
|
313
|
-
const auto_optimize_seo =
|
|
314
|
-
const featured_image_id_raw = Number((
|
|
315
|
-
const featured_image_id = Number.isFinite(featured_image_id_raw) ? Math.trunc(featured_image_id_raw) : 0;
|
|
316
|
-
const featured_image_url = normalizeMenuItemUrl(
|
|
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 =
|
|
336
|
-
const alreadyAssigned =
|
|
337
|
-
const returnedId = Number((
|
|
338
|
-
const currentId = Number((
|
|
339
|
-
const assignedOk =
|
|
340
|
-
updated ||
|
|
341
|
-
|
|
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((
|
|
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((
|
|
354
|
-
const menuRaw = Number((
|
|
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((
|
|
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((
|
|
364
|
-
const location = String((
|
|
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((
|
|
369
|
-
const location = String((
|
|
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((
|
|
374
|
-
const title = String((
|
|
375
|
-
const url = normalizeMenuItemUrl(context
|
|
376
|
-
const parent_item_id = Number((
|
|
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((
|
|
402
|
-
const parent_item_id = Number((
|
|
403
|
-
const categoryCsv = String((
|
|
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((
|
|
416
|
-
const text = String((
|
|
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 {
|