roboto-js 1.4.37 → 1.4.38

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.
@@ -717,6 +717,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
717
717
  defaultLimit,
718
718
  mergedParams,
719
719
  currentTime,
720
+ _paramsKey,
720
721
  cacheEntry,
721
722
  responsePromise,
722
723
  response,
@@ -743,33 +744,34 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
743
744
  }; // Merge defaults with provided params
744
745
  mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params); // Check cache for an existing request
745
746
  currentTime = Date.now();
746
- cacheEntry = this.requestCache[paramsKey];
747
+ _paramsKey = JSON.stringify(mergedParams);
748
+ cacheEntry = this.requestCache[_paramsKey];
747
749
  if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
748
- _context16.next = 11;
750
+ _context16.next = 12;
749
751
  break;
750
752
  }
751
753
  // 10000 ms = 10 seconds
752
- console.log("Using cached request for params:", paramsKey);
754
+ console.log("Using cached request for params:", _paramsKey);
753
755
  return _context16.abrupt("return", cacheEntry.val);
754
- case 11:
756
+ case 12:
755
757
  // Create the response promise and store it in the cache
756
758
  responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Store the promise along with the current time in the cache
757
- this.requestCache[paramsKey] = {
759
+ this.requestCache[_paramsKey] = {
758
760
  val: responsePromise,
759
761
  time: currentTime
760
762
  };
761
763
 
762
764
  // Await the response from the API
763
- _context16.next = 15;
765
+ _context16.next = 16;
764
766
  return responsePromise;
765
- case 15:
767
+ case 16:
766
768
  response = _context16.sent;
767
769
  if (!(response.data.ok === false)) {
768
- _context16.next = 18;
770
+ _context16.next = 19;
769
771
  break;
770
772
  }
771
773
  return _context16.abrupt("return", this._handleError(response));
772
- case 18:
774
+ case 19:
773
775
  // Process items into RbtObject instances
774
776
  if (Array.isArray(response.data.items)) {
775
777
  response.data.items = response.data.items.map(function (record) {
@@ -779,16 +781,16 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
779
781
  });
780
782
  }
781
783
  return _context16.abrupt("return", response.data.items);
782
- case 22:
783
- _context16.prev = 22;
784
+ case 23:
785
+ _context16.prev = 23;
784
786
  _context16.t0 = _context16["catch"](1);
785
787
  delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
786
788
  return _context16.abrupt("return", this._handleError(_context16.t0));
787
- case 26:
789
+ case 27:
788
790
  case "end":
789
791
  return _context16.stop();
790
792
  }
791
- }, _callee16, this, [[1, 22]]);
793
+ }, _callee16, this, [[1, 23]]);
792
794
  }));
793
795
  function query(_x11) {
794
796
  return _query.apply(this, arguments);
@@ -358,6 +358,7 @@ export default class RbtApi {
358
358
 
359
359
  // Check cache for an existing request
360
360
  const currentTime = Date.now();
361
+ const paramsKey = JSON.stringify(mergedParams);
361
362
  const cacheEntry = this.requestCache[paramsKey];
362
363
  if (cacheEntry && currentTime - cacheEntry.time < 10000) {
363
364
  // 10000 ms = 10 seconds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.37",
3
+ "version": "1.4.38",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -420,6 +420,7 @@ export default class RbtApi {
420
420
 
421
421
  // Check cache for an existing request
422
422
  const currentTime = Date.now();
423
+ const paramsKey = JSON.stringify(mergedParams);
423
424
  const cacheEntry = this.requestCache[paramsKey];
424
425
  if (cacheEntry && (currentTime - cacheEntry.time) < 10000) { // 10000 ms = 10 seconds
425
426
  console.log("Using cached request for params:", paramsKey);