roboto-js 1.6.1 → 1.6.3

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.
@@ -89,7 +89,8 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
89
89
  }, {
90
90
  key: "getSiteEnv",
91
91
  value: function getSiteEnv() {
92
- return this.api.getSiteEnv();
92
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
93
+ return this.api.getSiteEnv(key);
93
94
  }
94
95
  }, {
95
96
  key: "setAppServiceHost",
@@ -173,6 +173,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
173
173
  }, {
174
174
  key: "getSiteEnv",
175
175
  value: function getSiteEnv() {
176
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
177
+ if (key) {
178
+ return this.siteEnv[key];
179
+ }
176
180
  return this.siteEnv;
177
181
  }
178
182
  }, {
@@ -893,11 +897,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
893
897
  var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(type) {
894
898
  var _this2 = this;
895
899
  var params,
900
+ paramsKey,
896
901
  defaultOrderBy,
897
902
  defaultLimit,
898
903
  mergedParams,
899
904
  currentTime,
900
- _paramsKey,
901
905
  cacheEntry,
902
906
  responsePromise,
903
907
  processingPromise,
@@ -925,8 +929,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
925
929
  }; // Merge defaults with provided params
926
930
  mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params); // Check cache for an existing request
927
931
  currentTime = Date.now();
928
- _paramsKey = JSON.stringify(mergedParams);
929
- cacheEntry = this.requestCache[_paramsKey];
932
+ paramsKey = JSON.stringify(mergedParams);
933
+ cacheEntry = this.requestCache[paramsKey];
930
934
  if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
931
935
  _context18.next = 11;
932
936
  break;
@@ -938,11 +942,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
938
942
  processingPromise = responsePromise.then(function (response) {
939
943
  return _this2._processResponseData(response);
940
944
  })["catch"](function (e) {
941
- delete _this2.requestCache[_paramsKey]; // Ensure cache cleanup on failure
945
+ delete _this2.requestCache[paramsKey]; // Ensure cache cleanup on failure
942
946
  //console.log('RBTAPI.query ERROR (Processing)', paramsKey, e);
943
947
  return _this2._handleError(e);
944
948
  }); // Store the promise of the processed data in the cache
945
- this.requestCache[_paramsKey] = {
949
+ this.requestCache[paramsKey] = {
946
950
  val: processingPromise,
947
951
  time: currentTime
948
952
  };
package/dist/esm/index.js CHANGED
@@ -53,8 +53,8 @@ export default class Roboto {
53
53
  setSiteEnv(siteEnv) {
54
54
  this.api.setSiteEnv(siteEnv);
55
55
  }
56
- getSiteEnv() {
57
- return this.api.getSiteEnv();
56
+ getSiteEnv(key = null) {
57
+ return this.api.getSiteEnv(key);
58
58
  }
59
59
  setAppServiceHost(host) {
60
60
  // DEVELOPMENT
@@ -75,7 +75,10 @@ export default class RbtApi {
75
75
  setSiteEnv(siteEnv) {
76
76
  this.siteEnv = siteEnv;
77
77
  }
78
- getSiteEnv() {
78
+ getSiteEnv(key = null) {
79
+ if (key) {
80
+ return this.siteEnv[key];
81
+ }
79
82
  return this.siteEnv;
80
83
  }
81
84
  async registerTypedefs(typedefs) {
@@ -470,6 +473,7 @@ export default class RbtApi {
470
473
  // }
471
474
 
472
475
  async query(type, params = {}) {
476
+ let paramsKey;
473
477
  try {
474
478
  //console.log('RBTAPI.query INIT', type, params);
475
479
  params.type = type;
@@ -497,7 +501,7 @@ export default class RbtApi {
497
501
 
498
502
  // Check cache for an existing request
499
503
  const currentTime = Date.now();
500
- const paramsKey = JSON.stringify(mergedParams);
504
+ paramsKey = JSON.stringify(mergedParams);
501
505
  const cacheEntry = this.requestCache[paramsKey];
502
506
  if (cacheEntry && currentTime - cacheEntry.time < 10000) {
503
507
  // 10000 ms = 10 seconds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -64,8 +64,8 @@ export default class Roboto{
64
64
  }
65
65
 
66
66
 
67
- getSiteEnv(){
68
- return this.api.getSiteEnv();
67
+ getSiteEnv(key=null){
68
+ return this.api.getSiteEnv(key);
69
69
  }
70
70
 
71
71
  setAppServiceHost(host){
package/src/rbt_api.js CHANGED
@@ -90,7 +90,11 @@ export default class RbtApi {
90
90
 
91
91
  }
92
92
 
93
- getSiteEnv(){
93
+ getSiteEnv(key=null){
94
+
95
+ if(key){
96
+ return this.siteEnv[key];
97
+ }
94
98
 
95
99
  return this.siteEnv;
96
100
 
@@ -566,6 +570,8 @@ export default class RbtApi {
566
570
 
567
571
 
568
572
  async query(type, params = {}) {
573
+
574
+ let paramsKey;
569
575
  try {
570
576
  //console.log('RBTAPI.query INIT', type, params);
571
577
  params.type = type;
@@ -579,7 +585,7 @@ export default class RbtApi {
579
585
 
580
586
  // Check cache for an existing request
581
587
  const currentTime = Date.now();
582
- const paramsKey = JSON.stringify(mergedParams);
588
+ paramsKey = JSON.stringify(mergedParams);
583
589
  const cacheEntry = this.requestCache[paramsKey];
584
590
  if (cacheEntry && (currentTime - cacheEntry.time) < 10000) { // 10000 ms = 10 seconds
585
591
  //console.log('RBTAPI.query CACHED', type, paramsKey);