spice-js 2.6.82 → 2.6.84
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
|
-
|
|
16
|
-
return input;
|
|
15
|
+
return crypto.createHash("md5").update(input).digest("hex"); //return input;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
module.exports = class SpiceCache {
|
|
@@ -1745,14 +1745,16 @@ class SpiceModel {
|
|
|
1745
1745
|
var {
|
|
1746
1746
|
when,
|
|
1747
1747
|
execute,
|
|
1748
|
-
field = null
|
|
1748
|
+
field = null,
|
|
1749
|
+
sourceField = null
|
|
1749
1750
|
} = _ref15;
|
|
1750
1751
|
|
|
1751
1752
|
if (this[_serializers][when]) {
|
|
1752
1753
|
// Store as object with field info for column-based filtering
|
|
1753
1754
|
this[_serializers][when]["modifiers"].push({
|
|
1754
1755
|
execute,
|
|
1755
|
-
field
|
|
1756
|
+
field,
|
|
1757
|
+
sourceField
|
|
1756
1758
|
});
|
|
1757
1759
|
}
|
|
1758
1760
|
}
|
|
@@ -1779,6 +1781,8 @@ class SpiceModel {
|
|
|
1779
1781
|
|
|
1780
1782
|
var _loop = function _loop(i) {
|
|
1781
1783
|
if (properties[i].map) {
|
|
1784
|
+
console.log("properties[i].map", properties[i].map);
|
|
1785
|
+
|
|
1782
1786
|
switch (properties[i].map.type) {
|
|
1783
1787
|
case _2.MapType.MODEL:
|
|
1784
1788
|
{
|
|
@@ -1792,6 +1796,8 @@ class SpiceModel {
|
|
|
1792
1796
|
when: properties[i].map.when || "read",
|
|
1793
1797
|
field: destinationField,
|
|
1794
1798
|
// ⚡ Track which field this modifier populates
|
|
1799
|
+
sourceField: i,
|
|
1800
|
+
// ⚡ Track source property for column filtering
|
|
1795
1801
|
execute: function () {
|
|
1796
1802
|
var _execute = _asyncToGenerator(function* (data) {
|
|
1797
1803
|
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 +1821,8 @@ class SpiceModel {
|
|
|
1815
1821
|
when: properties[i].map.when || "read",
|
|
1816
1822
|
field: destinationField,
|
|
1817
1823
|
// ⚡ Track which field this modifier populates
|
|
1824
|
+
sourceField: i,
|
|
1825
|
+
// ⚡ Track source property for column filtering
|
|
1818
1826
|
execute: function () {
|
|
1819
1827
|
var _execute2 = _asyncToGenerator(function* (data) {
|
|
1820
1828
|
return yield _this17.mapToObjectArray(data, _.isString(properties[i].map.reference) ? spice.models[properties[i].map.reference] : properties[i].map.reference, i, destinationField, properties[i]);
|
|
@@ -1910,6 +1918,8 @@ class SpiceModel {
|
|
|
1910
1918
|
|
|
1911
1919
|
|
|
1912
1920
|
if (_this18.type && !_this18[_external_modifier_loaded]) {
|
|
1921
|
+
console.trace("adding external modifiers", _this18.type);
|
|
1922
|
+
|
|
1913
1923
|
_this18.addExternalModifiers(_this18.type);
|
|
1914
1924
|
|
|
1915
1925
|
_this18[_external_modifier_loaded] = true;
|
|
@@ -1925,8 +1935,9 @@ class SpiceModel {
|
|
|
1925
1935
|
var genericModifiers = [];
|
|
1926
1936
|
|
|
1927
1937
|
for (var modifier of modifiers) {
|
|
1928
|
-
// Skip field-specific modifiers if columns specified and field
|
|
1929
|
-
|
|
1938
|
+
console.log("modifier", modifier); // Skip field-specific modifiers if columns specified and neither source nor destination field is requested
|
|
1939
|
+
|
|
1940
|
+
if (requestedColumns && modifier.field && !requestedColumns.has(modifier.field) && !(modifier.sourceField && requestedColumns.has(modifier.sourceField))) {
|
|
1930
1941
|
continue;
|
|
1931
1942
|
} // Field modifiers have a .field property and .execute function - they can run in parallel
|
|
1932
1943
|
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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 {
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -1590,10 +1590,14 @@ export default class SpiceModel {
|
|
|
1590
1590
|
return original_is_array ? data : data[0];
|
|
1591
1591
|
}
|
|
1592
1592
|
|
|
1593
|
-
addModifier({ when, execute, field = null }) {
|
|
1593
|
+
addModifier({ when, execute, field = null, sourceField = null }) {
|
|
1594
1594
|
if (this[_serializers][when]) {
|
|
1595
1595
|
// Store as object with field info for column-based filtering
|
|
1596
|
-
this[_serializers][when]["modifiers"].push({
|
|
1596
|
+
this[_serializers][when]["modifiers"].push({
|
|
1597
|
+
execute,
|
|
1598
|
+
field,
|
|
1599
|
+
sourceField,
|
|
1600
|
+
});
|
|
1597
1601
|
}
|
|
1598
1602
|
}
|
|
1599
1603
|
|
|
@@ -1612,6 +1616,7 @@ export default class SpiceModel {
|
|
|
1612
1616
|
createMofifier(properties) {
|
|
1613
1617
|
for (let i in properties) {
|
|
1614
1618
|
if (properties[i].map) {
|
|
1619
|
+
console.log("properties[i].map", properties[i].map);
|
|
1615
1620
|
switch (properties[i].map.type) {
|
|
1616
1621
|
case MapType.MODEL: {
|
|
1617
1622
|
const destinationField = properties[i].map.destination || i;
|
|
@@ -1621,6 +1626,7 @@ export default class SpiceModel {
|
|
|
1621
1626
|
this.addModifier({
|
|
1622
1627
|
when: properties[i].map.when || "read",
|
|
1623
1628
|
field: destinationField, // ⚡ Track which field this modifier populates
|
|
1629
|
+
sourceField: i, // ⚡ Track source property for column filtering
|
|
1624
1630
|
execute: async (data) => {
|
|
1625
1631
|
return await this.mapToObject(
|
|
1626
1632
|
data,
|
|
@@ -1640,6 +1646,7 @@ export default class SpiceModel {
|
|
|
1640
1646
|
this.addModifier({
|
|
1641
1647
|
when: properties[i].map.when || "read",
|
|
1642
1648
|
field: destinationField, // ⚡ Track which field this modifier populates
|
|
1649
|
+
sourceField: i, // ⚡ Track source property for column filtering
|
|
1643
1650
|
execute: async (data) => {
|
|
1644
1651
|
return await this.mapToObjectArray(
|
|
1645
1652
|
data,
|
|
@@ -1712,6 +1719,7 @@ export default class SpiceModel {
|
|
|
1712
1719
|
|
|
1713
1720
|
// Add external modifiers only once.
|
|
1714
1721
|
if (this.type && !this[_external_modifier_loaded]) {
|
|
1722
|
+
console.trace("adding external modifiers", this.type);
|
|
1715
1723
|
this.addExternalModifiers(this.type);
|
|
1716
1724
|
this[_external_modifier_loaded] = true;
|
|
1717
1725
|
}
|
|
@@ -1727,11 +1735,13 @@ export default class SpiceModel {
|
|
|
1727
1735
|
const genericModifiers = [];
|
|
1728
1736
|
|
|
1729
1737
|
for (const modifier of modifiers) {
|
|
1730
|
-
|
|
1738
|
+
console.log("modifier", modifier);
|
|
1739
|
+
// Skip field-specific modifiers if columns specified and neither source nor destination field is requested
|
|
1731
1740
|
if (
|
|
1732
1741
|
requestedColumns &&
|
|
1733
1742
|
modifier.field &&
|
|
1734
|
-
!requestedColumns.has(modifier.field)
|
|
1743
|
+
!requestedColumns.has(modifier.field) &&
|
|
1744
|
+
!(modifier.sourceField && requestedColumns.has(modifier.sourceField))
|
|
1735
1745
|
) {
|
|
1736
1746
|
continue;
|
|
1737
1747
|
}
|