spice-js 2.6.82 → 2.6.85

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.
@@ -12,8 +12,7 @@ var crypto = require("crypto");
12
12
 
13
13
  function generateCacheKey(input) {
14
14
  // Create an MD5 hash of the input string and return it in hexadecimal format
15
- //return crypto.createHash("md5").update(input).digest("hex");
16
- return input;
15
+ return crypto.createHash("md5").update(input).digest("hex"); //return input;
17
16
  }
18
17
 
19
18
  module.exports = class SpiceCache {
@@ -168,8 +168,7 @@ class SpiceModel {
168
168
  }
169
169
 
170
170
  return props;
171
- } //console.log("Applying Overrides to :", this.collection,'||', args.collection)
172
-
171
+ }
173
172
 
174
173
  args.props = applySchemaOverrides(removeDynamicProps(args.props), args.collection);
175
174
  this[_props] = args.props;
@@ -232,7 +231,7 @@ class SpiceModel {
232
231
  that = this;
233
232
  this.createModifiersFromProps();
234
233
  } catch (e) {
235
- console.log(e.stack);
234
+ console.warn(e.stack);
236
235
  } // }
237
236
 
238
237
  }
@@ -682,7 +681,7 @@ class SpiceModel {
682
681
 
683
682
  return yield doGet();
684
683
  } catch (e) {
685
- console.log(e.message, e);
684
+ console.warn(e.message, e);
686
685
  throw e;
687
686
  }
688
687
  })();
@@ -750,7 +749,7 @@ class SpiceModel {
750
749
 
751
750
  return results;
752
751
  } catch (e) {
753
- console.log(e.stack);
752
+ console.warn(e.stack);
754
753
  throw e;
755
754
  }
756
755
  })();
@@ -869,7 +868,7 @@ class SpiceModel {
869
868
 
870
869
  return yield doUpdate();
871
870
  } catch (e) {
872
- console.log("Error on update", e, e.stack);
871
+ console.warn("Error on update", e, e.stack);
873
872
  throw e;
874
873
  }
875
874
  })();
@@ -962,7 +961,7 @@ class SpiceModel {
962
961
 
963
962
  return yield doCreate();
964
963
  } catch (e) {
965
- console.log(e.stack);
964
+ console.warn(e.stack);
966
965
  throw e;
967
966
  }
968
967
  })();
@@ -983,7 +982,7 @@ class SpiceModel {
983
982
  touch_response = yield _this10.database.touch(args.id, args._ttl);
984
983
  return touch_response;
985
984
  } catch (e) {
986
- console.log(e.stack);
985
+ console.warn(e.stack);
987
986
  throw e;
988
987
  }
989
988
  })();
@@ -1063,7 +1062,7 @@ class SpiceModel {
1063
1062
 
1064
1063
  return yield doDelete();
1065
1064
  } catch (e) {
1066
- console.log(e.stack);
1065
+ console.warn(e.stack);
1067
1066
  throw e;
1068
1067
  }
1069
1068
  })();
@@ -1433,7 +1432,7 @@ class SpiceModel {
1433
1432
 
1434
1433
  return yield doList();
1435
1434
  } catch (e) {
1436
- console.log(e.stack);
1435
+ console.warn(e.stack);
1437
1436
  throw e;
1438
1437
  }
1439
1438
  })();
@@ -1745,14 +1744,16 @@ class SpiceModel {
1745
1744
  var {
1746
1745
  when,
1747
1746
  execute,
1748
- field = null
1747
+ field = null,
1748
+ sourceField = null
1749
1749
  } = _ref15;
1750
1750
 
1751
1751
  if (this[_serializers][when]) {
1752
1752
  // Store as object with field info for column-based filtering
1753
1753
  this[_serializers][when]["modifiers"].push({
1754
1754
  execute,
1755
- field
1755
+ field,
1756
+ sourceField
1756
1757
  });
1757
1758
  }
1758
1759
  }
