n8n-nodes-prestashop8 2.0.2 → 2.0.3

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.
@@ -3955,6 +3955,50 @@ function convertFieldValue(value, fieldInfo) {
3955
3955
  }
3956
3956
  }
3957
3957
  exports.convertFieldValue = convertFieldValue;
3958
+ /**
3959
+ * Convert numeric fields in associations
3960
+ */
3961
+ function convertAssociationIds(associations) {
3962
+ if (!associations || typeof associations !== 'object') {
3963
+ return associations;
3964
+ }
3965
+ const converted = {};
3966
+ for (const [assocName, assocValue] of Object.entries(associations)) {
3967
+ if (Array.isArray(assocValue)) {
3968
+ // Convert array of association items
3969
+ converted[assocName] = assocValue.map((item) => {
3970
+ if (item && typeof item === 'object') {
3971
+ const convertedItem = {};
3972
+ // Convert all fields based on naming patterns
3973
+ for (const [key, value] of Object.entries(item)) {
3974
+ // Convert ID fields (id, id_*, *_id)
3975
+ if (key === 'id' || key.startsWith('id_') || key.endsWith('_id')) {
3976
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3977
+ }
3978
+ // Convert quantity fields
3979
+ else if (key.includes('quantity')) {
3980
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3981
+ }
3982
+ // Convert price fields (price, unit_price_*, *_price_*)
3983
+ else if (key.includes('price')) {
3984
+ convertedItem[key] = typeof value === 'string' ? Number(value) : value;
3985
+ }
3986
+ // Keep other fields as-is
3987
+ else {
3988
+ convertedItem[key] = value;
3989
+ }
3990
+ }
3991
+ return convertedItem;
3992
+ }
3993
+ return item;
3994
+ });
3995
+ }
3996
+ else {
3997
+ converted[assocName] = assocValue;
3998
+ }
3999
+ }
4000
+ return converted;
4001
+ }
3958
4002
  /**
3959
4003
  * Convert all fields in an object based on resource schema
3960
4004
  */
@@ -3965,7 +4009,11 @@ function convertResourceTypes(data, resource) {
3965
4009
  }
3966
4010
  const converted = {};
3967
4011
  for (const [field, value] of Object.entries(data)) {
3968
- if (schema[field]) {
4012
+ if (field === 'associations') {
4013
+ // Special handling for associations: convert numeric fields
4014
+ converted[field] = convertAssociationIds(value);
4015
+ }
4016
+ else if (schema[field]) {
3969
4017
  converted[field] = convertFieldValue(value, schema[field]);
3970
4018
  }
3971
4019
  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.3",
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",