roboto-js 1.4.33 → 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,31 +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
- _context16.next = 12;
753
- return this.axios.post('/object_service/queryObjects', [mergedParams]);
754
- case 12:
755
- responsePromise = _context16.sent;
756
- // Store the promise in the cache
757
- this.requestCache[_paramsKey] = responsePromise;
758
- _context16.next = 16;
752
+ //
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;
758
+ _context16.next = 14;
759
759
  return responsePromise;
760
- case 16:
760
+ case 14:
761
761
  response = _context16.sent;
762
- delete this.requestCache[_paramsKey];
763
762
  if (!(response.data.ok === false)) {
764
- _context16.next = 20;
763
+ _context16.next = 17;
765
764
  break;
766
765
  }
767
766
  return _context16.abrupt("return", this._handleError(response));
768
- case 20:
767
+ case 17:
769
768
  // Process items into RbtObject instances
770
769
  if (Array.isArray(response.data.items)) {
771
770
  response.data.items = response.data.items.map(function (record) {
@@ -775,16 +774,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
775
774
  });
776
775
  }
777
776
  return _context16.abrupt("return", response.data.items);
778
- case 24:
779
- _context16.prev = 24;
777
+ case 21:
778
+ _context16.prev = 21;
780
779
  _context16.t0 = _context16["catch"](1);
781
- delete this.requestCache[paramsKey];
782
780
  return _context16.abrupt("return", this._handleError(_context16.t0));
783
- case 28:
781
+ case 24:
784
782
  case "end":
785
783
  return _context16.stop();
786
784
  }
787
- }, _callee16, this, [[1, 24]]);
785
+ }, _callee16, this, [[1, 21]]);
788
786
  }));
789
787
  function query(_x11) {
790
788
  return _query.apply(this, arguments);
@@ -364,12 +364,14 @@ export default class RbtApi {
364
364
  }
365
365
  //
366
366
 
367
- const responsePromise = await 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.33",
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,14 +424,17 @@ export default class RbtApi {
424
424
  }
425
425
  //
426
426
 
427
- const responsePromise = await 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);
437
440
  }
@@ -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
  }