n8n-nodes-prestashop8 2.0.5 → 2.1.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.
|
@@ -22,9 +22,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.PrestaShop8 = void 0;
|
|
27
30
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
31
|
+
const axios_1 = __importDefault(require("axios"));
|
|
28
32
|
const PrestaShop8_node_description_1 = require("./PrestaShop8.node.description");
|
|
29
33
|
const types_1 = require("./types");
|
|
30
34
|
const utils_1 = require("./utils");
|
|
@@ -178,6 +182,20 @@ function captureRequestDebugInfo(options, credentials, rawMode, operation, resou
|
|
|
178
182
|
...(options.json !== undefined && { jsonParsing: options.json }),
|
|
179
183
|
};
|
|
180
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Wrap response with optional headers and status information
|
|
187
|
+
*/
|
|
188
|
+
function wrapResponse(processedResponse, includeHeaders, headers, statusCode) {
|
|
189
|
+
if (includeHeaders) {
|
|
190
|
+
return {
|
|
191
|
+
body: processedResponse,
|
|
192
|
+
headers: headers || {},
|
|
193
|
+
statusCode: statusCode || 200,
|
|
194
|
+
statusMessage: statusCode && statusCode >= 200 && statusCode < 300 ? 'OK' : 'Error'
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return processedResponse;
|
|
198
|
+
}
|
|
181
199
|
class PrestaShop8 {
|
|
182
200
|
constructor() {
|
|
183
201
|
this.description = PrestaShop8_node_description_1.PrestaShop8Description;
|
|
@@ -360,8 +378,6 @@ class PrestaShop8 {
|
|
|
360
378
|
let requestHeaders = {};
|
|
361
379
|
let requestDebugInfo = {};
|
|
362
380
|
const rawMode = this.getNodeParameter('options.response.rawMode', i, false);
|
|
363
|
-
// Use resource for response processing
|
|
364
|
-
const currentMode = resource;
|
|
365
381
|
switch (operation) {
|
|
366
382
|
case 'list': {
|
|
367
383
|
const advancedOptions = this.getNodeParameter('advancedOptions', i, {});
|
|
@@ -386,9 +402,8 @@ class PrestaShop8 {
|
|
|
386
402
|
const includeResponseHeaders = this.getNodeParameter('options.response.includeResponseHeaders', i, false);
|
|
387
403
|
if (rawMode) {
|
|
388
404
|
// In Raw mode, use axios directly to avoid n8n automatic parsing
|
|
389
|
-
const axios = require('axios');
|
|
390
405
|
try {
|
|
391
|
-
const axiosResponse = await
|
|
406
|
+
const axiosResponse = await (0, axios_1.default)({
|
|
392
407
|
method: 'GET',
|
|
393
408
|
url: requestUrl,
|
|
394
409
|
auth: {
|
|
@@ -398,7 +413,7 @@ class PrestaShop8 {
|
|
|
398
413
|
headers: buildHttpOptions('GET', requestUrl, credentials, rawMode, timeout || 30000).headers,
|
|
399
414
|
timeout: timeout || 30000,
|
|
400
415
|
transformResponse: [(data) => data],
|
|
401
|
-
validateStatus: neverError ? () => true : undefined
|
|
416
|
+
validateStatus: neverError ? () => true : undefined
|
|
402
417
|
});
|
|
403
418
|
requestDebugInfo = captureRequestDebugInfo({
|
|
404
419
|
method: 'GET',
|
|
@@ -407,35 +422,17 @@ class PrestaShop8 {
|
|
|
407
422
|
timeout: timeout
|
|
408
423
|
}, credentials, rawMode, operation, resource);
|
|
409
424
|
requestHeaders = requestDebugInfo.headers;
|
|
410
|
-
// Check if this is an error response with Never Error mode
|
|
411
425
|
if (neverError && (axiosResponse.status < 200 || axiosResponse.status >= 300)) {
|
|
412
|
-
responseData = {
|
|
413
|
-
status: axiosResponse.status,
|
|
414
|
-
message: axiosResponse.data || ''
|
|
415
|
-
};
|
|
426
|
+
responseData = { status: axiosResponse.status, message: axiosResponse.data || '' };
|
|
416
427
|
}
|
|
417
428
|
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
|
-
}
|
|
429
|
+
const processedResponse = { raw: axiosResponse.data };
|
|
430
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, axiosResponse.headers, axiosResponse.status);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
catch (error) {
|
|
434
434
|
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
|
-
};
|
|
435
|
+
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
436
|
}
|
|
440
437
|
else {
|
|
441
438
|
throw error;
|
|
@@ -448,19 +445,8 @@ class PrestaShop8 {
|
|
|
448
445
|
requestUrl = url;
|
|
449
446
|
requestDebugInfo = debugInfo;
|
|
450
447
|
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
|
-
}
|
|
448
|
+
const processedResponse = (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
449
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
464
450
|
}
|
|
465
451
|
break;
|
|
466
452
|
}
|
|
@@ -486,19 +472,8 @@ class PrestaShop8 {
|
|
|
486
472
|
requestUrl = url;
|
|
487
473
|
requestDebugInfo = debugInfo;
|
|
488
474
|
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
|
-
}
|
|
475
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
476
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
502
477
|
break;
|
|
503
478
|
}
|
|
504
479
|
case 'create': {
|
|
@@ -538,19 +513,8 @@ class PrestaShop8 {
|
|
|
538
513
|
requestUrl = url;
|
|
539
514
|
requestDebugInfo = debugInfo;
|
|
540
515
|
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
|
-
}
|
|
516
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
517
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
554
518
|
break;
|
|
555
519
|
}
|
|
556
520
|
case 'update': {
|
|
@@ -586,19 +550,8 @@ class PrestaShop8 {
|
|
|
586
550
|
requestUrl = url;
|
|
587
551
|
requestDebugInfo = debugInfo;
|
|
588
552
|
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
|
-
}
|
|
553
|
+
const processedResponse = rawMode ? { raw: response } : (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
554
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
602
555
|
break;
|
|
603
556
|
}
|
|
604
557
|
case 'search': {
|
|
@@ -743,9 +696,8 @@ class PrestaShop8 {
|
|
|
743
696
|
const includeResponseHeaders = this.getNodeParameter('options.response.includeResponseHeaders', i, false);
|
|
744
697
|
if (rawMode) {
|
|
745
698
|
// In Raw mode, use axios directly to avoid n8n automatic parsing
|
|
746
|
-
const axios = require('axios');
|
|
747
699
|
try {
|
|
748
|
-
const axiosResponse = await
|
|
700
|
+
const axiosResponse = await (0, axios_1.default)({
|
|
749
701
|
method: 'GET',
|
|
750
702
|
url: requestUrl,
|
|
751
703
|
auth: {
|
|
@@ -755,7 +707,7 @@ class PrestaShop8 {
|
|
|
755
707
|
headers: buildHttpOptions('GET', requestUrl, credentials, rawMode, timeout || 30000).headers,
|
|
756
708
|
timeout: timeout || 30000,
|
|
757
709
|
transformResponse: [(data) => data],
|
|
758
|
-
validateStatus: neverError ? () => true : undefined
|
|
710
|
+
validateStatus: neverError ? () => true : undefined
|
|
759
711
|
});
|
|
760
712
|
requestDebugInfo = captureRequestDebugInfo({
|
|
761
713
|
method: 'GET',
|
|
@@ -764,35 +716,17 @@ class PrestaShop8 {
|
|
|
764
716
|
timeout: timeout
|
|
765
717
|
}, credentials, rawMode, operation, resource);
|
|
766
718
|
requestHeaders = requestDebugInfo.headers;
|
|
767
|
-
// Check if this is an error response with Never Error mode
|
|
768
719
|
if (neverError && (axiosResponse.status < 200 || axiosResponse.status >= 300)) {
|
|
769
|
-
responseData = {
|
|
770
|
-
status: axiosResponse.status,
|
|
771
|
-
message: axiosResponse.data || ''
|
|
772
|
-
};
|
|
720
|
+
responseData = { status: axiosResponse.status, message: axiosResponse.data || '' };
|
|
773
721
|
}
|
|
774
722
|
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
|
-
}
|
|
723
|
+
const processedResponse = { raw: axiosResponse.data };
|
|
724
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, axiosResponse.headers, axiosResponse.status);
|
|
788
725
|
}
|
|
789
726
|
}
|
|
790
727
|
catch (error) {
|
|
791
728
|
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
|
-
};
|
|
729
|
+
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
730
|
}
|
|
797
731
|
else {
|
|
798
732
|
throw error;
|
|
@@ -805,19 +739,8 @@ class PrestaShop8 {
|
|
|
805
739
|
requestUrl = url;
|
|
806
740
|
requestDebugInfo = debugInfo;
|
|
807
741
|
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
|
-
}
|
|
742
|
+
const processedResponse = (0, utils_1.processResponseForMode)(response, resource, resource);
|
|
743
|
+
responseData = wrapResponse(processedResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
821
744
|
}
|
|
822
745
|
break;
|
|
823
746
|
}
|
|
@@ -834,23 +757,12 @@ class PrestaShop8 {
|
|
|
834
757
|
requestUrl = url;
|
|
835
758
|
requestDebugInfo = debugInfo;
|
|
836
759
|
requestHeaders = debugInfo.headers;
|
|
837
|
-
|
|
760
|
+
const deleteResponse = {
|
|
838
761
|
success: true,
|
|
839
762
|
message: `${resource} with ID ${id} deleted successfully`,
|
|
840
763
|
deletedId: id,
|
|
841
764
|
};
|
|
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
|
-
}
|
|
765
|
+
responseData = wrapResponse(deleteResponse, includeResponseHeaders, responseHeaders, statusCode);
|
|
854
766
|
break;
|
|
855
767
|
}
|
|
856
768
|
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