spice-js 2.7.0 → 2.7.1
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.
- package/build/models/SpiceModel.js +5 -33
- package/package.json +1 -1
- package/src/models/SpiceModel.js +4 -42
|
@@ -1924,52 +1924,24 @@ class SpiceModel {
|
|
|
1924
1924
|
var requestedColumns = _this18.parseRequestedColumns(args == null ? void 0 : args.columns); // Cache the modifiers lookup for the specified type.
|
|
1925
1925
|
|
|
1926
1926
|
|
|
1927
|
-
var modifiers = ((_this18$_serializers = _this18[_serializers]) == null ? void 0 : (_this18$_serializers$ = _this18$_serializers[type]) == null ? void 0 : _this18$_serializers$.modifiers) || []; //
|
|
1928
|
-
|
|
1929
|
-
var fieldModifiers = [];
|
|
1930
|
-
var genericModifiers = [];
|
|
1927
|
+
var modifiers = ((_this18$_serializers = _this18[_serializers]) == null ? void 0 : (_this18$_serializers$ = _this18$_serializers[type]) == null ? void 0 : _this18$_serializers$.modifiers) || []; // Run modifiers serially
|
|
1931
1928
|
|
|
1932
1929
|
for (var modifier of modifiers) {
|
|
1933
|
-
// Skip field-specific modifiers if columns specified and
|
|
1930
|
+
// Skip field-specific modifiers if columns specified and field is not requested
|
|
1934
1931
|
if (requestedColumns && modifier.field && !requestedColumns.has(modifier.field) && !(modifier.sourceField && requestedColumns.has(modifier.sourceField))) {
|
|
1935
1932
|
continue;
|
|
1936
|
-
} // Field modifiers have a .field property and .execute function - they can run in parallel
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
if (modifier.field && typeof modifier.execute === "function") {
|
|
1940
|
-
fieldModifiers.push(modifier);
|
|
1941
|
-
} else {
|
|
1942
|
-
genericModifiers.push(modifier);
|
|
1943
1933
|
}
|
|
1944
|
-
} // Run generic modifiers serially first (they may transform the data structure)
|
|
1945
1934
|
|
|
1946
|
-
|
|
1947
|
-
for (var _modifier of genericModifiers) {
|
|
1948
1935
|
try {
|
|
1949
|
-
|
|
1936
|
+
// Handle both function modifiers and object modifiers with .execute
|
|
1937
|
+
var executeFn = typeof modifier === "function" ? modifier : modifier.execute;
|
|
1950
1938
|
var result = yield executeFn(data, old_data, _this18[_ctx], _this18.type); // Only assign if modifier returned a value to prevent data corruption
|
|
1951
1939
|
|
|
1952
1940
|
if (result !== undefined) {
|
|
1953
1941
|
data = result;
|
|
1954
1942
|
}
|
|
1955
1943
|
} catch (error) {
|
|
1956
|
-
console.error("Modifier error in do_serialize
|
|
1957
|
-
}
|
|
1958
|
-
} // Run field-specific modifiers SERIALLY to allow proper deduplication
|
|
1959
|
-
// of nested relation lookups (parallel execution causes duplicate fetches
|
|
1960
|
-
// when related entities have circular references like user fields)
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
for (var _modifier2 of fieldModifiers) {
|
|
1964
|
-
try {
|
|
1965
|
-
var _result = yield _modifier2.execute(data, old_data, _this18[_ctx], _this18.type); // Only assign if modifier returned a value to prevent data corruption
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
if (_result !== undefined) {
|
|
1969
|
-
data = _result;
|
|
1970
|
-
}
|
|
1971
|
-
} catch (error) {
|
|
1972
|
-
console.error("Modifier error for field " + _modifier2.field + ":", error.stack);
|
|
1944
|
+
console.error("Modifier error in do_serialize:", error.stack);
|
|
1973
1945
|
}
|
|
1974
1946
|
} // Ensure data is always an array for consistent processing.
|
|
1975
1947
|
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -1727,12 +1727,9 @@ export default class SpiceModel {
|
|
|
1727
1727
|
// Cache the modifiers lookup for the specified type.
|
|
1728
1728
|
const modifiers = this[_serializers]?.[type]?.modifiers || [];
|
|
1729
1729
|
|
|
1730
|
-
//
|
|
1731
|
-
const fieldModifiers = [];
|
|
1732
|
-
const genericModifiers = [];
|
|
1733
|
-
|
|
1730
|
+
// Run modifiers serially
|
|
1734
1731
|
for (const modifier of modifiers) {
|
|
1735
|
-
// Skip field-specific modifiers if columns specified and
|
|
1732
|
+
// Skip field-specific modifiers if columns specified and field is not requested
|
|
1736
1733
|
if (
|
|
1737
1734
|
requestedColumns &&
|
|
1738
1735
|
modifier.field &&
|
|
@@ -1742,17 +1739,8 @@ export default class SpiceModel {
|
|
|
1742
1739
|
continue;
|
|
1743
1740
|
}
|
|
1744
1741
|
|
|
1745
|
-
// Field modifiers have a .field property and .execute function - they can run in parallel
|
|
1746
|
-
if (modifier.field && typeof modifier.execute === "function") {
|
|
1747
|
-
fieldModifiers.push(modifier);
|
|
1748
|
-
} else {
|
|
1749
|
-
genericModifiers.push(modifier);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
// Run generic modifiers serially first (they may transform the data structure)
|
|
1754
|
-
for (const modifier of genericModifiers) {
|
|
1755
1742
|
try {
|
|
1743
|
+
// Handle both function modifiers and object modifiers with .execute
|
|
1756
1744
|
const executeFn =
|
|
1757
1745
|
typeof modifier === "function" ? modifier : modifier.execute;
|
|
1758
1746
|
const result = await executeFn(data, old_data, this[_ctx], this.type);
|
|
@@ -1761,33 +1749,7 @@ export default class SpiceModel {
|
|
|
1761
1749
|
data = result;
|
|
1762
1750
|
}
|
|
1763
1751
|
} catch (error) {
|
|
1764
|
-
console.error(
|
|
1765
|
-
"Modifier error in do_serialize (generic):",
|
|
1766
|
-
error.stack
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
// Run field-specific modifiers SERIALLY to allow proper deduplication
|
|
1772
|
-
// of nested relation lookups (parallel execution causes duplicate fetches
|
|
1773
|
-
// when related entities have circular references like user fields)
|
|
1774
|
-
for (const modifier of fieldModifiers) {
|
|
1775
|
-
try {
|
|
1776
|
-
const result = await modifier.execute(
|
|
1777
|
-
data,
|
|
1778
|
-
old_data,
|
|
1779
|
-
this[_ctx],
|
|
1780
|
-
this.type
|
|
1781
|
-
);
|
|
1782
|
-
// Only assign if modifier returned a value to prevent data corruption
|
|
1783
|
-
if (result !== undefined) {
|
|
1784
|
-
data = result;
|
|
1785
|
-
}
|
|
1786
|
-
} catch (error) {
|
|
1787
|
-
console.error(
|
|
1788
|
-
`Modifier error for field ${modifier.field}:`,
|
|
1789
|
-
error.stack
|
|
1790
|
-
);
|
|
1752
|
+
console.error("Modifier error in do_serialize:", error.stack);
|
|
1791
1753
|
}
|
|
1792
1754
|
}
|
|
1793
1755
|
|