roboto-js 1.4.35 → 1.4.36

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,30 +741,31 @@ 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]) {
746
- _context16.next = 10;
744
+ _paramsKey = JSON.stringify(mergedParams);
745
+ if (!this.requestCache[_paramsKey]) {
746
+ _context16.next = 9;
747
747
  break;
748
748
  }
749
- console.log("Returning cached request for params:", paramsKey);
750
- return _context16.abrupt("return", this.requestCache[paramsKey]);
751
- case 10:
752
- //
749
+ return _context16.abrupt("return", this.requestCache[_paramsKey]);
750
+ case 9:
751
+ // Create the response promise and store it in the cache
753
752
  responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams])["finally"](function () {
754
753
  // Ensure that the cache is cleaned up after the promise settles
755
- delete _this.requestCache[paramsKey];
754
+ delete _this.requestCache[_paramsKey];
756
755
  }); // Store the promise in the cache
757
- this.requestCache[paramsKey] = responsePromise;
758
- _context16.next = 14;
756
+ this.requestCache[_paramsKey] = responsePromise;
757
+
758
+ // Await the response from the API
759
+ _context16.next = 13;
759
760
  return responsePromise;
760
- case 14:
761
+ case 13:
761
762
  response = _context16.sent;
762
763
  if (!(response.data.ok === false)) {
763
- _context16.next = 17;
764
+ _context16.next = 16;
764
765
  break;
765
766
  }
766
767
  return _context16.abrupt("return", this._handleError(response));
767
- case 17:
768
+ case 16:
768
769
  // Process items into RbtObject instances
769
770
  if (Array.isArray(response.data.items)) {
770
771
  response.data.items = response.data.items.map(function (record) {
@@ -774,15 +775,16 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
774
775
  });
775
776
  }
776
777
  return _context16.abrupt("return", response.data.items);
777
- case 21:
778
- _context16.prev = 21;
778
+ case 20:
779
+ _context16.prev = 20;
779
780
  _context16.t0 = _context16["catch"](1);
781
+ delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
780
782
  return _context16.abrupt("return", this._handleError(_context16.t0));
781
783
  case 24:
782
784
  case "end":
783
785
  return _context16.stop();
784
786
  }
785
- }, _callee16, this, [[1, 21]]);
787
+ }, _callee16, this, [[1, 20]]);
786
788
  }));
787
789
  function query(_x11) {
788
790
  return _query.apply(this, arguments);
@@ -359,11 +359,10 @@ export default class RbtApi {
359
359
  // Check cache for an existing request
360
360
  const paramsKey = JSON.stringify(mergedParams);
361
361
  if (this.requestCache[paramsKey]) {
362
- console.log("Returning cached request for params:", paramsKey);
363
362
  return this.requestCache[paramsKey];
364
363
  }
365
- //
366
364
 
365
+ // Create the response promise and store it in the cache
367
366
  const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]).finally(() => {
368
367
  // Ensure that the cache is cleaned up after the promise settles
369
368
  delete this.requestCache[paramsKey];
@@ -371,6 +370,8 @@ export default class RbtApi {
371
370
 
372
371
  // Store the promise in the cache
373
372
  this.requestCache[paramsKey] = responsePromise;
373
+
374
+ // Await the response from the API
374
375
  const response = await responsePromise;
375
376
  if (response.data.ok === false) {
376
377
  return this._handleError(response);
@@ -378,12 +379,15 @@ export default class RbtApi {
378
379
 
379
380
  // Process items into RbtObject instances
380
381
  if (Array.isArray(response.data.items)) {
381
- response.data.items = response.data.items.map(record => new RbtObject(record, this.axios, {
382
- isNew: true
383
- }));
382
+ response.data.items = response.data.items.map(record => {
383
+ return new RbtObject(record, this.axios, {
384
+ isNew: true
385
+ });
386
+ });
384
387
  }
385
388
  return response.data.items;
386
389
  } catch (e) {
390
+ delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
387
391
  return this._handleError(e);
388
392
  }
389
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.35",
3
+ "version": "1.4.36",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -407,6 +407,7 @@ export default class RbtApi {
407
407
  */
408
408
  async query(type, params = {}) {
409
409
  try {
410
+
410
411
  params.type = type;
411
412
 
412
413
  // Default ordering and pagination
@@ -419,11 +420,10 @@ export default class RbtApi {
419
420
  // Check cache for an existing request
420
421
  const paramsKey = JSON.stringify(mergedParams);
421
422
  if (this.requestCache[paramsKey]) {
422
- console.log("Returning cached request for params:", paramsKey);
423
- return this.requestCache[paramsKey];
423
+ return this.requestCache[paramsKey];
424
424
  }
425
- //
426
425
 
426
+ // Create the response promise and store it in the cache
427
427
  const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams])
428
428
  .finally(() => {
429
429
  // Ensure that the cache is cleaned up after the promise settles
@@ -433,6 +433,7 @@ export default class RbtApi {
433
433
  // Store the promise in the cache
434
434
  this.requestCache[paramsKey] = responsePromise;
435
435
 
436
+ // Await the response from the API
436
437
  const response = await responsePromise;
437
438
 
438
439
  if (response.data.ok === false) {
@@ -441,11 +442,18 @@ export default class RbtApi {
441
442
 
442
443
  // Process items into RbtObject instances
443
444
  if (Array.isArray(response.data.items)) {
444
- response.data.items = response.data.items.map(record => new RbtObject(record, this.axios, { isNew: true }));
445
+ response.data.items = response.data.items.map(record => {
446
+ return new RbtObject(record, this.axios, { isNew: true });
447
+ });
445
448
  }
449
+
446
450
  return response.data.items;
451
+
447
452
  } catch (e) {
453
+
454
+ delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
448
455
  return this._handleError(e);
456
+
449
457
  }
450
458
  }
451
459