n8n-nodes-prestashop8 2.4.1 → 2.5.0
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/PrestaShop8/PrestaShop8.node.description.js +8 -0
- package/dist/nodes/PrestaShop8/PrestaShop8.node.js +4 -13
- package/dist/nodes/PrestaShop8/helpers/http.d.ts +5 -0
- package/dist/nodes/PrestaShop8/helpers/http.js +8 -0
- package/dist/nodes/PrestaShop8/loadOptions.js +2 -2
- package/dist/nodes/PrestaShop8/utils/response.js +2 -2
- package/dist/nodes/PrestaShop8/utils/xml.js +1 -1
- package/package.json +5 -5
|
@@ -677,6 +677,14 @@ exports.PrestaShop8Description = {
|
|
|
677
677
|
default: 30000,
|
|
678
678
|
description: 'Request timeout in milliseconds',
|
|
679
679
|
},
|
|
680
|
+
{
|
|
681
|
+
displayName: 'Delay Between Calls (ms)',
|
|
682
|
+
name: 'delayBetweenCalls',
|
|
683
|
+
type: 'number',
|
|
684
|
+
typeOptions: { minValue: 0 },
|
|
685
|
+
default: 0,
|
|
686
|
+
description: 'Pause in milliseconds applied before each PrestaShop call except the first, to throttle requests when processing multiple input items',
|
|
687
|
+
},
|
|
680
688
|
],
|
|
681
689
|
},
|
|
682
690
|
],
|
|
@@ -97,10 +97,13 @@ class PrestaShop8 {
|
|
|
97
97
|
try {
|
|
98
98
|
let responseData;
|
|
99
99
|
let requestUrl = '';
|
|
100
|
-
let requestHeaders = {};
|
|
101
100
|
let requestDebugInfo = {};
|
|
102
101
|
const opts = (0, http_1.getOperationOptions)(this, i);
|
|
103
102
|
const { rawMode, timeout, neverError, includeResponseHeaders, showRequestInfo, showRequestUrl } = opts;
|
|
103
|
+
// Throttle: pause before each PrestaShop call except the first.
|
|
104
|
+
if (i > 0 && opts.delayBetweenCalls > 0) {
|
|
105
|
+
await (0, http_1.sleep)(opts.delayBetweenCalls);
|
|
106
|
+
}
|
|
104
107
|
switch (operation) {
|
|
105
108
|
case 'list': {
|
|
106
109
|
const advancedOptions = this.getNodeParameter('advancedOptions', i, {});
|
|
@@ -124,14 +127,12 @@ class PrestaShop8 {
|
|
|
124
127
|
const rawResult = await (0, http_1.executeRawModeRequest)(requestUrl, credentials, timeout, neverError, includeResponseHeaders, operation, resource);
|
|
125
128
|
responseData = rawResult.responseData;
|
|
126
129
|
requestDebugInfo = rawResult.requestDebugInfo;
|
|
127
|
-
requestHeaders = rawResult.requestHeaders;
|
|
128
130
|
}
|
|
129
131
|
else {
|
|
130
132
|
const options = (0, http_1.buildHttpOptions)('GET', requestUrl, credentials, rawMode, timeout);
|
|
131
133
|
const { response, debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError);
|
|
132
134
|
requestUrl = url;
|
|
133
135
|
requestDebugInfo = debugInfo;
|
|
134
|
-
requestHeaders = debugInfo.headers;
|
|
135
136
|
const processedResponse = (0, utils_1.processResponseForMode)(response, resource);
|
|
136
137
|
responseData = (0, http_1.wrapResponse)(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
137
138
|
}
|
|
@@ -155,7 +156,6 @@ class PrestaShop8 {
|
|
|
155
156
|
const { response, debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError);
|
|
156
157
|
requestUrl = url;
|
|
157
158
|
requestDebugInfo = debugInfo;
|
|
158
|
-
requestHeaders = debugInfo.headers;
|
|
159
159
|
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource);
|
|
160
160
|
responseData = (0, http_1.wrapResponse)(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
161
161
|
break;
|
|
@@ -193,7 +193,6 @@ class PrestaShop8 {
|
|
|
193
193
|
const { response, debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError, body);
|
|
194
194
|
requestUrl = url;
|
|
195
195
|
requestDebugInfo = debugInfo;
|
|
196
|
-
requestHeaders = debugInfo.headers;
|
|
197
196
|
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource);
|
|
198
197
|
responseData = (0, http_1.wrapResponse)(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
199
198
|
break;
|
|
@@ -227,7 +226,6 @@ class PrestaShop8 {
|
|
|
227
226
|
const { response, debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError, body);
|
|
228
227
|
requestUrl = url;
|
|
229
228
|
requestDebugInfo = debugInfo;
|
|
230
|
-
requestHeaders = debugInfo.headers;
|
|
231
229
|
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource);
|
|
232
230
|
responseData = (0, http_1.wrapResponse)(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
233
231
|
break;
|
|
@@ -300,14 +298,12 @@ class PrestaShop8 {
|
|
|
300
298
|
const rawResult = await (0, http_1.executeRawModeRequest)(requestUrl, credentials, timeout, neverError, includeResponseHeaders, operation, resource);
|
|
301
299
|
responseData = rawResult.responseData;
|
|
302
300
|
requestDebugInfo = rawResult.requestDebugInfo;
|
|
303
|
-
requestHeaders = rawResult.requestHeaders;
|
|
304
301
|
}
|
|
305
302
|
else {
|
|
306
303
|
const options = (0, http_1.buildHttpOptions)('GET', requestUrl, credentials, rawMode, timeout);
|
|
307
304
|
const { response, debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError);
|
|
308
305
|
requestUrl = url;
|
|
309
306
|
requestDebugInfo = debugInfo;
|
|
310
|
-
requestHeaders = debugInfo.headers;
|
|
311
307
|
const processedResponse = (0, utils_1.processResponseForMode)(response, resource);
|
|
312
308
|
responseData = (0, http_1.wrapResponse)(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
313
309
|
}
|
|
@@ -322,7 +318,6 @@ class PrestaShop8 {
|
|
|
322
318
|
const { debugInfo, url, responseHeaders, statusCode } = await (0, http_1.executeHttpRequest)(this.helpers, options, credentials, rawMode, operation, resource, neverError);
|
|
323
319
|
requestUrl = url;
|
|
324
320
|
requestDebugInfo = debugInfo;
|
|
325
|
-
requestHeaders = debugInfo.headers;
|
|
326
321
|
const deleteResponse = {
|
|
327
322
|
success: true,
|
|
328
323
|
message: `${resource} with ID ${id} deleted successfully`,
|
|
@@ -347,10 +342,6 @@ class PrestaShop8 {
|
|
|
347
342
|
timestamp: new Date().toISOString(),
|
|
348
343
|
};
|
|
349
344
|
}
|
|
350
|
-
// Add headers to output if requested
|
|
351
|
-
if (showRequestInfo) {
|
|
352
|
-
requestHeaders = requestDebugInfo.headers;
|
|
353
|
-
}
|
|
354
345
|
if (showRequestUrl || showRequestInfo) {
|
|
355
346
|
responseData = {
|
|
356
347
|
data: responseData,
|
|
@@ -18,7 +18,12 @@ export interface OperationOptions {
|
|
|
18
18
|
rawMode: boolean;
|
|
19
19
|
showRequestInfo: boolean;
|
|
20
20
|
showRequestUrl: boolean;
|
|
21
|
+
delayBetweenCalls: number;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Pause execution for the given number of milliseconds (used to throttle calls).
|
|
25
|
+
*/
|
|
26
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
22
27
|
/**
|
|
23
28
|
* Extract common operation options from node parameters
|
|
24
29
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FILTER_OPERATOR_FORMATS = void 0;
|
|
4
|
+
exports.sleep = sleep;
|
|
4
5
|
exports.getOperationOptions = getOperationOptions;
|
|
5
6
|
exports.buildHttpOptions = buildHttpOptions;
|
|
6
7
|
exports.captureRequestDebugInfo = captureRequestDebugInfo;
|
|
@@ -27,6 +28,12 @@ exports.FILTER_OPERATOR_FORMATS = {
|
|
|
27
28
|
'IS_EMPTY': { template: '[]', requiresValue: false },
|
|
28
29
|
'IS_NOT_EMPTY': { template: '![]', requiresValue: false },
|
|
29
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Pause execution for the given number of milliseconds (used to throttle calls).
|
|
33
|
+
*/
|
|
34
|
+
function sleep(ms) {
|
|
35
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
36
|
+
}
|
|
30
37
|
/**
|
|
31
38
|
* Extract common operation options from node parameters
|
|
32
39
|
*/
|
|
@@ -38,6 +45,7 @@ function getOperationOptions(executeFunctions, itemIndex) {
|
|
|
38
45
|
rawMode: executeFunctions.getNodeParameter('options.response.rawMode', itemIndex, false),
|
|
39
46
|
showRequestInfo: executeFunctions.getNodeParameter('options.request.showRequestInfo', itemIndex, false),
|
|
40
47
|
showRequestUrl: executeFunctions.getNodeParameter('options.request.showRequestUrl', itemIndex, false),
|
|
48
|
+
delayBetweenCalls: executeFunctions.getNodeParameter('options.delayBetweenCalls', itemIndex, 0),
|
|
41
49
|
};
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
@@ -115,7 +115,7 @@ exports.loadOptionsMethods = {
|
|
|
115
115
|
description: `Required field: ${field}`,
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
-
catch
|
|
118
|
+
catch {
|
|
119
119
|
return [{
|
|
120
120
|
name: 'Custom Field',
|
|
121
121
|
value: '__custom__',
|
|
@@ -170,7 +170,7 @@ exports.loadOptionsMethods = {
|
|
|
170
170
|
});
|
|
171
171
|
return fieldOptions;
|
|
172
172
|
}
|
|
173
|
-
catch
|
|
173
|
+
catch {
|
|
174
174
|
return [];
|
|
175
175
|
}
|
|
176
176
|
},
|
|
@@ -95,7 +95,7 @@ function simplifyPrestashopResponse(rawData, resource) {
|
|
|
95
95
|
/**
|
|
96
96
|
* Simplifies an individual element
|
|
97
97
|
*/
|
|
98
|
-
function simplifyItem(item,
|
|
98
|
+
function simplifyItem(item, _resource) {
|
|
99
99
|
if (!item || typeof item !== 'object') {
|
|
100
100
|
return item;
|
|
101
101
|
}
|
|
@@ -193,7 +193,7 @@ function buildPrestashopXml(resource, data) {
|
|
|
193
193
|
/**
|
|
194
194
|
* Converts simplified JSON to PrestaShop format
|
|
195
195
|
*/
|
|
196
|
-
function convertSimplifiedToPrestaShop(data,
|
|
196
|
+
function convertSimplifiedToPrestaShop(data, _resource) {
|
|
197
197
|
if (!data || typeof data !== 'object') {
|
|
198
198
|
return data;
|
|
199
199
|
}
|
|
@@ -81,7 +81,7 @@ function buildFieldsXml(fields) {
|
|
|
81
81
|
// Group fields by base name (for multilingual support)
|
|
82
82
|
const fieldGroups = {};
|
|
83
83
|
for (const field of fields) {
|
|
84
|
-
if (field.name && field.value !== undefined) {
|
|
84
|
+
if (field.name && field.value !== undefined && field.value !== null) {
|
|
85
85
|
const multilingualMatch = field.name.match(/^(.+)-(\d+)$/);
|
|
86
86
|
if (multilingualMatch) {
|
|
87
87
|
const [, fieldName, langId] = multilingualMatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-prestashop8",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Nœud n8n personnalisé pour PrestaShop 8 avec support CRUD complet et conversion XML/JSON automatique",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"build": "tsc && gulp build:icons",
|
|
33
33
|
"dev": "tsc --watch",
|
|
34
34
|
"format": "prettier nodes credentials --write",
|
|
35
|
-
"lint": "eslint nodes credentials
|
|
36
|
-
"lintfix": "eslint nodes credentials
|
|
35
|
+
"lint": "eslint nodes credentials",
|
|
36
|
+
"lintfix": "eslint nodes credentials --fix",
|
|
37
37
|
"prepublishOnly": "npm run build && npm run lint",
|
|
38
38
|
"test": "jest",
|
|
39
39
|
"test:watch": "jest --watch",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@eslint/js": "^9.39.4",
|
|
59
59
|
"@types/jest": "^30.0.0",
|
|
60
|
-
"axios": "^1.
|
|
60
|
+
"axios": "^1.16.0",
|
|
61
61
|
"@types/node": "^24.12.2",
|
|
62
62
|
"@types/xml2js": "^0.4.14",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^8.59.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"picomatch": "^4.0.4",
|
|
86
86
|
"brace-expansion": "^1.1.13",
|
|
87
87
|
"uuid": "^14.0.0",
|
|
88
|
-
"axios": "^1.
|
|
88
|
+
"axios": "^1.16.0",
|
|
89
89
|
"form-data": "^4.0.4",
|
|
90
90
|
"follow-redirects": "^1.16.0"
|
|
91
91
|
}
|