n8n-nodes-prestashop8 2.0.5 → 2.1.1
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.
|
@@ -25,6 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.PrestaShop8 = void 0;
|
|
27
27
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
29
|
+
const axios = require('axios');
|
|
28
30
|
const PrestaShop8_node_description_1 = require("./PrestaShop8.node.description");
|
|
29
31
|
const types_1 = require("./types");
|
|
30
32
|
const utils_1 = require("./utils");
|
|
@@ -178,6 +180,20 @@ function captureRequestDebugInfo(options, credentials, rawMode, operation, resou
|
|
|
178
180
|
...(options.json !== undefined && { jsonParsing: options.json }),
|
|
179
181
|
};
|
|
180
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Wrap response with optional headers and status information
|
|
185
|
+
*/
|
|
186
|
+
function wrapResponse(processedResponse, includeHeaders, headers, statusCode) {
|
|
187
|
+
if (includeHeaders) {
|
|
188
|
+
return {
|
|
189
|
+
body: processedResponse,
|
|
190
|
+
headers: headers || {},
|
|
191
|
+
statusCode: statusCode || 200,
|
|
192
|
+
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return processedResponse;
|
|
196
|
+
}
|
|
181
197
|
class PrestaShop8 {
|
|
182
198
|
constructor() {
|
|
183
199
|
this.description = PrestaShop8_node_description_1.PrestaShop8Description;
|
|
@@ -360,8 +376,6 @@ class PrestaShop8 {
|
|
|
360
376
|
let requestHeaders = {};
|
|
361
377
|
let requestDebugInfo = {};
|
|
362
378
|
const rawMode = this.getNodeParameter('options.response.rawMode', i, false);
|
|
363
|
-
// Use resource for response processing
|
|
364
|
-
const currentMode = resource;
|
|
365
379
|
switch (operation) {
|
|
366
380
|
case 'list': {
|
|
367
381
|
const advancedOptions = this.getNodeParameter('advancedOptions', i, {});
|
|
@@ -386,7 +400,6 @@ class PrestaShop8 {
|
|
|
386
400
|
const includeResponseHeaders = this.getNodeParameter('options.response.includeResponseHeaders', i, false);
|
|
387
401
|
if (rawMode) {
|
|
388
402
|
// In Raw mode, use axios directly to avoid n8n automatic parsing
|
|
389
|
-
const axios = require('axios');
|
|
390
403
|
try {
|
|
391
404
|
const axiosResponse = await axios({
|
|
392
405
|
method: 'GET',
|
|
@@ -398,7 +411,7 @@ class PrestaShop8 {
|
|
|
398
411
|
headers: buildHttpOptions('GET', requestUrl, credentials, rawMode, timeout || 30000).headers,
|
|
399
412
|
timeout: timeout || 30000,
|
|
400
413
|
transformResponse: [(data) => data],
|
|
401
|
-
validateStatus: neverError ? () => true : undefined
|
|
414
|
+
validateStatus: neverError ? () => true : undefined
|
|
402
415
|
});
|
|
403
416
|
requestDebugInfo = captureRequestDebugInfo({
|
|
404
417
|
method: 'GET',
|
|
@@ -407,35 +420,17 @@ class PrestaShop8 {
|
|
|
407
420
|
timeout: timeout
|
|
408
421
|
}, credentials, rawMode, operation, resource);
|
|
409
422
|
requestHeaders = requestDebugInfo.headers;
|
|
410
|
-
// Check if this is an error response with Never Error mode
|
|
411
423
|
if (neverError && (axiosResponse.status < 200 || axiosResponse.status >= 300)) {
|
|
412
|
-
responseData = {
|
|
413
|
-
status: axiosResponse.status,
|
|
414
|
-
message: axiosResponse.data || ''
|
|
415
|
-
};
|
|
424
|
+
responseData = { status: axiosResponse.status, message: axiosResponse.data || '' };
|
|
416
425
|
}
|
|
417
426
|
else {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (includeResponseHeaders) {
|
|
421
|
-
responseData = {
|
|
422
|
-
body: processedResponse,
|
|
423
|
-
headers: axiosResponse.headers,
|
|
424
|
-
statusCode: axiosResponse.status,
|
|
425
|
-
statusMessage: axiosResponse.status >= 200 && axiosResponse.status < 300 ? 'OK' : 'Error'
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
responseData = processedResponse;
|
|
430
|
-
}
|
|
427
|
+
const processedResponse = { raw: axiosResponse.data };
|
|
428
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, axiosResponse.headers, axiosResponse.status);
|
|
431
429
|
}
|
|
432
430
|
}
|
|
433
431
|
catch (error) {
|
|
434
432
|
if (neverError) {
|
|
435
|
-
responseData = {
|
|
436
|
-
status: ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) || 500,
|
|
437
|
-
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || ''
|
|
438
|
-
};
|
|
433
|
+
responseData = { status: ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) || 500, message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || '' };
|
|
439
434
|
}
|
|
440
435
|
else {
|
|
441
436
|
throw error;
|
|
@@ -448,19 +443,8 @@ class PrestaShop8 {
|
|
|
448
443
|
requestUrl = url;
|
|
449
444
|
requestDebugInfo = debugInfo;
|
|
450
445
|
requestHeaders = debugInfo.headers;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (includeResponseHeaders) {
|
|
454
|
-
responseData = {
|
|
455
|
-
body: processedResponse,
|
|
456
|
-
headers: responseHeaders,
|
|
457
|
-
statusCode: statusCode,
|
|
458
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
responseData = processedResponse;
|
|
463
|
-
}
|
|
446
|
+
const processedResponse = (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
447
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
464
448
|
}
|
|
465
449
|
break;
|
|
466
450
|
}
|
|
@@ -486,19 +470,8 @@ class PrestaShop8 {
|
|
|
486
470
|
requestUrl = url;
|
|
487
471
|
requestDebugInfo = debugInfo;
|
|
488
472
|
requestHeaders = debugInfo.headers;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if (includeResponseHeaders) {
|
|
492
|
-
responseData = {
|
|
493
|
-
body: processedResponse,
|
|
494
|
-
headers: responseHeaders,
|
|
495
|
-
statusCode: statusCode,
|
|
496
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
responseData = processedResponse;
|
|
501
|
-
}
|
|
473
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
474
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
502
475
|
break;
|
|
503
476
|
}
|
|
504
477
|
case 'create': {
|
|
@@ -538,19 +511,8 @@ class PrestaShop8 {
|
|
|
538
511
|
requestUrl = url;
|
|
539
512
|
requestDebugInfo = debugInfo;
|
|
540
513
|
requestHeaders = debugInfo.headers;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (includeResponseHeaders) {
|
|
544
|
-
responseData = {
|
|
545
|
-
body: processedResponse,
|
|
546
|
-
headers: responseHeaders,
|
|
547
|
-
statusCode: statusCode,
|
|
548
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
responseData = processedResponse;
|
|
553
|
-
}
|
|
514
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
515
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
554
516
|
break;
|
|
555
517
|
}
|
|
556
518
|
case 'update': {
|
|
@@ -586,19 +548,8 @@ class PrestaShop8 {
|
|
|
586
548
|
requestUrl = url;
|
|
587
549
|
requestDebugInfo = debugInfo;
|
|
588
550
|
requestHeaders = debugInfo.headers;
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
if (includeResponseHeaders) {
|
|
592
|
-
responseData = {
|
|
593
|
-
body: processedResponse,
|
|
594
|
-
headers: responseHeaders,
|
|
595
|
-
statusCode: statusCode,
|
|
596
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
responseData = processedResponse;
|
|
601
|
-
}
|
|
551
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
552
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
602
553
|
break;
|
|
603
554
|
}
|
|
604
555
|
case 'search': {
|
|
@@ -743,7 +694,6 @@ class PrestaShop8 {
|
|
|
743
694
|
const includeResponseHeaders = this.getNodeParameter('options.response.includeResponseHeaders', i, false);
|
|
744
695
|
if (rawMode) {
|
|
745
696
|
// In Raw mode, use axios directly to avoid n8n automatic parsing
|
|
746
|
-
const axios = require('axios');
|
|
747
697
|
try {
|
|
748
698
|
const axiosResponse = await axios({
|
|
749
699
|
method: 'GET',
|
|
@@ -755,7 +705,7 @@ class PrestaShop8 {
|
|
|
755
705
|
headers: buildHttpOptions('GET', requestUrl, credentials, rawMode, timeout || 30000).headers,
|
|
756
706
|
timeout: timeout || 30000,
|
|
757
707
|
transformResponse: [(data) => data],
|
|
758
|
-
validateStatus: neverError ? () => true : undefined
|
|
708
|
+
validateStatus: neverError ? () => true : undefined
|
|
759
709
|
});
|
|
760
710
|
requestDebugInfo = captureRequestDebugInfo({
|
|
761
711
|
method: 'GET',
|
|
@@ -764,35 +714,17 @@ class PrestaShop8 {
|
|
|
764
714
|
timeout: timeout
|
|
765
715
|
}, credentials, rawMode, operation, resource);
|
|
766
716
|
requestHeaders = requestDebugInfo.headers;
|
|
767
|
-
// Check if this is an error response with Never Error mode
|
|
768
717
|
if (neverError && (axiosResponse.status < 200 || axiosResponse.status >= 300)) {
|
|
769
|
-
responseData = {
|
|
770
|
-
status: axiosResponse.status,
|
|
771
|
-
message: axiosResponse.data || ''
|
|
772
|
-
};
|
|
718
|
+
responseData = { status: axiosResponse.status, message: axiosResponse.data || '' };
|
|
773
719
|
}
|
|
774
720
|
else {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
if (includeResponseHeaders) {
|
|
778
|
-
responseData = {
|
|
779
|
-
body: processedResponse,
|
|
780
|
-
headers: axiosResponse.headers,
|
|
781
|
-
statusCode: axiosResponse.status,
|
|
782
|
-
statusMessage: axiosResponse.status >= 200 && axiosResponse.status < 300 ? 'OK' : 'Error'
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
responseData = processedResponse;
|
|
787
|
-
}
|
|
721
|
+
const processedResponse = { raw: axiosResponse.data };
|
|
722
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, axiosResponse.headers, axiosResponse.status);
|
|
788
723
|
}
|
|
789
724
|
}
|
|
790
725
|
catch (error) {
|
|
791
726
|
if (neverError) {
|
|
792
|
-
responseData = {
|
|
793
|
-
status: ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) || 500,
|
|
794
|
-
message: ((_d = error.response) === null || _d === void 0 ? void 0 : _d.data) || ''
|
|
795
|
-
};
|
|
727
|
+
responseData = { status: ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) || 500, message: ((_d = error.response) === null || _d === void 0 ? void 0 : _d.data) || '' };
|
|
796
728
|
}
|
|
797
729
|
else {
|
|
798
730
|
throw error;
|
|
@@ -805,19 +737,8 @@ class PrestaShop8 {
|
|
|
805
737
|
requestUrl = url;
|
|
806
738
|
requestDebugInfo = debugInfo;
|
|
807
739
|
requestHeaders = debugInfo.headers;
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
if (includeResponseHeaders) {
|
|
811
|
-
responseData = {
|
|
812
|
-
body: processedResponse,
|
|
813
|
-
headers: responseHeaders,
|
|
814
|
-
statusCode: statusCode,
|
|
815
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
else {
|
|
819
|
-
responseData = processedResponse;
|
|
820
|
-
}
|
|
740
|
+
const processedResponse = (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
741
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
821
742
|
}
|
|
822
743
|
break;
|
|
823
744
|
}
|
|
@@ -834,23 +755,12 @@ class PrestaShop8 {
|
|
|
834
755
|
requestUrl = url;
|
|
835
756
|
requestDebugInfo = debugInfo;
|
|
836
757
|
requestHeaders = debugInfo.headers;
|
|
837
|
-
|
|
758
|
+
const deleteResponse = {
|
|
838
759
|
success: true,
|
|
839
760
|
message: `${resource} with ID ${id} deleted successfully`,
|
|
840
761
|
deletedId: id,
|
|
841
762
|
};
|
|
842
|
-
|
|
843
|
-
if (includeResponseHeaders) {
|
|
844
|
-
responseData = {
|
|
845
|
-
body: deleteResponse,
|
|
846
|
-
headers: responseHeaders,
|
|
847
|
-
statusCode: statusCode,
|
|
848
|
-
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
else {
|
|
852
|
-
responseData = deleteResponse;
|
|
853
|
-
}
|
|
763
|
+
responseData = wrapResponse(deleteResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
854
764
|
break;
|
|
855
765
|
}
|
|
856
766
|
default:
|
|
@@ -3739,6 +3739,14 @@ exports.RESOURCE_SCHEMAS = {
|
|
|
3739
3739
|
},
|
|
3740
3740
|
},
|
|
3741
3741
|
'customer_messages': {
|
|
3742
|
+
'id_customer_thread': {
|
|
3743
|
+
type: 'number',
|
|
3744
|
+
format: 'isUnsignedId',
|
|
3745
|
+
required: false,
|
|
3746
|
+
readOnly: false,
|
|
3747
|
+
multilang: false,
|
|
3748
|
+
maxSize: null,
|
|
3749
|
+
},
|
|
3742
3750
|
'id_employee': {
|
|
3743
3751
|
type: 'number',
|
|
3744
3752
|
format: 'isUnsignedId',
|
|
@@ -17,8 +17,8 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
17
17
|
},
|
|
18
18
|
addresses: {
|
|
19
19
|
name: 'addresses',
|
|
20
|
-
displayName: '
|
|
21
|
-
description: '
|
|
20
|
+
displayName: 'Addresses',
|
|
21
|
+
description: 'Customer and delivery addresses',
|
|
22
22
|
supportsCreate: true,
|
|
23
23
|
supportsUpdate: true,
|
|
24
24
|
supportsDelete: true,
|
|
@@ -29,7 +29,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
29
29
|
groups: {
|
|
30
30
|
name: 'groups',
|
|
31
31
|
displayName: 'Customer Groups',
|
|
32
|
-
description: '
|
|
32
|
+
description: 'Customer groups and pricing',
|
|
33
33
|
supportsCreate: true,
|
|
34
34
|
supportsUpdate: true,
|
|
35
35
|
supportsDelete: true,
|
|
@@ -39,8 +39,8 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
39
39
|
},
|
|
40
40
|
customer_threads: {
|
|
41
41
|
name: 'customer_threads',
|
|
42
|
-
displayName: '
|
|
43
|
-
description: '
|
|
42
|
+
displayName: 'Customer Threads',
|
|
43
|
+
description: 'Customer conversation threads',
|
|
44
44
|
supportsCreate: true,
|
|
45
45
|
supportsUpdate: true,
|
|
46
46
|
supportsDelete: true,
|
|
@@ -51,7 +51,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
51
51
|
customer_messages: {
|
|
52
52
|
name: 'customer_messages',
|
|
53
53
|
displayName: 'Customer Messages',
|
|
54
|
-
description: '
|
|
54
|
+
description: 'Individual conversation messages',
|
|
55
55
|
supportsCreate: true,
|
|
56
56
|
supportsUpdate: true,
|
|
57
57
|
supportsDelete: true,
|
|
@@ -59,11 +59,11 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
59
59
|
supportsGetById: true,
|
|
60
60
|
supportsSearch: true,
|
|
61
61
|
},
|
|
62
|
-
//
|
|
62
|
+
// Product catalog
|
|
63
63
|
products: {
|
|
64
64
|
name: 'products',
|
|
65
65
|
displayName: 'Products',
|
|
66
|
-
description: '
|
|
66
|
+
description: 'Store product catalog',
|
|
67
67
|
supportsCreate: true,
|
|
68
68
|
supportsUpdate: true,
|
|
69
69
|
supportsDelete: true,
|
|
@@ -107,7 +107,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
107
107
|
manufacturers: {
|
|
108
108
|
name: 'manufacturers',
|
|
109
109
|
displayName: 'Manufacturers',
|
|
110
|
-
description: '
|
|
110
|
+
description: 'Brands and manufacturers',
|
|
111
111
|
supportsCreate: true,
|
|
112
112
|
supportsUpdate: true,
|
|
113
113
|
supportsDelete: true,
|
|
@@ -118,7 +118,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
118
118
|
suppliers: {
|
|
119
119
|
name: 'suppliers',
|
|
120
120
|
displayName: 'Suppliers',
|
|
121
|
-
description: '
|
|
121
|
+
description: 'Product suppliers',
|
|
122
122
|
supportsCreate: true,
|
|
123
123
|
supportsUpdate: true,
|
|
124
124
|
supportsDelete: true,
|
|
@@ -151,7 +151,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
151
151
|
product_options: {
|
|
152
152
|
name: 'product_options',
|
|
153
153
|
displayName: 'Product Options',
|
|
154
|
-
description: '
|
|
154
|
+
description: 'Product customization options',
|
|
155
155
|
supportsCreate: true,
|
|
156
156
|
supportsUpdate: true,
|
|
157
157
|
supportsDelete: true,
|
|
@@ -159,11 +159,11 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
159
159
|
supportsGetById: true,
|
|
160
160
|
supportsSearch: true,
|
|
161
161
|
},
|
|
162
|
-
// Orders &
|
|
162
|
+
// Orders & Sales
|
|
163
163
|
orders: {
|
|
164
164
|
name: 'orders',
|
|
165
165
|
displayName: 'Orders',
|
|
166
|
-
description: '
|
|
166
|
+
description: 'Store orders',
|
|
167
167
|
supportsCreate: true,
|
|
168
168
|
supportsUpdate: true,
|
|
169
169
|
supportsDelete: true,
|
|
@@ -174,7 +174,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
174
174
|
order_details: {
|
|
175
175
|
name: 'order_details',
|
|
176
176
|
displayName: 'Order Details',
|
|
177
|
-
description: '
|
|
177
|
+
description: 'Order line items',
|
|
178
178
|
supportsCreate: false,
|
|
179
179
|
supportsUpdate: true,
|
|
180
180
|
supportsDelete: false,
|
|
@@ -184,7 +184,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
184
184
|
},
|
|
185
185
|
order_histories: {
|
|
186
186
|
name: 'order_histories',
|
|
187
|
-
displayName: '
|
|
187
|
+
displayName: 'Order Histories',
|
|
188
188
|
description: 'Order status changes',
|
|
189
189
|
supportsCreate: true,
|
|
190
190
|
supportsUpdate: false,
|
|
@@ -207,7 +207,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
207
207
|
order_carriers: {
|
|
208
208
|
name: 'order_carriers',
|
|
209
209
|
displayName: 'Order Carriers',
|
|
210
|
-
description: '
|
|
210
|
+
description: 'Order carrier assignments',
|
|
211
211
|
supportsCreate: true,
|
|
212
212
|
supportsUpdate: true,
|
|
213
213
|
supportsDelete: true,
|
|
@@ -218,7 +218,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
218
218
|
carts: {
|
|
219
219
|
name: 'carts',
|
|
220
220
|
displayName: 'Carts',
|
|
221
|
-
description: '
|
|
221
|
+
description: 'Customer shopping carts',
|
|
222
222
|
supportsCreate: true,
|
|
223
223
|
supportsUpdate: true,
|
|
224
224
|
supportsDelete: true,
|
|
@@ -237,11 +237,11 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
237
237
|
supportsGetById: true,
|
|
238
238
|
supportsSearch: true,
|
|
239
239
|
},
|
|
240
|
-
//
|
|
240
|
+
// Shipping & Logistics
|
|
241
241
|
carriers: {
|
|
242
242
|
name: 'carriers',
|
|
243
243
|
displayName: 'Carriers',
|
|
244
|
-
description: '
|
|
244
|
+
description: 'Shipping methods and carriers',
|
|
245
245
|
supportsCreate: true,
|
|
246
246
|
supportsUpdate: true,
|
|
247
247
|
supportsDelete: true,
|
|
@@ -252,7 +252,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
252
252
|
zones: {
|
|
253
253
|
name: 'zones',
|
|
254
254
|
displayName: 'Geographic Zones',
|
|
255
|
-
description: '
|
|
255
|
+
description: 'Delivery zones',
|
|
256
256
|
supportsCreate: true,
|
|
257
257
|
supportsUpdate: true,
|
|
258
258
|
supportsDelete: true,
|
|
@@ -263,7 +263,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
263
263
|
countries: {
|
|
264
264
|
name: 'countries',
|
|
265
265
|
displayName: 'Countries',
|
|
266
|
-
description: '
|
|
266
|
+
description: 'Country list',
|
|
267
267
|
supportsCreate: true,
|
|
268
268
|
supportsUpdate: true,
|
|
269
269
|
supportsDelete: true,
|
|
@@ -282,7 +282,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
282
282
|
supportsGetById: true,
|
|
283
283
|
supportsSearch: true,
|
|
284
284
|
},
|
|
285
|
-
//
|
|
285
|
+
// Payments & Finance
|
|
286
286
|
currencies: {
|
|
287
287
|
name: 'currencies',
|
|
288
288
|
displayName: 'Currencies',
|
|
@@ -297,7 +297,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
297
297
|
taxes: {
|
|
298
298
|
name: 'taxes',
|
|
299
299
|
displayName: 'Taxes',
|
|
300
|
-
description: '
|
|
300
|
+
description: 'Tax rates',
|
|
301
301
|
supportsCreate: true,
|
|
302
302
|
supportsUpdate: true,
|
|
303
303
|
supportsDelete: true,
|
|
@@ -308,8 +308,8 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
308
308
|
// CMS & Media
|
|
309
309
|
content_management_system: {
|
|
310
310
|
name: 'content_management_system',
|
|
311
|
-
displayName: 'Pages
|
|
312
|
-
description: '
|
|
311
|
+
displayName: 'CMS Pages',
|
|
312
|
+
description: 'Static content pages',
|
|
313
313
|
supportsCreate: true,
|
|
314
314
|
supportsUpdate: true,
|
|
315
315
|
supportsDelete: true,
|
|
@@ -354,7 +354,7 @@ exports.PRESTASHOP_RESOURCES = {
|
|
|
354
354
|
shops: {
|
|
355
355
|
name: 'shops',
|
|
356
356
|
displayName: 'Shops',
|
|
357
|
-
description: '
|
|
357
|
+
description: 'Multi-store management',
|
|
358
358
|
supportsCreate: true,
|
|
359
359
|
supportsUpdate: true,
|
|
360
360
|
supportsDelete: true,
|
|
@@ -24,7 +24,7 @@ export declare function simplifyPrestashopResponse(rawData: any, resource: strin
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function buildPrestashopXml(resource: string, data: any): string;
|
|
26
26
|
/**
|
|
27
|
-
* Parse XML
|
|
27
|
+
* Parse XML to JSON
|
|
28
28
|
*/
|
|
29
29
|
export declare function parseXmlToJson(xml: string): Promise<any>;
|
|
30
30
|
/**
|
|
@@ -214,7 +214,7 @@ function simplifyPrestashopResponse(rawData, resource) {
|
|
|
214
214
|
return rawData;
|
|
215
215
|
}
|
|
216
216
|
let data = rawData.prestashop;
|
|
217
|
-
//
|
|
217
|
+
// Extract the main resource
|
|
218
218
|
if (data[resource]) {
|
|
219
219
|
data = data[resource];
|
|
220
220
|
}
|
|
@@ -225,7 +225,7 @@ function simplifyPrestashopResponse(rawData, resource) {
|
|
|
225
225
|
if (Array.isArray(data)) {
|
|
226
226
|
return data.map(item => simplifyItem(item, resource));
|
|
227
227
|
}
|
|
228
|
-
//
|
|
228
|
+
// If it's a single object
|
|
229
229
|
return simplifyItem(data, resource);
|
|
230
230
|
}
|
|
231
231
|
exports.simplifyPrestashopResponse = simplifyPrestashopResponse;
|
|
@@ -240,7 +240,7 @@ function simplifyItem(item, resource) {
|
|
|
240
240
|
for (const [key, value] of Object.entries(item)) {
|
|
241
241
|
const simplifiedKey = convertFieldName(key);
|
|
242
242
|
if (key === 'associations' && value && typeof value === 'object') {
|
|
243
|
-
//
|
|
243
|
+
// Process associations
|
|
244
244
|
for (const [assocKey, assocValue] of Object.entries(value)) {
|
|
245
245
|
simplified[convertFieldName(assocKey)] = simplifyAssociation(assocValue);
|
|
246
246
|
}
|
|
@@ -255,7 +255,7 @@ function simplifyItem(item, resource) {
|
|
|
255
255
|
return simplified;
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
258
|
+
* Simplifies a PrestaShop association
|
|
259
259
|
*/
|
|
260
260
|
function simplifyAssociation(assoc) {
|
|
261
261
|
if (!assoc)
|
|
@@ -283,12 +283,12 @@ function simplifyAssociation(assoc) {
|
|
|
283
283
|
return [];
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
|
-
*
|
|
286
|
+
* Converts PrestaShop field names to camelCase
|
|
287
287
|
*/
|
|
288
288
|
function convertFieldName(fieldName) {
|
|
289
289
|
return fieldName
|
|
290
290
|
.replace(/^id_/, '') // Remove id_ prefix
|
|
291
|
-
.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase()); //
|
|
291
|
+
.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase()); // Convert to camelCase
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
294
|
* Converts string values to appropriate types
|
|
@@ -297,7 +297,7 @@ function convertValue(value) {
|
|
|
297
297
|
if (typeof value !== 'string') {
|
|
298
298
|
return value;
|
|
299
299
|
}
|
|
300
|
-
//
|
|
300
|
+
// Try to convert to number
|
|
301
301
|
if (/^\d+$/.test(value)) {
|
|
302
302
|
return parseInt(value, 10);
|
|
303
303
|
}
|
|
@@ -311,7 +311,7 @@ function convertValue(value) {
|
|
|
311
311
|
if (value === 'false' || value === '0') {
|
|
312
312
|
return false;
|
|
313
313
|
}
|
|
314
|
-
//
|
|
314
|
+
// Return string value as-is
|
|
315
315
|
return value;
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
@@ -360,7 +360,7 @@ function convertSimplifiedToPrestaShop(data, resource) {
|
|
|
360
360
|
}
|
|
361
361
|
// convertFromCamelCase function moved to fieldMappings.ts for centralization
|
|
362
362
|
/**
|
|
363
|
-
*
|
|
363
|
+
* Gets all string fields for CDATA
|
|
364
364
|
*/
|
|
365
365
|
function getAllStringFields(obj) {
|
|
366
366
|
const fields = [];
|
|
@@ -381,7 +381,7 @@ function getAllStringFields(obj) {
|
|
|
381
381
|
return fields;
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
|
-
* Parse XML
|
|
384
|
+
* Parse XML to JSON
|
|
385
385
|
*/
|
|
386
386
|
async function parseXmlToJson(xml) {
|
|
387
387
|
const parser = new xml2js.Parser({
|
|
@@ -412,7 +412,7 @@ function buildUrlWithFilters(baseUrl, options, rawMode) {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
//
|
|
415
|
+
// Add output_format only if not in Raw mode
|
|
416
416
|
if (!rawMode) {
|
|
417
417
|
params.append('output_format', 'JSON');
|
|
418
418
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-prestashop8",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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",
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"typescript": "^4.8.4"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"axios": "^1.6.0",
|
|
71
70
|
"js2xmlparser": "^5.0.0",
|
|
72
71
|
"xml2js": "^0.6.2"
|
|
73
72
|
},
|