roboto-js 1.4.34 → 1.4.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.
@@ -716,7 +716,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
716
716
  defaultOrderBy,
717
717
  defaultLimit,
718
718
  mergedParams,
719
- _paramsKey,
719
+ paramsKey,
720
720
  responsePromise,
721
721
  response,
722
722
  _args16 = arguments;
@@ -741,28 +741,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
741
741
  }
742
742
  }; // Merge defaults with provided params
743
743
  mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params); // Check cache for an existing request
744
- _paramsKey = JSON.stringify(mergedParams);
745
- if (!this.requestCache[_paramsKey]) {
744
+ paramsKey = JSON.stringify(mergedParams);
745
+ if (!this.requestCache[paramsKey]) {
746
746
  _context16.next = 10;
747
747
  break;
748
748
  }
749
- console.log("Returning cached request for params:", _paramsKey);
750
- return _context16.abrupt("return", this.requestCache[_paramsKey]);
749
+ console.log("Returning cached request for params:", paramsKey);
750
+ return _context16.abrupt("return", this.requestCache[paramsKey]);
751
751
  case 10:
752
752
  //
753
- responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Store the promise in the cache
754
- this.requestCache[_paramsKey] = responsePromise;
753
+ responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams])["finally"](function () {
754
+ // Ensure that the cache is cleaned up after the promise settles
755
+ delete _this.requestCache[paramsKey];
756
+ }); // Store the promise in the cache
757
+ this.requestCache[paramsKey] = responsePromise;
755
758
  _context16.next = 14;
756
759
  return responsePromise;
757
760
  case 14:
758
761
  response = _context16.sent;
759
- delete this.requestCache[_paramsKey];
760
762
  if (!(response.data.ok === false)) {
761
- _context16.next = 18;
763
+ _context16.next = 17;
762
764
  break;
763
765
  }
764
766
  return _context16.abrupt("return", this._handleError(response));
765
- case 18:
767
+ case 17:
766
768
  // Process items into RbtObject instances
767
769
  if (Array.isArray(response.data.items)) {
768
770
  response.data.items = response.data.items.map(function (record) {
@@ -772,16 +774,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
772
774
  });
773
775
  }
774
776
  return _context16.abrupt("return", response.data.items);
775
- case 22:
776
- _context16.prev = 22;
777
+ case 21:
778
+ _context16.prev = 21;
777
779
  _context16.t0 = _context16["catch"](1);
778
- delete this.requestCache[paramsKey];
779
780
  return _context16.abrupt("return", this._handleError(_context16.t0));
780
- case 26:
781
+ case 24:
781
782
  case "end":
782
783
  return _context16.stop();
783
784
  }
784
- }, _callee16, this, [[1, 22]]);
785
+ }, _callee16, this, [[1, 21]]);
785
786
  }));
786
787
  function query(_x11) {
787
788
  return _query.apply(this, arguments);
@@ -364,12 +364,14 @@ export default class RbtApi {
364
364
  }
365
365
  //
366
366
 
367
- const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]);
367
+ const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]).finally(() => {
368
+ // Ensure that the cache is cleaned up after the promise settles
369
+ delete this.requestCache[paramsKey];
370
+ });
368
371
 
369
372
  // Store the promise in the cache
370
373
  this.requestCache[paramsKey] = responsePromise;
371
374
  const response = await responsePromise;
372
- delete this.requestCache[paramsKey];
373
375
  if (response.data.ok === false) {
374
376
  return this._handleError(response);
375
377
  }
@@ -382,7 +384,6 @@ export default class RbtApi {
382
384
  }
383
385
  return response.data.items;
384
386
  } catch (e) {
385
- delete this.requestCache[paramsKey];
386
387
  return this._handleError(e);
387
388
  }
388
389
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.34",
3
+ "version": "1.4.35",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -424,13 +424,16 @@ export default class RbtApi {
424
424
  }
425
425
  //
426
426
 
427
- const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]);
427
+ const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams])
428
+ .finally(() => {
429
+ // Ensure that the cache is cleaned up after the promise settles
430
+ delete this.requestCache[paramsKey];
431
+ });
428
432
 
429
433
  // Store the promise in the cache
430
434
  this.requestCache[paramsKey] = responsePromise;
431
435
 
432
436
  const response = await responsePromise;
433
- delete this.requestCache[paramsKey];
434
437
 
435
438
  if (response.data.ok === false) {
436
439
  return this._handleError(response);
@@ -442,7 +445,6 @@ export default class RbtApi {
442
445
  }
443
446
  return response.data.items;
444
447
  } catch (e) {
445
- delete this.requestCache[paramsKey];
446
448
  return this._handleError(e);
447
449
  }
448
450
  }