n8n-nodes-prestashop8 2.0.2 → 2.0.4

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.
@@ -338,6 +338,18 @@ class PrestaShop8 {
338
338
  const items = this.getInputData();
339
339
  const returnData = [];
340
340
  const credentials = await this.getCredentials('prestaShop8Api');
341
+ // Normalize base URL: ensure it ends with /api and has no trailing slash
342
+ let baseUrl = credentials.baseUrl.trim();
343
+ // Remove trailing slash if present
344
+ if (baseUrl.endsWith('/')) {
345
+ baseUrl = baseUrl.slice(0, -1);
346
+ }
347
+ // Add /api if not present
348
+ if (!baseUrl.endsWith('/api')) {
349
+ baseUrl = baseUrl + '/api';
350
+ }
351
+ // Update credentials with normalized URL
352
+ credentials.baseUrl = baseUrl;
341
353
  // Récupérer directement la ressource et l'opération
342
354
  const resource = this.getNodeParameter('resource', 0);
343
355
  const operation = this.getNodeParameter('operation', 0);
@@ -1549,6 +1549,14 @@ exports.RESOURCE_SCHEMAS = {
1549
1549
  },
1550
1550
  },
1551
1551
  'orders': {
1552
+ 'reference': {
1553
+ type: 'string',
1554
+ format: 'isReference',
1555
+ required: false,
1556
+ readOnly: false,
1557
+ multilang: false,
1558
+ maxSize: 9,
1559
+ },
1552
1560
  'id_address_delivery': {
1553
1561
  type: 'number',
1554
1562
  format: 'isUnsignedId',
@@ -3955,6 +3963,50 @@ function convertFieldValue(value, fieldInfo) {
3955
3963
  }
3956
3964
  }
3957
3965
  exports.convertFieldValue = convertFieldValue;
3966
+ /**
3967
+ * Convert numeric fields in associations
3968
+ */
3969
+ function convertAssociationIds(associations) {
3970
+ if (!associations || typeof associations !== 'object') {
3971
+ return associations;
3972
+ }
3973
+ const converted = {};
3974
+ for (const [assocName, assocValue] of Object.entries(associations)) {
3975
+ if (Array.isArray(assocValue)) {
3976
+ // Convert array of association items
3977
+ converted[assocName] = assocValue.map((item) => {
3978
+ if (item && typeof item === 'object') {
3979
+ const convertedItem = {};
3980
+ // Convert all fields based on naming patterns
3981
+ for (const [key, value] of Object.entries(item)) {
3982
+ // Convert ID fields (id, id_*, *_id)
3983
+ if (key === 'id' || key.startsWith('id_') || key.endsWith('_id')) {
3984
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3985
+ }
3986
+ // Convert quantity fields
3987
+ else if (key.includes('quantity')) {
3988
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3989
+ }
3990
+ // Convert price fields (price, unit_price_*, *_price_*)
3991
+ else if (key.includes('price')) {
3992
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3993
+ }
3994
+ // Keep other fields as-is
3995
+ else {
3996
+ convertedItem[key] = value;
3997
+ }
3998
+ }
3999
+ return convertedItem;
4000
+ }
4001
+ return item;
4002
+ });
4003
+ }
4004
+ else {
4005
+ converted[assocName] = assocValue;
4006
+ }
4007
+ }
4008
+ return converted;
4009
+ }
3958
4010
  /**
3959
4011
  * Convert all fields in an object based on resource schema
3960
4012
  */
@@ -3965,7 +4017,11 @@ function convertResourceTypes(data, resource) {
3965
4017
  }
3966
4018
  const converted = {};
3967
4019
  for (const [field, value] of Object.entries(data)) {
3968
- if (schema[field]) {
4020
+ if (field === 'associations') {
4021
+ // Special handling for associations: convert numeric fields
4022
+ converted[field] = convertAssociationIds(value);
4023
+ }
4024
+ else if (schema[field]) {
3969
4025
  converted[field] = convertFieldValue(value, schema[field]);
3970
4026
  }
3971
4027
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-prestashop8",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",