@@ -1792,6 +1793,8 @@ class SpiceModel {
1792
1793
  when: properties[i].map.when || "read",
1793
1794
  field: destinationField,
1794
1795
  // ⚡ Track which field this modifier populates
1796
+ sourceField: i,
1797
+ // ⚡ Track source property for column filtering
1795
1798
  execute: function () {
1796
1799
  var _execute = _asyncToGenerator(function* (data) {
1797
1800
  return yield _this17.mapToObject(data, _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, i, destinationField, properties[i]);
@@ -1815,6 +1818,8 @@ class SpiceModel {
1815
1818
  when: properties[i].map.when || "read",
1816
1819
  field: destinationField,
1817
1820
  // ⚡ Track which field this modifier populates
1821
+ sourceField: i,
1822
+ // ⚡ Track source property for column filtering
1818
1823
  execute: function () {
1819
1824
  var _execute2 = _asyncToGenerator(function* (data) {
1820
1825
  return yield _this17.mapToObjectArray(data, _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, i, destinationField, properties[i]);
@@ -1925,8 +1930,8 @@ class SpiceModel {
1925
1930
  var genericModifiers = [];
1926
1931
 
1927
1932
  for (var modifier of modifiers) {
1928
- // Skip field-specific modifiers if columns specified and field not requested
1929
- if (requestedColumns && modifier.field && !requestedColumns.has(modifier.field)) {
1933
+ // Skip field-specific modifiers if columns specified and neither source nor destination field is requested
1934
+ if (requestedColumns && modifier.field && !requestedColumns.has(modifier.field) && !(modifier.sourceField && requestedColumns.has(modifier.sourceField))) {
1930
1935
  continue;
1931
1936
  } // Field modifiers have a .field property and .execute function - they can run in parallel
1932
1937
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.82",
3
+ "version": "2.6.85",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -3,8 +3,8 @@ const crypto = require("crypto");
3
3
 
4
4
  function generateCacheKey(input) {
5
5
  // Create an MD5 hash of the input string and return it in hexadecimal format
6
- //return crypto.createHash("md5").update(input).digest("hex");
7
- return input;
6
+ return crypto.createHash("md5").update(input).digest("hex");
7
+ //return input;
8
8
  }
9
9
 
10
10
  module.exports = class SpiceCache {
@@ -157,7 +157,6 @@ export default class SpiceModel {
157
157
  }
158
158
  return props;
159
159
  }
160
- //console.log("Applying Overrides to :", this.collection,'||', args.collection)
161
160
  args.props = applySchemaOverrides(
162
161
  removeDynamicProps(args.props),
163
162
  args.collection
@@ -221,7 +220,7 @@ export default class SpiceModel {
221
220
  that = this;
222
221
  this.createModifiersFromProps();
223
222
  } catch (e) {
224
- console.log(e.stack);
223
+ console.warn(e.stack);
225
224
  }
226
225
  // }
227
226
  }
@@ -592,7 +591,7 @@ export default class SpiceModel {
592
591
  }
593
592
  return await doGet();
594
593
  } catch (e) {
595
- console.log(e.message, e);
594
+ console.warn(e.message, e);
596
595
  throw e;
597
596
  }
598
597
  }
@@ -655,7 +654,7 @@ export default class SpiceModel {
655
654
 
656
655
  return results;
657
656
  } catch (e) {
658
- console.log(e.stack);
657
+ console.warn(e.stack);
659
658
  throw e;
660
659
  }
661
660
  }
@@ -763,7 +762,7 @@ export default class SpiceModel {
763
762
  }
764
763
  return await doUpdate();
765
764
  } catch (e) {
766
- console.log("Error on update", e, e.stack);
765
+ console.warn("Error on update", e, e.stack);
767
766
  throw e;
768
767
  }
769
768
  }
@@ -836,7 +835,7 @@ export default class SpiceModel {
836
835
  }
837
836
  return await doCreate();
838
837
  } catch (e) {
839
- console.log(e.stack);
838
+ console.warn(e.stack);
840
839
  throw e;
841
840
  }
842
841
  }
@@ -852,7 +851,7 @@ export default class SpiceModel {
852
851
  touch_response = await this.database.touch(args.id, args._ttl);
853
852
  return touch_response;
854
853
  } catch (e) {
855
- console.log(e.stack);
854
+ console.warn(e.stack);
856
855
  throw e;
857
856
  }
858
857
  }
@@ -902,7 +901,7 @@ export default class SpiceModel {
902
901
  }
903
902
  return await doDelete();
904
903
  } catch (e) {
905
- console.log(e.stack);
904
+ console.warn(e.stack);
906
905
  throw e;
907
906
  }
908
907
  }
@@ -1290,7 +1289,7 @@ export default class SpiceModel {
1290
1289
  }
1291
1290
  return await doList();
1292
1291
  } catch (e) {
1293
- console.log(e.stack);
1292
+ console.warn(e.stack);
1294
1293
  throw e;
1295
1294
  }
1296
1295
  }
@@ -1590,10 +1589,14 @@ export default class SpiceModel {
1590
1589
  return original_is_array ? data : data[0];
1591
1590
  }
1592
1591
 
1593
- addModifier({ when, execute, field = null }) {
1592
+ addModifier({ when, execute, field = null, sourceField = null }) {
1594
1593
  if (this[_serializers][when]) {
1595
1594
  // Store as object with field info for column-based filtering
1596
- this[_serializers][when]["modifiers"].push({ execute, field });
1595
+ this[_serializers][when]["modifiers"].push({
1596
+ execute,
1597
+ field,
1598
+ sourceField,
1599
+ });
1597
1600
  }
1598
1601
  }
1599
1602
 
@@ -1621,6 +1624,7 @@ export default class SpiceModel {
1621
1624
  this.addModifier({
1622
1625
  when: properties[i].map.when || "read",
1623
1626
  field: destinationField, // ⚡ Track which field this modifier populates
1627
+ sourceField: i, // ⚡ Track source property for column filtering
1624
1628
  execute: async (data) => {
1625
1629
  return await this.mapToObject(
1626
1630
  data,
@@ -1640,6 +1644,7 @@ export default class SpiceModel {
1640
1644
  this.addModifier({
1641
1645
  when: properties[i].map.when || "read",
1642
1646
  field: destinationField, // ⚡ Track which field this modifier populates
1647
+ sourceField: i, // ⚡ Track source property for column filtering
1643
1648
  execute: async (data) => {
1644
1649
  return await this.mapToObjectArray(
1645
1650
  data,
@@ -1727,11 +1732,12 @@ export default class SpiceModel {
1727
1732
  const genericModifiers = [];
1728
1733
 
1729
1734
  for (const modifier of modifiers) {
1730
- // Skip field-specific modifiers if columns specified and field not requested
1735
+ // Skip field-specific modifiers if columns specified and neither source nor destination field is requested
1731
1736
  if (
1732
1737
  requestedColumns &&
1733
1738
  modifier.field &&
1734
- !requestedColumns.has(modifier.field)
1739
+ !requestedColumns.has(modifier.field) &&
1740
+ !(modifier.sourceField && requestedColumns.has(modifier.sourceField))
1735
1741
  ) {
1736
1742
  continue;
1737
1743
  }