roboto-js 1.4.32 → 1.4.34
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.
- package/dist/cjs/rbt_api.cjs +26 -10
- package/dist/esm/rbt_api.js +17 -1
- package/package.json +1 -1
- package/src/rbt_api.js +18 -1
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -62,6 +62,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
62
62
|
this.localDb = null;
|
|
63
63
|
this.iac_session = null;
|
|
64
64
|
this.appServiceHost = null;
|
|
65
|
+
this.requestCache = {};
|
|
65
66
|
|
|
66
67
|
// Use the storageAdaptor to get the authToken, if available
|
|
67
68
|
this.initAuthToken(authtoken);
|
|
@@ -715,6 +716,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
715
716
|
defaultOrderBy,
|
|
716
717
|
defaultLimit,
|
|
717
718
|
mergedParams,
|
|
719
|
+
_paramsKey,
|
|
720
|
+
responsePromise,
|
|
718
721
|
response,
|
|
719
722
|
_args16 = arguments;
|
|
720
723
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
@@ -737,17 +740,29 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
737
740
|
results: 50
|
|
738
741
|
}
|
|
739
742
|
}; // Merge defaults with provided params
|
|
740
|
-
mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params);
|
|
741
|
-
|
|
742
|
-
|
|
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;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
console.log("Returning cached request for params:", _paramsKey);
|
|
750
|
+
return _context16.abrupt("return", this.requestCache[_paramsKey]);
|
|
751
|
+
case 10:
|
|
752
|
+
//
|
|
753
|
+
responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Store the promise in the cache
|
|
754
|
+
this.requestCache[_paramsKey] = responsePromise;
|
|
755
|
+
_context16.next = 14;
|
|
756
|
+
return responsePromise;
|
|
757
|
+
case 14:
|
|
744
758
|
response = _context16.sent;
|
|
759
|
+
delete this.requestCache[_paramsKey];
|
|
745
760
|
if (!(response.data.ok === false)) {
|
|
746
|
-
_context16.next =
|
|
761
|
+
_context16.next = 18;
|
|
747
762
|
break;
|
|
748
763
|
}
|
|
749
764
|
return _context16.abrupt("return", this._handleError(response));
|
|
750
|
-
case
|
|
765
|
+
case 18:
|
|
751
766
|
// Process items into RbtObject instances
|
|
752
767
|
if (Array.isArray(response.data.items)) {
|
|
753
768
|
response.data.items = response.data.items.map(function (record) {
|
|
@@ -757,15 +772,16 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
757
772
|
});
|
|
758
773
|
}
|
|
759
774
|
return _context16.abrupt("return", response.data.items);
|
|
760
|
-
case
|
|
761
|
-
_context16.prev =
|
|
775
|
+
case 22:
|
|
776
|
+
_context16.prev = 22;
|
|
762
777
|
_context16.t0 = _context16["catch"](1);
|
|
778
|
+
delete this.requestCache[paramsKey];
|
|
763
779
|
return _context16.abrupt("return", this._handleError(_context16.t0));
|
|
764
|
-
case
|
|
780
|
+
case 26:
|
|
765
781
|
case "end":
|
|
766
782
|
return _context16.stop();
|
|
767
783
|
}
|
|
768
|
-
}, _callee16, this, [[1,
|
|
784
|
+
}, _callee16, this, [[1, 22]]);
|
|
769
785
|
}));
|
|
770
786
|
function query(_x11) {
|
|
771
787
|
return _query.apply(this, arguments);
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -34,6 +34,7 @@ export default class RbtApi {
|
|
|
34
34
|
this.localDb = null;
|
|
35
35
|
this.iac_session = null;
|
|
36
36
|
this.appServiceHost = null;
|
|
37
|
+
this.requestCache = {};
|
|
37
38
|
|
|
38
39
|
// Use the storageAdaptor to get the authToken, if available
|
|
39
40
|
this.initAuthToken(authtoken);
|
|
@@ -354,7 +355,21 @@ export default class RbtApi {
|
|
|
354
355
|
...defaultLimit,
|
|
355
356
|
...params
|
|
356
357
|
};
|
|
357
|
-
|
|
358
|
+
|
|
359
|
+
// Check cache for an existing request
|
|
360
|
+
const paramsKey = JSON.stringify(mergedParams);
|
|
361
|
+
if (this.requestCache[paramsKey]) {
|
|
362
|
+
console.log("Returning cached request for params:", paramsKey);
|
|
363
|
+
return this.requestCache[paramsKey];
|
|
364
|
+
}
|
|
365
|
+
//
|
|
366
|
+
|
|
367
|
+
const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
368
|
+
|
|
369
|
+
// Store the promise in the cache
|
|
370
|
+
this.requestCache[paramsKey] = responsePromise;
|
|
371
|
+
const response = await responsePromise;
|
|
372
|
+
delete this.requestCache[paramsKey];
|
|
358
373
|
if (response.data.ok === false) {
|
|
359
374
|
return this._handleError(response);
|
|
360
375
|
}
|
|
@@ -367,6 +382,7 @@ export default class RbtApi {
|
|
|
367
382
|
}
|
|
368
383
|
return response.data.items;
|
|
369
384
|
} catch (e) {
|
|
385
|
+
delete this.requestCache[paramsKey];
|
|
370
386
|
return this._handleError(e);
|
|
371
387
|
}
|
|
372
388
|
}
|
package/package.json
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -33,6 +33,7 @@ export default class RbtApi {
|
|
|
33
33
|
this.localDb = null;
|
|
34
34
|
this.iac_session = null;
|
|
35
35
|
this.appServiceHost = null;
|
|
36
|
+
this.requestCache = {};
|
|
36
37
|
|
|
37
38
|
// Use the storageAdaptor to get the authToken, if available
|
|
38
39
|
this.initAuthToken(authtoken);
|
|
@@ -415,7 +416,22 @@ export default class RbtApi {
|
|
|
415
416
|
// Merge defaults with provided params
|
|
416
417
|
const mergedParams = { ...defaultOrderBy, ...defaultLimit, ...params };
|
|
417
418
|
|
|
418
|
-
|
|
419
|
+
// Check cache for an existing request
|
|
420
|
+
const paramsKey = JSON.stringify(mergedParams);
|
|
421
|
+
if (this.requestCache[paramsKey]) {
|
|
422
|
+
console.log("Returning cached request for params:", paramsKey);
|
|
423
|
+
return this.requestCache[paramsKey];
|
|
424
|
+
}
|
|
425
|
+
//
|
|
426
|
+
|
|
427
|
+
const responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
428
|
+
|
|
429
|
+
// Store the promise in the cache
|
|
430
|
+
this.requestCache[paramsKey] = responsePromise;
|
|
431
|
+
|
|
432
|
+
const response = await responsePromise;
|
|
433
|
+
delete this.requestCache[paramsKey];
|
|
434
|
+
|
|
419
435
|
if (response.data.ok === false) {
|
|
420
436
|
return this._handleError(response);
|
|
421
437
|
}
|
|
@@ -426,6 +442,7 @@ export default class RbtApi {
|
|
|
426
442
|
}
|
|
427
443
|
return response.data.items;
|
|
428
444
|
} catch (e) {
|
|
445
|
+
delete this.requestCache[paramsKey];
|
|
429
446
|
return this._handleError(e);
|
|
430
447
|
}
|
|
431
448
|
}
|