spice-js 2.6.20 → 2.6.22

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.
@@ -526,14 +526,14 @@ class SpiceModel {
526
526
  yield _this4.run_hook(args, "get", "before");
527
527
  }
528
528
 
529
- var key = _this4.type + "::" + args.id;
529
+ var key = "get::" + _this4.type + "::" + args.id;
530
530
  var results = {};
531
531
 
532
532
  if (_this4.shouldUseCache(_this4.type)) {
533
533
  var cached_results = yield _this4.getCacheProviderObject(_this4.type).get(key);
534
534
  results = cached_results == null ? void 0 : cached_results.value;
535
535
 
536
- if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this4.shouldForceRefresh(cached_results))) {
536
+ if ((cached_results == null ? void 0 : cached_results.value) == undefined || (yield _this4.shouldForceRefresh(cached_results)) || _this4.type == "workflow") {
537
537
  results = yield _this4.database.get(args.id);
538
538
  yield _this4.getCacheProviderObject(_this4.type).set(key, {
539
539
  value: results,
@@ -601,7 +601,7 @@ class SpiceModel {
601
601
 
602
602
  _.remove(args.ids, o => o == undefined);
603
603
 
604
- var key = _this6.type + "::" + _.join(args.ids, "|");
604
+ var key = "multi-get::" + _this6.type + "::" + _.join(args.ids, "|");
605
605
 
606
606
  var results = [];
607
607
 
@@ -946,6 +946,15 @@ class SpiceModel {
946
946
  }
947
947
  }
948
948
 
949
+ function formatSortComponent(sortComponent) {
950
+ // Split the string by spaces to get individual parts
951
+ var parts = sortComponent.split(" "); // Assuming the first part is the column name, add backticks around it
952
+
953
+ parts[0] = "`" + parts[0] + "`"; // Rejoin the parts back into a string and return
954
+
955
+ return parts.join(" ");
956
+ }
957
+
949
958
  if ((0, _Security.hasSQLInjection)(query)) {
950
959
  return [];
951
960
  }
@@ -967,7 +976,7 @@ class SpiceModel {
967
976
 
968
977
  for (var i = 0; i < sort_array.length; i++) {
969
978
  if (!sort_array[i].includes(".")) {
970
- new_sort_array.push("`" + _this11.type + "`.`" + sort_array[i] + "`");
979
+ new_sort_array.push("`" + _this11.type + "`." + formatSortComponent(sort_array[i]));
971
980
  } else {
972
981
  new_sort_array.push(sort_array[i]);
973
982
  }
@@ -984,7 +993,7 @@ class SpiceModel {
984
993
  return str.replace(/[^a-zA-Z0-9]/g, "");
985
994
  }
986
995
 
987
- var key = removeSpaceAndSpecialCharacters(_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);
996
+ 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);
988
997
  var results;
989
998
 
990
999
  if (args.is_custom_query && args.is_custom_query === "true") {
@@ -1049,6 +1058,8 @@ class SpiceModel {
1049
1058
  results.data = yield _this11.do_serialize(results.data, "read", {}, args, (yield _this11.propsToBeRemoved(results.data)));
1050
1059
  }
1051
1060
 
1061
+ if (_this11.type == "resourcedetail") ;
1062
+
1052
1063
  if (args.skip_hooks != true) {
1053
1064
  yield _this11.run_hook(results.data, "list", "after");
1054
1065
  }
@@ -1150,6 +1161,7 @@ class SpiceModel {
1150
1161
  return new obj(_extends({}, _this13[_args], {
1151
1162
  skip_cache: _this13[_skip_cache]
1152
1163
  })).getMulti({
1164
+ skip_hooks: true,
1153
1165
  ids: ids
1154
1166
  });
1155
1167
  }));
@@ -1202,6 +1214,7 @@ class SpiceModel {
1202
1214
  return new obj(_extends({}, _this14[_args], {
1203
1215
  skip_cache: _this14[_skip_cache]
1204
1216
  })).getMulti({
1217
+ skip_hooks: true,
1205
1218
  ids: ids
1206
1219
  });
1207
1220
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.6.20",
3
+ "version": "2.6.22",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -436,17 +436,18 @@ export default class SpiceModel {
436
436
  if (args.skip_hooks != true) {
437
437
  await this.run_hook(args, "get", "before");
438
438
  }
439
- let key = `${this.type}::${args.id}`;
439
+ let key = `get::${this.type}::${args.id}`;
440
440
  let results = {};
441
441
  if (this.shouldUseCache(this.type)) {
442
442
  let cached_results = await this.getCacheProviderObject(this.type).get(
443
443
  key
444
444
  );
445
- results = cached_results?.value;
446
445
 
446
+ results = cached_results?.value;
447
447
  if (
448
448
  cached_results?.value == undefined ||
449
- (await this.shouldForceRefresh(cached_results))
449
+ (await this.shouldForceRefresh(cached_results)) ||
450
+ this.type == "workflow"
450
451
  ) {
451
452
  results = await this.database.get(args.id);
452
453
  await this.getCacheProviderObject(this.type).set(
@@ -511,7 +512,7 @@ export default class SpiceModel {
511
512
  await this.run_hook(this, "list", "before");
512
513
  }
513
514
  _.remove(args.ids, (o) => o == undefined);
514
- let key = `${this.type}::${_.join(args.ids, "|")}`;
515
+ let key = `multi-get::${this.type}::${_.join(args.ids, "|")}`;
515
516
  let results = [];
516
517
  if (args.ids.length > 0) {
517
518
  if (this.shouldUseCache(this.type)) {
@@ -890,7 +891,7 @@ export default class SpiceModel {
890
891
  return str.replace(/[^a-zA-Z0-9]/g, "");
891
892
  }
892
893
  let key = removeSpaceAndSpecialCharacters(
893
- `${this.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}`
894
+ `list::${this.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}`
894
895
  );
895
896
 
896
897
  let results;