spice-js 2.6.34 → 2.6.35
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 +80 -56
- package/package.json +1 -1
- package/src/models/SpiceModel.js +12 -12
|
@@ -49,6 +49,8 @@ if (!Promise.allSettled) {
|
|
|
49
49
|
|
|
50
50
|
class SpiceModel {
|
|
51
51
|
constructor(args) {
|
|
52
|
+
var _args$props$i;
|
|
53
|
+
|
|
52
54
|
if (args === void 0) {
|
|
53
55
|
args = {};
|
|
54
56
|
}
|
|
@@ -166,7 +168,7 @@ class SpiceModel {
|
|
|
166
168
|
for (var i in args.props) {
|
|
167
169
|
if (args.args != undefined) {
|
|
168
170
|
if (args.args[i] != undefined) {
|
|
169
|
-
switch (args.props[i].type) {
|
|
171
|
+
switch ((_args$props$i = args.props[i]) == null ? void 0 : _args$props$i.type) {
|
|
170
172
|
case String:
|
|
171
173
|
case "string":
|
|
172
174
|
{
|
|
@@ -258,7 +260,7 @@ class SpiceModel {
|
|
|
258
260
|
var _this$_ctx, _this$_ctx$state;
|
|
259
261
|
|
|
260
262
|
if ((_this$_ctx = _this[_ctx]) == null ? void 0 : (_this$_ctx$state = _this$_ctx.state) == null ? void 0 : _this$_ctx$state.process_fields) {
|
|
261
|
-
var returned = yield new _this[_ctx].state.process_fields().process(_this[_ctx], data, _this.type);
|
|
263
|
+
var returned = yield new _this[_ctx].state.process_fields().process(_this[_ctx], data, _this == null ? void 0 : _this.type);
|
|
262
264
|
return returned;
|
|
263
265
|
} else {
|
|
264
266
|
return data;
|
|
@@ -529,7 +531,7 @@ class SpiceModel {
|
|
|
529
531
|
return _asyncToGenerator(function* () {
|
|
530
532
|
var obj = _this3.getCacheProviderObject();
|
|
531
533
|
|
|
532
|
-
var monitor_record = yield obj.get("monitor::" + _this3.type);
|
|
534
|
+
var monitor_record = yield obj.get("monitor::" + (_this3 == null ? void 0 : _this3.type));
|
|
533
535
|
|
|
534
536
|
if (monitor_record == undefined) {
|
|
535
537
|
return false;
|
|
@@ -546,7 +548,7 @@ class SpiceModel {
|
|
|
546
548
|
setMonitor() {
|
|
547
549
|
var current_time = new Date().getTime();
|
|
548
550
|
var obj = this.getCacheProviderObject();
|
|
549
|
-
var key = "monitor::" + this.type;
|
|
551
|
+
var key = "monitor::" + (this == null ? void 0 : this.type);
|
|
550
552
|
var value = {
|
|
551
553
|
time: current_time
|
|
552
554
|
};
|
|
@@ -565,37 +567,43 @@ class SpiceModel {
|
|
|
565
567
|
}
|
|
566
568
|
|
|
567
569
|
if (_.isString(args.id)) {
|
|
570
|
+
var _results, _results3, _results5, _results6;
|
|
571
|
+
|
|
568
572
|
if (args.skip_hooks != true) {
|
|
569
573
|
yield _this4.run_hook(args, "get", "before");
|
|
570
574
|
}
|
|
571
575
|
|
|
572
|
-
var key = "get::" + _this4.type + "::" + args.id;
|
|
576
|
+
var key = "get::" + (_this4 == null ? void 0 : _this4.type) + "::" + args.id;
|
|
573
577
|
var results = {};
|
|
574
578
|
|
|
575
|
-
if (_this4.shouldUseCache(_this4.type)) {
|
|
576
|
-
var cached_results = yield _this4.getCacheProviderObject(_this4.type).get(key);
|
|
579
|
+
if (_this4.shouldUseCache(_this4 == null ? void 0 : _this4.type)) {
|
|
580
|
+
var cached_results = yield _this4.getCacheProviderObject(_this4 == null ? void 0 : _this4.type).get(key);
|
|
577
581
|
results = cached_results == null ? void 0 : cached_results.value;
|
|
578
582
|
|
|
579
|
-
if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this4.shouldForceRefresh(cached_results)) || _this4.type == "workflow") {
|
|
583
|
+
if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this4.shouldForceRefresh(cached_results)) || (_this4 == null ? void 0 : _this4.type) == "workflow") {
|
|
580
584
|
results = yield _this4.database.get(args.id);
|
|
581
|
-
yield _this4.getCacheProviderObject(_this4.type).set(key, {
|
|
585
|
+
yield _this4.getCacheProviderObject(_this4 == null ? void 0 : _this4.type).set(key, {
|
|
582
586
|
value: results,
|
|
583
587
|
time: new Date().getTime()
|
|
584
|
-
}, _this4.getCacheConfig(_this4.type));
|
|
588
|
+
}, _this4.getCacheConfig(_this4 == null ? void 0 : _this4.type));
|
|
585
589
|
}
|
|
586
590
|
} else {
|
|
587
591
|
results = yield _this4.database.get(args.id);
|
|
588
592
|
}
|
|
589
593
|
|
|
590
|
-
if (results.type != undefined) {
|
|
591
|
-
|
|
594
|
+
if (((_results = results) == null ? void 0 : _results.type) != undefined) {
|
|
595
|
+
var _results2;
|
|
596
|
+
|
|
597
|
+
if (((_results2 = results) == null ? void 0 : _results2.type) != (_this4 == null ? void 0 : _this4.type)) throw new Error((_this4 == null ? void 0 : _this4.type) + " does not exist type");
|
|
592
598
|
}
|
|
593
599
|
|
|
594
|
-
if (results._type != undefined) {
|
|
595
|
-
|
|
600
|
+
if (((_results3 = results) == null ? void 0 : _results3._type) != undefined) {
|
|
601
|
+
var _results4;
|
|
602
|
+
|
|
603
|
+
if (((_results4 = results) == null ? void 0 : _results4._type) != (_this4 == null ? void 0 : _this4.type)) throw new Error((_this4 == null ? void 0 : _this4.type) + " does not exist _type");
|
|
596
604
|
}
|
|
597
605
|
|
|
598
|
-
if (results.deleted == undefined || results.deleted == false) {
|
|
606
|
+
if (((_results5 = results) == null ? void 0 : _results5.deleted) == undefined || ((_results6 = results) == null ? void 0 : _results6.deleted) == false) {
|
|
599
607
|
if (args.skip_read_serialize != true && args.skip_serialize != true) {
|
|
600
608
|
results = yield _this4.do_serialize(results, "read", {}, args, (yield _this4.propsToBeRemoved(results)));
|
|
601
609
|
}
|
|
@@ -606,7 +614,7 @@ class SpiceModel {
|
|
|
606
614
|
|
|
607
615
|
return results;
|
|
608
616
|
} else {
|
|
609
|
-
throw new Error(_this4.type + " does not exist");
|
|
617
|
+
throw new Error((_this4 == null ? void 0 : _this4.type) + " does not exist");
|
|
610
618
|
}
|
|
611
619
|
}
|
|
612
620
|
} catch (e) {
|
|
@@ -644,29 +652,29 @@ class SpiceModel {
|
|
|
644
652
|
|
|
645
653
|
_.remove(args.ids, o => o == undefined);
|
|
646
654
|
|
|
647
|
-
var key = "multi-get::" + _this6.type + "::" + _.join(args.ids, "|");
|
|
655
|
+
var key = "multi-get::" + (_this6 == null ? void 0 : _this6.type) + "::" + _.join(args.ids, "|");
|
|
648
656
|
|
|
649
657
|
var results = [];
|
|
650
658
|
|
|
651
659
|
if (args.ids.length > 0) {
|
|
652
|
-
if (_this6.shouldUseCache(_this6.type)) {
|
|
653
|
-
var cached_results = yield _this6.getCacheProviderObject(_this6.type).get(key);
|
|
660
|
+
if (_this6.shouldUseCache(_this6 == null ? void 0 : _this6.type)) {
|
|
661
|
+
var cached_results = yield _this6.getCacheProviderObject(_this6 == null ? void 0 : _this6.type).get(key);
|
|
654
662
|
results = cached_results == null ? void 0 : cached_results.value;
|
|
655
663
|
|
|
656
664
|
if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this6.shouldForceRefresh(cached_results))) {
|
|
657
665
|
results = yield _this6.database.multi_get(args.ids, true);
|
|
658
666
|
|
|
659
|
-
_this6.getCacheProviderObject(_this6.type).set(key, {
|
|
667
|
+
_this6.getCacheProviderObject(_this6 == null ? void 0 : _this6.type).set(key, {
|
|
660
668
|
value: results,
|
|
661
669
|
time: new Date().getTime()
|
|
662
|
-
}, _this6.getCacheConfig(_this6.type));
|
|
670
|
+
}, _this6.getCacheConfig(_this6 == null ? void 0 : _this6.type));
|
|
663
671
|
}
|
|
664
672
|
} else {
|
|
665
673
|
results = yield _this6.database.multi_get(args.ids, true);
|
|
666
674
|
}
|
|
667
675
|
}
|
|
668
676
|
|
|
669
|
-
_.remove(results, o => o.type != _this6.type);
|
|
677
|
+
_.remove(results, o => (o == null ? void 0 : o.type) != (_this6 == null ? void 0 : _this6.type));
|
|
670
678
|
|
|
671
679
|
if (args.skip_read_serialize != true && args.skip_serialize != true) {
|
|
672
680
|
results = yield _this6.do_serialize(results, "read", {}, args, (yield _this6.propsToBeRemoved(results)));
|
|
@@ -691,17 +699,17 @@ class SpiceModel {
|
|
|
691
699
|
try {
|
|
692
700
|
if (_.isString(data)) {
|
|
693
701
|
var result = yield _this7.database.get(data);
|
|
694
|
-
if (result.type) if (result.type != _this7.type) {
|
|
702
|
+
if (result == null ? void 0 : result.type) if (result.type != (_this7 == null ? void 0 : _this7.type)) {
|
|
695
703
|
return false;
|
|
696
704
|
}
|
|
697
|
-
if (result._type) if (result._type != _this7.type) {
|
|
705
|
+
if (result == null ? void 0 : result._type) if (result._type != (_this7 == null ? void 0 : _this7.type)) {
|
|
698
706
|
return false;
|
|
699
707
|
}
|
|
700
708
|
} else {
|
|
701
|
-
if (data.type) if (data.type != _this7.type) {
|
|
709
|
+
if (data == null ? void 0 : data.type) if (data.type != (_this7 == null ? void 0 : _this7.type)) {
|
|
702
710
|
return false;
|
|
703
711
|
}
|
|
704
|
-
if (data._type) if (data._type != _this7.type) {
|
|
712
|
+
if (data == null ? void 0 : data._type) if (data._type != (_this7 == null ? void 0 : _this7.type)) {
|
|
705
713
|
return false;
|
|
706
714
|
}
|
|
707
715
|
}
|
|
@@ -723,7 +731,7 @@ class SpiceModel {
|
|
|
723
731
|
var item_exist = yield _this8.exist(results);
|
|
724
732
|
|
|
725
733
|
if (!item_exist) {
|
|
726
|
-
throw new Error(_this8.type + " does not exist. in update");
|
|
734
|
+
throw new Error((_this8 == null ? void 0 : _this8.type) + " does not exist. in update");
|
|
727
735
|
}
|
|
728
736
|
|
|
729
737
|
delete results["id"];
|
|
@@ -783,7 +791,7 @@ class SpiceModel {
|
|
|
783
791
|
var form;
|
|
784
792
|
_this9.created_at = new SDate().now();
|
|
785
793
|
args = _.defaults(args, {
|
|
786
|
-
id_prefix: _this9.type
|
|
794
|
+
id_prefix: _this9 == null ? void 0 : _this9.type
|
|
787
795
|
});
|
|
788
796
|
|
|
789
797
|
if (args.body) {
|
|
@@ -840,7 +848,7 @@ class SpiceModel {
|
|
|
840
848
|
var item_exist = yield _this10.exist(args.id);
|
|
841
849
|
|
|
842
850
|
if (!item_exist) {
|
|
843
|
-
throw new Error(_this10.type + " does not exist.");
|
|
851
|
+
throw new Error((_this10 == null ? void 0 : _this10.type) + " does not exist.");
|
|
844
852
|
}
|
|
845
853
|
|
|
846
854
|
var results = yield _this10.database.get(args.id);
|
|
@@ -949,7 +957,7 @@ class SpiceModel {
|
|
|
949
957
|
return returnVal;
|
|
950
958
|
}
|
|
951
959
|
|
|
952
|
-
var nestings = [...extractNestings((_args4 = args) == null ? void 0 : _args4.query, _this11.type), ...extractNestings((_args5 = args) == null ? void 0 : _args5.columns, _this11.type), ...extractNestings((_args6 = args) == null ? void 0 : _args6.sort, _this11.type)];
|
|
960
|
+
var nestings = [...extractNestings((_args4 = args) == null ? void 0 : _args4.query, _this11 == null ? void 0 : _this11.type), ...extractNestings((_args5 = args) == null ? void 0 : _args5.columns, _this11 == null ? void 0 : _this11.type), ...extractNestings((_args6 = args) == null ? void 0 : _args6.sort, _this11 == null ? void 0 : _this11.type)];
|
|
953
961
|
|
|
954
962
|
var mappedNestings = _.compact(_.map(_.uniq(nestings), nesting => {
|
|
955
963
|
var prop = _this11.props[nesting];
|
|
@@ -989,9 +997,9 @@ class SpiceModel {
|
|
|
989
997
|
query = _this11.makeQueryFromFilter(args.filters);
|
|
990
998
|
} else {
|
|
991
999
|
if (args.query) {
|
|
992
|
-
query = args.query + (" AND (`" + _this11.type + "`.deleted = false OR `" + _this11.type + "`.deleted IS MISSING) ");
|
|
1000
|
+
query = args.query + (" AND (`" + (_this11 == null ? void 0 : _this11.type) + "`.deleted = false OR `" + (_this11 == null ? void 0 : _this11.type) + "`.deleted IS MISSING) ");
|
|
993
1001
|
} else {
|
|
994
|
-
query = "(`" + _this11.type + "`.deleted = false OR `" + _this11.type + "`.deleted IS MISSING) ";
|
|
1002
|
+
query = "(`" + (_this11 == null ? void 0 : _this11.type) + "`.deleted = false OR `" + (_this11 == null ? void 0 : _this11.type) + "`.deleted IS MISSING) ";
|
|
995
1003
|
}
|
|
996
1004
|
}
|
|
997
1005
|
}
|
|
@@ -1018,7 +1026,7 @@ class SpiceModel {
|
|
|
1018
1026
|
}
|
|
1019
1027
|
|
|
1020
1028
|
if (!args.sort) {
|
|
1021
|
-
args.sort = "`" + _this11.type + "`.created_at DESC";
|
|
1029
|
+
args.sort = "`" + (_this11 == null ? void 0 : _this11.type) + "`.created_at DESC";
|
|
1022
1030
|
} else {
|
|
1023
1031
|
var sort_array = args.sort.split(","); // check the first string in each item in the array to see if it contains a . if not then add the type
|
|
1024
1032
|
|
|
@@ -1026,7 +1034,7 @@ class SpiceModel {
|
|
|
1026
1034
|
|
|
1027
1035
|
for (var i = 0; i < sort_array.length; i++) {
|
|
1028
1036
|
if (!sort_array[i].includes(".")) {
|
|
1029
|
-
new_sort_array.push("`" + _this11.type + "`." + formatSortComponent(sort_array[i]));
|
|
1037
|
+
new_sort_array.push("`" + (_this11 == null ? void 0 : _this11.type) + "`." + formatSortComponent(sort_array[i]));
|
|
1030
1038
|
} else {
|
|
1031
1039
|
new_sort_array.push(sort_array[i]);
|
|
1032
1040
|
}
|
|
@@ -1043,22 +1051,22 @@ class SpiceModel {
|
|
|
1043
1051
|
return str.replace(/[^a-zA-Z0-9]/g, "");
|
|
1044
1052
|
}
|
|
1045
1053
|
|
|
1046
|
-
var key = removeSpaceAndSpecialCharacters("list::" + _this11.type + "::" + args._join + "::" + query + "::" + args.limit + "::" + args.offset + "::" + args.sort + "::" + args.do_count + "::" + args.statement_consistent + "::" + args.columns + "::" + args.is_full_text + "::" + args.is_custom_query);
|
|
1054
|
+
var key = removeSpaceAndSpecialCharacters("list::" + (_this11 == null ? void 0 : _this11.type) + "::" + args._join + "::" + query + "::" + args.limit + "::" + args.offset + "::" + args.sort + "::" + args.do_count + "::" + args.statement_consistent + "::" + args.columns + "::" + args.is_full_text + "::" + args.is_custom_query);
|
|
1047
1055
|
var results;
|
|
1048
1056
|
|
|
1049
1057
|
if (args.is_custom_query && args.is_custom_query === "true") {
|
|
1050
1058
|
if (args.ids.length > 0) {
|
|
1051
|
-
if (_this11.shouldUseCache(_this11.type)) {
|
|
1052
|
-
var cached_results = yield _this11.getCacheProviderObject(_this11.type).get(key);
|
|
1059
|
+
if (_this11.shouldUseCache(_this11 == null ? void 0 : _this11.type)) {
|
|
1060
|
+
var cached_results = yield _this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).get(key);
|
|
1053
1061
|
results = cached_results == null ? void 0 : cached_results.value;
|
|
1054
1062
|
|
|
1055
1063
|
if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this11.shouldForceRefresh(cached_results))) {
|
|
1056
1064
|
results = yield _this11.database.query(query);
|
|
1057
1065
|
|
|
1058
|
-
_this11.getCacheProviderObject(_this11.type).set(key, {
|
|
1066
|
+
_this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).set(key, {
|
|
1059
1067
|
value: results,
|
|
1060
1068
|
time: new Date().getTime()
|
|
1061
|
-
}, _this11.getCacheConfig(_this11.type));
|
|
1069
|
+
}, _this11.getCacheConfig(_this11 == null ? void 0 : _this11.type));
|
|
1062
1070
|
}
|
|
1063
1071
|
} else {
|
|
1064
1072
|
results = yield _this11.database.query(query);
|
|
@@ -1066,39 +1074,39 @@ class SpiceModel {
|
|
|
1066
1074
|
}
|
|
1067
1075
|
} else {
|
|
1068
1076
|
if (args.is_full_text && args.is_full_text === "true") {
|
|
1069
|
-
if (_this11.shouldUseCache(_this11.type)) {
|
|
1070
|
-
var _cached_results = yield _this11.getCacheProviderObject(_this11.type).get(key);
|
|
1077
|
+
if (_this11.shouldUseCache(_this11 == null ? void 0 : _this11.type)) {
|
|
1078
|
+
var _cached_results = yield _this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).get(key);
|
|
1071
1079
|
|
|
1072
1080
|
results = _cached_results == null ? void 0 : _cached_results.value;
|
|
1073
1081
|
|
|
1074
1082
|
if ((_cached_results == null ? void 0 : _cached_results.value) == undefined || (yield _this11.shouldForceRefresh(_cached_results))) {
|
|
1075
|
-
results = yield _this11.database.full_text_search(_this11.type, query || "", args.limit, args.offset, args._join);
|
|
1083
|
+
results = yield _this11.database.full_text_search(_this11 == null ? void 0 : _this11.type, query || "", args.limit, args.offset, args._join);
|
|
1076
1084
|
|
|
1077
|
-
_this11.getCacheProviderObject(_this11.type).set(key, {
|
|
1085
|
+
_this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).set(key, {
|
|
1078
1086
|
value: results,
|
|
1079
1087
|
time: new Date().getTime()
|
|
1080
|
-
}, _this11.getCacheConfig(_this11.type));
|
|
1088
|
+
}, _this11.getCacheConfig(_this11 == null ? void 0 : _this11.type));
|
|
1081
1089
|
}
|
|
1082
1090
|
} else {
|
|
1083
|
-
results = yield _this11.database.full_text_search(_this11.type, query || "", args.limit, args.offset, args._join);
|
|
1091
|
+
results = yield _this11.database.full_text_search(_this11 == null ? void 0 : _this11.type, query || "", args.limit, args.offset, args._join);
|
|
1084
1092
|
}
|
|
1085
1093
|
} else {
|
|
1086
|
-
if (_this11.shouldUseCache(_this11.type)) {
|
|
1087
|
-
var _cached_results2 = yield _this11.getCacheProviderObject(_this11.type).get(key);
|
|
1094
|
+
if (_this11.shouldUseCache(_this11 == null ? void 0 : _this11.type)) {
|
|
1095
|
+
var _cached_results2 = yield _this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).get(key);
|
|
1088
1096
|
|
|
1089
1097
|
results = _cached_results2 == null ? void 0 : _cached_results2.value;
|
|
1090
1098
|
var shouleForceRefresh = yield _this11.shouldForceRefresh(_cached_results2);
|
|
1091
1099
|
|
|
1092
1100
|
if ((_cached_results2 == null ? void 0 : _cached_results2.value) == undefined || shouleForceRefresh) {
|
|
1093
|
-
results = yield _this11.database.search(_this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
|
|
1101
|
+
results = yield _this11.database.search(_this11 == null ? void 0 : _this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
|
|
1094
1102
|
|
|
1095
|
-
_this11.getCacheProviderObject(_this11.type).set(key, {
|
|
1103
|
+
_this11.getCacheProviderObject(_this11 == null ? void 0 : _this11.type).set(key, {
|
|
1096
1104
|
value: results,
|
|
1097
1105
|
time: new Date().getTime()
|
|
1098
|
-
}, _this11.getCacheConfig(_this11.type));
|
|
1106
|
+
}, _this11.getCacheConfig(_this11 == null ? void 0 : _this11.type));
|
|
1099
1107
|
}
|
|
1100
1108
|
} else {
|
|
1101
|
-
results = yield _this11.database.search(_this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
|
|
1109
|
+
results = yield _this11.database.search(_this11 == null ? void 0 : _this11.type, args.columns || "", query || "", args.limit, args.offset, args.sort, args.do_count, args.statement_consistent, args._join);
|
|
1102
1110
|
}
|
|
1103
1111
|
}
|
|
1104
1112
|
}
|
|
@@ -1108,7 +1116,7 @@ class SpiceModel {
|
|
|
1108
1116
|
results.data = yield _this11.do_serialize(results.data, "read", {}, args, (yield _this11.propsToBeRemoved(results.data)));
|
|
1109
1117
|
}
|
|
1110
1118
|
|
|
1111
|
-
if (_this11.type == "resourcedetail") ;
|
|
1119
|
+
if ((_this11 == null ? void 0 : _this11.type) == "resourcedetail") ;
|
|
1112
1120
|
|
|
1113
1121
|
if (args.skip_hooks != true) {
|
|
1114
1122
|
yield _this11.run_hook(results.data, "list", "after");
|
|
@@ -1148,7 +1156,7 @@ class SpiceModel {
|
|
|
1148
1156
|
operation: op,
|
|
1149
1157
|
when,
|
|
1150
1158
|
old_data,
|
|
1151
|
-
resource: _this12.type,
|
|
1159
|
+
resource: _this12 == null ? void 0 : _this12.type,
|
|
1152
1160
|
ctx: _this12[_ctx]
|
|
1153
1161
|
}
|
|
1154
1162
|
});
|
|
@@ -1202,6 +1210,10 @@ class SpiceModel {
|
|
|
1202
1210
|
var ids = [];
|
|
1203
1211
|
|
|
1204
1212
|
_.each(data, result => {
|
|
1213
|
+
if (!result || result == "undefined") {
|
|
1214
|
+
result = {};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1205
1217
|
if (_.isString(result[source_property]) && result[source_property] != "") {
|
|
1206
1218
|
ids = _.union(ids, [result[source_property]]);
|
|
1207
1219
|
}
|
|
@@ -1221,6 +1233,10 @@ class SpiceModel {
|
|
|
1221
1233
|
})));
|
|
1222
1234
|
|
|
1223
1235
|
data = _.map(data, result => {
|
|
1236
|
+
if (!result || result == "undefined") {
|
|
1237
|
+
result = {};
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1224
1240
|
var result_found = _.find(ug, g => {
|
|
1225
1241
|
return g.id == result[source_property];
|
|
1226
1242
|
}) || {};
|
|
@@ -1246,6 +1262,10 @@ class SpiceModel {
|
|
|
1246
1262
|
_.each(data, result => {
|
|
1247
1263
|
var value = [];
|
|
1248
1264
|
|
|
1265
|
+
if (!result || result == "undefined") {
|
|
1266
|
+
result = {};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1249
1269
|
if (_.isArray(result[source_property])) {
|
|
1250
1270
|
value = result[source_property];
|
|
1251
1271
|
}
|
|
@@ -1278,6 +1298,10 @@ class SpiceModel {
|
|
|
1278
1298
|
|
|
1279
1299
|
|
|
1280
1300
|
_.each(data, result => {
|
|
1301
|
+
if (!result || result == "undefined") {
|
|
1302
|
+
result = {};
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1281
1305
|
if (_.isString(result[store_property])) {
|
|
1282
1306
|
result[store_property] = [result[store_property]];
|
|
1283
1307
|
}
|
|
@@ -1403,15 +1427,15 @@ class SpiceModel {
|
|
|
1403
1427
|
}
|
|
1404
1428
|
|
|
1405
1429
|
if (_this16.shouldSerializerRun(args, type)) {
|
|
1406
|
-
if (_this16.type != "" && _this16.type != undefined && _this16[_external_modifier_loaded] != true) {
|
|
1407
|
-
_this16.addExternalModifiers(_this16.type);
|
|
1430
|
+
if ((_this16 == null ? void 0 : _this16.type) != "" && (_this16 == null ? void 0 : _this16.type) != undefined && _this16[_external_modifier_loaded] != true) {
|
|
1431
|
+
_this16.addExternalModifiers(_this16 == null ? void 0 : _this16.type);
|
|
1408
1432
|
|
|
1409
1433
|
_this16[_external_modifier_loaded] = true;
|
|
1410
1434
|
}
|
|
1411
1435
|
|
|
1412
1436
|
for (var i of _this16[_serializers][type]["modifiers"]) {
|
|
1413
1437
|
try {
|
|
1414
|
-
data = yield i(data, old_data, _this16[_ctx], _this16.type);
|
|
1438
|
+
data = yield i(data, old_data, _this16[_ctx], _this16 == null ? void 0 : _this16.type);
|
|
1415
1439
|
} catch (e) {
|
|
1416
1440
|
console.log(e.stack);
|
|
1417
1441
|
}
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -483,9 +483,9 @@ export default class SpiceModel {
|
|
|
483
483
|
let key = `get::${this?.type}::${args.id}`;
|
|
484
484
|
let results = {};
|
|
485
485
|
if (this.shouldUseCache(this?.type)) {
|
|
486
|
-
let cached_results = await this.getCacheProviderObject(
|
|
487
|
-
|
|
488
|
-
);
|
|
486
|
+
let cached_results = await this.getCacheProviderObject(
|
|
487
|
+
this?.type
|
|
488
|
+
).get(key);
|
|
489
489
|
|
|
490
490
|
results = cached_results?.value;
|
|
491
491
|
if (
|
|
@@ -505,12 +505,12 @@ export default class SpiceModel {
|
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
if (results?.type != undefined) {
|
|
508
|
-
if (results
|
|
508
|
+
if (results?.type != this?.type)
|
|
509
509
|
throw new Error(`${this?.type} does not exist type`);
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
if (results?._type != undefined) {
|
|
513
|
-
if (results
|
|
513
|
+
if (results?._type != this?.type)
|
|
514
514
|
throw new Error(`${this?.type} does not exist _type`);
|
|
515
515
|
}
|
|
516
516
|
|
|
@@ -560,9 +560,9 @@ export default class SpiceModel {
|
|
|
560
560
|
let results = [];
|
|
561
561
|
if (args.ids.length > 0) {
|
|
562
562
|
if (this.shouldUseCache(this?.type)) {
|
|
563
|
-
let cached_results = await this.getCacheProviderObject(
|
|
564
|
-
|
|
565
|
-
);
|
|
563
|
+
let cached_results = await this.getCacheProviderObject(
|
|
564
|
+
this?.type
|
|
565
|
+
).get(key);
|
|
566
566
|
results = cached_results?.value;
|
|
567
567
|
if (
|
|
568
568
|
cached_results?.value == undefined ||
|
|
@@ -1120,7 +1120,7 @@ export default class SpiceModel {
|
|
|
1120
1120
|
|
|
1121
1121
|
let ids = [];
|
|
1122
1122
|
_.each(data, (result) => {
|
|
1123
|
-
if (!result || result== "undefined") {
|
|
1123
|
+
if (!result || result == "undefined") {
|
|
1124
1124
|
result = {};
|
|
1125
1125
|
}
|
|
1126
1126
|
if (
|
|
@@ -1151,7 +1151,7 @@ export default class SpiceModel {
|
|
|
1151
1151
|
);
|
|
1152
1152
|
|
|
1153
1153
|
data = _.map(data, (result) => {
|
|
1154
|
-
if (!result || result== "undefined") {
|
|
1154
|
+
if (!result || result == "undefined") {
|
|
1155
1155
|
result = {};
|
|
1156
1156
|
}
|
|
1157
1157
|
let result_found =
|
|
@@ -1178,7 +1178,7 @@ export default class SpiceModel {
|
|
|
1178
1178
|
let ids = [];
|
|
1179
1179
|
_.each(data, (result) => {
|
|
1180
1180
|
let value = [];
|
|
1181
|
-
if (!result || result== "undefined") {
|
|
1181
|
+
if (!result || result == "undefined") {
|
|
1182
1182
|
result = {};
|
|
1183
1183
|
}
|
|
1184
1184
|
|
|
@@ -1219,7 +1219,7 @@ export default class SpiceModel {
|
|
|
1219
1219
|
ids: ids,
|
|
1220
1220
|
}); */
|
|
1221
1221
|
_.each(data, (result) => {
|
|
1222
|
-
if (!result || result== "undefined") {
|
|
1222
|
+
if (!result || result == "undefined") {
|
|
1223
1223
|
result = {};
|
|
1224
1224
|
}
|
|
1225
1225
|
if (_.isString(result[store_property])) {
|