@equinor/echo-framework 0.9.0 → 0.9.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.
Files changed (47) hide show
  1. package/dist/_virtual/index.js +9 -0
  2. package/dist/components/containers/layouts.d.ts +3 -5
  3. package/dist/components/panel/corePanelLeft.d.ts +4 -1
  4. package/dist/components/panel/corePanelRight.d.ts +4 -1
  5. package/dist/components/router/echoRoute.d.ts +2 -2
  6. package/dist/components/router/index.d.ts +0 -1
  7. package/dist/coreApplication/EchoBarComponent.d.ts +12 -0
  8. package/dist/coreApplication/EchoContent.d.ts +1 -0
  9. package/dist/coreApplication/index.d.ts +1 -0
  10. package/dist/hooks/hookLibrary.d.ts +13 -2
  11. package/dist/hooks/index.d.ts +1 -0
  12. package/dist/hooks/useScreenOrientation.d.ts +2 -0
  13. package/dist/index.d.ts +6 -1
  14. package/dist/node_modules/@microsoft/signalr/dist/esm/Utils.js +1 -1
  15. package/dist/node_modules/classnames/index.js +67 -0
  16. package/dist/services/api/api-manager.d.ts +10 -1
  17. package/dist/src/components/containers/layout.module.css.js +6 -2
  18. package/dist/src/components/containers/layouts.js +72 -36
  19. package/dist/src/components/footer/footer.module.css.js +1 -1
  20. package/dist/src/components/panel/corePanelLeft.js +5 -2
  21. package/dist/src/components/panel/corePanelLeft.module.css.js +1 -1
  22. package/dist/src/components/panel/corePanelRight.js +5 -2
  23. package/dist/src/components/panel/corePanelRight.module.css.js +1 -1
  24. package/dist/src/components/router/echoRoute.js +9 -3
  25. package/dist/src/components/router/routes.js +2 -4
  26. package/dist/src/coreApplication/EchoBarComponent.js +201 -0
  27. package/dist/src/coreApplication/EchoContent.js +7 -2
  28. package/dist/src/coreApplication/EchoContent.module.css.js +17 -0
  29. package/dist/src/globalStyles.css.js +1 -1
  30. package/dist/src/hooks/hookLibrary.js +17 -0
  31. package/dist/src/hooks/index.js +3 -0
  32. package/dist/src/hooks/useScreenOrientation.js +58 -0
  33. package/dist/src/index.js +13 -8
  34. package/dist/src/index2.js +37 -26
  35. package/dist/src/services/api/api-manager.js +107 -47
  36. package/dist/src/services/api/api-plantinfo.js +125 -8
  37. package/dist/src/services/api/api-plants.js +34 -3
  38. package/dist/src/services/api/api-realtimedata.js +9 -2
  39. package/dist/src/services/api/api-tags.js +61 -2
  40. package/dist/src/services/api/api-version.js +68 -6
  41. package/dist/src/utils/taskCache.js +89 -0
  42. package/dist/types/hookLibrary.d.ts +4 -0
  43. package/dist/utils/taskCache.d.ts +23 -0
  44. package/dist/utils/taskCache.test.d.ts +1 -0
  45. package/package.json +25 -25
  46. package/dist/components/router/useLayout.d.ts +0 -3
  47. package/dist/src/components/router/useLayout.js +0 -32
@@ -14,6 +14,8 @@ var echoBase = require('@equinor/echo-base');
14
14
 
15
15
  var EchoCore = require('@equinor/echo-core');
16
16
 
17
+ var taskCache = require('../../utils/taskCache.js');
18
+
17
19
  function _interopDefaultLegacy(e) {
18
20
  return e && _typeof(e) === 'object' && 'default' in e ? e : {
19
21
  'default': e
@@ -23,106 +25,164 @@ function _interopDefaultLegacy(e) {
23
25
  var EchoCore__default = /*#__PURE__*/_interopDefaultLegacy(EchoCore);
24
26
 
25
27
  var baseApiUrl = EchoCore.EchoEnv.env().REACT_APP_API_URL;
28
+ var oneHourInMs = 1000 * 60 * 60;
29
+ var Cache = new taskCache.TaskCache({
30
+ maxItems: 20,
31
+ defaultTimeToLiveMilliseconds: oneHourInMs * 4
32
+ });
26
33
 
27
- function request(url, requestType, abortSignal) {
34
+ function request(_ref) {
35
+ var cache = _ref.cache,
36
+ url = _ref.url,
37
+ abortSignal = _ref.abortSignal;
28
38
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
29
- var response, contentType, text;
39
+ var currentRequest;
30
40
  return _regeneratorRuntime().wrap(function _callee$(_context) {
31
41
  while (1) {
32
42
  switch (_context.prev = _context.next) {
33
43
  case 0:
34
- _context.next = 2;
44
+ currentRequest = Cache.get(url);
45
+
46
+ if (currentRequest) {
47
+ _context.next = 13;
48
+ break;
49
+ }
50
+
51
+ _context.prev = 2;
52
+ currentRequest = {
53
+ task: runRequest(url, abortSignal),
54
+ key: url,
55
+ timeToLiveMilliseconds: cache.timeToLiveMilliseconds
56
+ };
57
+
58
+ if (cache.isEnabled) {
59
+ Cache.add(currentRequest);
60
+ }
61
+
62
+ _context.next = 7;
63
+ return currentRequest.task;
64
+
65
+ case 7:
66
+ _context.next = 13;
67
+ break;
68
+
69
+ case 9:
70
+ _context.prev = 9;
71
+ _context.t0 = _context["catch"](2);
72
+
73
+ if (cache.isEnabled && currentRequest) {
74
+ currentRequest.timeToLiveMilliseconds = 1000 * 10; //we should be able to retry after 10 seconds if error
75
+
76
+ Cache.add(currentRequest);
77
+ }
78
+
79
+ throw _context.t0;
80
+
81
+ case 13:
82
+ _context.next = 15;
83
+ return currentRequest.task;
84
+
85
+ case 15:
86
+ return _context.abrupt("return", _context.sent);
87
+
88
+ case 16:
89
+ case "end":
90
+ return _context.stop();
91
+ }
92
+ }
93
+ }, _callee, null, [[2, 9]]);
94
+ }));
95
+ }
96
+
97
+ function runRequest(url, abortSignal) {
98
+ return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
99
+ var response, contentType, text;
100
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
101
+ while (1) {
102
+ switch (_context2.prev = _context2.next) {
103
+ case 0:
104
+ _context2.next = 2;
35
105
  return EchoCore__default["default"].EchoClient.fetch(url, undefined, undefined, undefined, abortSignal);
36
106
 
37
107
  case 2:
38
- response = _context.sent;
108
+ response = _context2.sent;
39
109
  contentType = response.headers.get('content-type');
40
110
 
41
111
  if (!((response.status === 200 || response.status === 202) && contentType && contentType.indexOf('application/json') !== -1)) {
42
- _context.next = 18;
112
+ _context2.next = 16;
43
113
  break;
44
114
  }
45
115
 
46
- _context.prev = 5;
47
- _context.t0 = JSON;
48
- _context.next = 9;
116
+ _context2.prev = 5;
117
+ _context2.t0 = JSON;
118
+ _context2.next = 9;
49
119
  return response.text();
50
120
 
51
121
  case 9:
52
- _context.t1 = _context.sent;
53
- requestType = _context.t0.parse.call(_context.t0, _context.t1);
54
- _context.next = 16;
55
- break;
122
+ _context2.t1 = _context2.sent;
123
+ return _context2.abrupt("return", _context2.t0.parse.call(_context2.t0, _context2.t1));
56
124
 
57
125
  case 13:
58
- _context.prev = 13;
59
- _context.t2 = _context["catch"](5);
126
+ _context2.prev = 13;
127
+ _context2.t2 = _context2["catch"](5);
60
128
  throw new echoBase.BaseError({
61
129
  name: '[framework.api-manager.request]',
62
130
  message: 'Could not parse JSON',
63
131
  innerError: {
64
- parseError: _context.t2,
132
+ parseError: _context2.t2,
65
133
  url: url
66
134
  }
67
135
  });
68
136
 
69
137
  case 16:
70
- _context.next = 39;
71
- break;
72
-
73
- case 18:
74
138
  if (!((response.status === 200 || response.status === 202) && contentType && contentType.indexOf('text/plain') !== -1)) {
75
- _context.next = 25;
139
+ _context2.next = 21;
76
140
  break;
77
141
  }
78
142
 
79
- _context.next = 21;
143
+ _context2.next = 19;
80
144
  return response.text();
81
145
 
82
- case 21:
83
- text = _context.sent;
84
- requestType = text;
85
- _context.next = 39;
86
- break;
146
+ case 19:
147
+ text = _context2.sent;
148
+ return _context2.abrupt("return", text);
87
149
 
88
- case 25:
150
+ case 21:
89
151
  if (!((response.status === 200 || response.status === 202) && contentType && contentType.indexOf('image/') >= 0 || contentType && contentType.indexOf('video/') >= 0)) {
90
- _context.next = 39;
152
+ _context2.next = 35;
91
153
  break;
92
154
  }
93
155
 
94
- _context.prev = 26;
95
- _context.next = 29;
156
+ _context2.prev = 22;
157
+ _context2.next = 25;
96
158
  return response.arrayBuffer();
97
159
 
98
- case 29:
99
- requestType = _context.sent;
100
- _context.next = 39;
101
- break;
160
+ case 25:
161
+ return _context2.abrupt("return", _context2.sent);
102
162
 
103
- case 32:
104
- _context.prev = 32;
105
- _context.t3 = _context["catch"](26);
163
+ case 28:
164
+ _context2.prev = 28;
165
+ _context2.t3 = _context2["catch"](22);
106
166
 
107
- if (!(typeof _context.t3 === 'string')) {
108
- _context.next = 38;
167
+ if (!(typeof _context2.t3 === 'string')) {
168
+ _context2.next = 34;
109
169
  break;
110
170
  }
111
171
 
112
- throw new Error(_context.t3);
172
+ throw new Error(_context2.t3);
113
173
 
114
- case 38:
115
- throw new Error("Unknown error while processing request. The exception in string format: ".concat(JSON.stringify(_context.t3)));
174
+ case 34:
175
+ throw new Error("Unknown error while processing request. The exception in string format: ".concat(JSON.stringify(_context2.t3)));
116
176
 
117
- case 39:
118
- return _context.abrupt("return", requestType);
177
+ case 35:
178
+ return _context2.abrupt("return", undefined);
119
179
 
120
- case 40:
180
+ case 36:
121
181
  case "end":
122
- return _context.stop();
182
+ return _context2.stop();
123
183
  }
124
184
  }
125
- }, _callee, null, [[5, 13], [26, 32]]);
185
+ }, _callee2, null, [[5, 13], [22, 28]]);
126
186
  }));
127
187
  }
128
188
 
@@ -12,7 +12,11 @@ var _tslib = require('../../../_virtual/_tslib.js');
12
12
 
13
13
  var apiManager = require('./api-manager.js');
14
14
 
15
+ var tenMinutesInMs = 1000 * 60 * 10;
16
+
15
17
  function getPlantsInfo(instCode) {
18
+ var _a;
19
+
16
20
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17
21
  var url;
18
22
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -25,9 +29,42 @@ function getPlantsInfo(instCode) {
25
29
  url += "?instCode=".concat(instCode);
26
30
  }
27
31
 
28
- return _context.abrupt("return", apiManager.request(url, []));
32
+ _context.next = 4;
33
+ return apiManager.request({
34
+ url: url,
35
+ cache: {
36
+ isEnabled: true
37
+ }
38
+ });
39
+
40
+ case 4:
41
+ _context.t1 = _a = _context.sent;
42
+ _context.t0 = _context.t1 !== null;
43
+
44
+ if (!_context.t0) {
45
+ _context.next = 8;
46
+ break;
47
+ }
48
+
49
+ _context.t0 = _a !== void 0;
50
+
51
+ case 8:
52
+ if (!_context.t0) {
53
+ _context.next = 12;
54
+ break;
55
+ }
56
+
57
+ _context.t2 = _a;
58
+ _context.next = 13;
59
+ break;
29
60
 
30
- case 3:
61
+ case 12:
62
+ _context.t2 = [];
63
+
64
+ case 13:
65
+ return _context.abrupt("return", _context.t2);
66
+
67
+ case 14:
31
68
  case "end":
32
69
  return _context.stop();
33
70
  }
@@ -37,16 +74,56 @@ function getPlantsInfo(instCode) {
37
74
  }
38
75
 
39
76
  function check3dPermissionForPlant(plantCode) {
77
+ var _a;
78
+
40
79
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
41
- var url;
80
+ var url, defaultValue;
42
81
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
43
82
  while (1) {
44
83
  switch (_context2.prev = _context2.next) {
45
84
  case 0:
46
85
  url = "".concat(apiManager.baseApiUrl, "/echo-3d-model/platform/access/").concat(plantCode);
47
- return _context2.abrupt("return", apiManager.request(url, {}));
86
+ defaultValue = {
87
+ plantCodes: [],
88
+ timestamp: new Date()
89
+ };
90
+ _context2.next = 4;
91
+ return apiManager.request({
92
+ url: url,
93
+ cache: {
94
+ isEnabled: true,
95
+ timeToLiveMilliseconds: tenMinutesInMs
96
+ }
97
+ });
98
+
99
+ case 4:
100
+ _context2.t1 = _a = _context2.sent;
101
+ _context2.t0 = _context2.t1 !== null;
102
+
103
+ if (!_context2.t0) {
104
+ _context2.next = 8;
105
+ break;
106
+ }
107
+
108
+ _context2.t0 = _a !== void 0;
48
109
 
49
- case 2:
110
+ case 8:
111
+ if (!_context2.t0) {
112
+ _context2.next = 12;
113
+ break;
114
+ }
115
+
116
+ _context2.t2 = _a;
117
+ _context2.next = 13;
118
+ break;
119
+
120
+ case 12:
121
+ _context2.t2 = defaultValue;
122
+
123
+ case 13:
124
+ return _context2.abrupt("return", _context2.t2);
125
+
126
+ case 14:
50
127
  case "end":
51
128
  return _context2.stop();
52
129
  }
@@ -56,16 +133,56 @@ function check3dPermissionForPlant(plantCode) {
56
133
  }
57
134
 
58
135
  function getPermitted3dModels() {
136
+ var _a;
137
+
59
138
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
60
- var url;
139
+ var url, defaultValue;
61
140
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
62
141
  while (1) {
63
142
  switch (_context3.prev = _context3.next) {
64
143
  case 0:
65
144
  url = "".concat(apiManager.baseApiUrl, "/echo-3d-model/platform/access");
66
- return _context3.abrupt("return", apiManager.request(url, {}));
145
+ defaultValue = {
146
+ plantCodes: [],
147
+ timestamp: new Date()
148
+ };
149
+ _context3.next = 4;
150
+ return apiManager.request({
151
+ url: url,
152
+ cache: {
153
+ isEnabled: true,
154
+ timeToLiveMilliseconds: tenMinutesInMs
155
+ }
156
+ });
157
+
158
+ case 4:
159
+ _context3.t1 = _a = _context3.sent;
160
+ _context3.t0 = _context3.t1 !== null;
161
+
162
+ if (!_context3.t0) {
163
+ _context3.next = 8;
164
+ break;
165
+ }
166
+
167
+ _context3.t0 = _a !== void 0;
168
+
169
+ case 8:
170
+ if (!_context3.t0) {
171
+ _context3.next = 12;
172
+ break;
173
+ }
174
+
175
+ _context3.t2 = _a;
176
+ _context3.next = 13;
177
+ break;
178
+
179
+ case 12:
180
+ _context3.t2 = defaultValue;
181
+
182
+ case 13:
183
+ return _context3.abrupt("return", _context3.t2);
67
184
 
68
- case 2:
185
+ case 14:
69
186
  case "end":
70
187
  return _context3.stop();
71
188
  }
@@ -19,6 +19,8 @@ var apiManager = require('./api-manager.js');
19
19
 
20
20
 
21
21
  function getPlantsFromApi() {
22
+ var _a;
23
+
22
24
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
23
25
  var url;
24
26
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -27,12 +29,41 @@ function getPlantsFromApi() {
27
29
  case 0:
28
30
  url = "".concat(apiManager.baseApiUrl, "/plants");
29
31
  _context.next = 3;
30
- return apiManager.request(url, []);
32
+ return apiManager.request({
33
+ url: url,
34
+ cache: {
35
+ isEnabled: true
36
+ }
37
+ });
31
38
 
32
39
  case 3:
33
- return _context.abrupt("return", _context.sent);
40
+ _context.t1 = _a = _context.sent;
41
+ _context.t0 = _context.t1 !== null;
42
+
43
+ if (!_context.t0) {
44
+ _context.next = 7;
45
+ break;
46
+ }
47
+
48
+ _context.t0 = _a !== void 0;
49
+
50
+ case 7:
51
+ if (!_context.t0) {
52
+ _context.next = 11;
53
+ break;
54
+ }
55
+
56
+ _context.t2 = _a;
57
+ _context.next = 12;
58
+ break;
59
+
60
+ case 11:
61
+ _context.t2 = [];
62
+
63
+ case 12:
64
+ return _context.abrupt("return", _context.t2);
34
65
 
35
- case 4:
66
+ case 13:
36
67
  case "end":
37
68
  return _context.stop();
38
69
  }
@@ -13,6 +13,8 @@ var _tslib = require('../../../_virtual/_tslib.js');
13
13
  var apiManager = require('./api-manager.js');
14
14
 
15
15
  function getTimeseriesByName(name, instCode) {
16
+ var _a;
17
+
16
18
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17
19
  var url, response, timeseries;
18
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -22,11 +24,16 @@ function getTimeseriesByName(name, instCode) {
22
24
  url = "".concat(apiManager.baseApiUrl, "/").concat(instCode, "/timeseries/search-ims-by-name?name=").concat(name);
23
25
  _context.prev = 1;
24
26
  _context.next = 4;
25
- return apiManager.request(url, {});
27
+ return apiManager.request({
28
+ url: url,
29
+ cache: {
30
+ isEnabled: false
31
+ }
32
+ });
26
33
 
27
34
  case 4:
28
35
  response = _context.sent;
29
- timeseries = response.data.items.find(function (item) {
36
+ timeseries = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items.find(function (item) {
30
37
  return item.name === name;
31
38
  });
32
39
  return _context.abrupt("return", timeseries);
@@ -1,9 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
6
+
3
7
  Object.defineProperty(exports, '__esModule', {
4
8
  value: true
5
9
  });
6
10
 
11
+ var _tslib = require('../../../_virtual/_tslib.js');
12
+
7
13
  var apiManager = require('./api-manager.js');
8
14
  /**
9
15
  * Fetches tag information from ProCoSys.
@@ -22,8 +28,61 @@ function getTagFromProCoSys(_ref) {
22
28
  var instCode = _ref.instCode,
23
29
  tagNo = _ref.tagNo,
24
30
  abortSignal = _ref.abortSignal;
25
- var url = "".concat(apiManager.baseApiUrl, "/").concat(instCode, "/tags/procosys?tagNo=").concat(tagNo);
26
- return apiManager.request(url, [], abortSignal);
31
+
32
+ var _a;
33
+
34
+ return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
35
+ var url, tenMinutes;
36
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
37
+ while (1) {
38
+ switch (_context.prev = _context.next) {
39
+ case 0:
40
+ url = "".concat(apiManager.baseApiUrl, "/").concat(instCode, "/tags/procosys?tagNo=").concat(tagNo);
41
+ tenMinutes = 1000 * 10;
42
+ _context.next = 4;
43
+ return apiManager.request({
44
+ url: url,
45
+ abortSignal: abortSignal,
46
+ cache: {
47
+ isEnabled: true,
48
+ timeToLiveMilliseconds: tenMinutes
49
+ }
50
+ });
51
+
52
+ case 4:
53
+ _context.t1 = _a = _context.sent;
54
+ _context.t0 = _context.t1 !== null;
55
+
56
+ if (!_context.t0) {
57
+ _context.next = 8;
58
+ break;
59
+ }
60
+
61
+ _context.t0 = _a !== void 0;
62
+
63
+ case 8:
64
+ if (!_context.t0) {
65
+ _context.next = 12;
66
+ break;
67
+ }
68
+
69
+ _context.t2 = _a;
70
+ _context.next = 13;
71
+ break;
72
+
73
+ case 12:
74
+ _context.t2 = [];
75
+
76
+ case 13:
77
+ return _context.abrupt("return", _context.t2);
78
+
79
+ case 14:
80
+ case "end":
81
+ return _context.stop();
82
+ }
83
+ }
84
+ }, _callee);
85
+ }));
27
86
  }
28
87
 
29
88
  exports.getTagFromProCoSys = getTagFromProCoSys;
@@ -13,6 +13,8 @@ var _tslib = require('../../../_virtual/_tslib.js');
13
13
  var apiManager = require('./api-manager.js');
14
14
 
15
15
  function getApiVersion() {
16
+ var _a;
17
+
16
18
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17
19
  var url;
18
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -21,12 +23,41 @@ function getApiVersion() {
21
23
  case 0:
22
24
  url = "".concat(apiManager.baseApiUrl, "/Version");
23
25
  _context.next = 3;
24
- return apiManager.request(url, '');
26
+ return apiManager.request({
27
+ url: url,
28
+ cache: {
29
+ isEnabled: true
30
+ }
31
+ });
25
32
 
26
33
  case 3:
27
- return _context.abrupt("return", _context.sent);
34
+ _context.t1 = _a = _context.sent;
35
+ _context.t0 = _context.t1 !== null;
36
+
37
+ if (!_context.t0) {
38
+ _context.next = 7;
39
+ break;
40
+ }
41
+
42
+ _context.t0 = _a !== void 0;
43
+
44
+ case 7:
45
+ if (!_context.t0) {
46
+ _context.next = 11;
47
+ break;
48
+ }
49
+
50
+ _context.t2 = _a;
51
+ _context.next = 12;
52
+ break;
53
+
54
+ case 11:
55
+ _context.t2 = '';
56
+
57
+ case 12:
58
+ return _context.abrupt("return", _context.t2);
28
59
 
29
- case 4:
60
+ case 13:
30
61
  case "end":
31
62
  return _context.stop();
32
63
  }
@@ -36,6 +67,8 @@ function getApiVersion() {
36
67
  }
37
68
 
38
69
  function getAppVersion() {
70
+ var _a;
71
+
39
72
  return _tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
40
73
  var url;
41
74
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -44,12 +77,41 @@ function getAppVersion() {
44
77
  case 0:
45
78
  url = "".concat(apiManager.baseApiUrl, "/Version/ProductVersion");
46
79
  _context2.next = 3;
47
- return apiManager.request(url, '');
80
+ return apiManager.request({
81
+ url: url,
82
+ cache: {
83
+ isEnabled: true
84
+ }
85
+ });
48
86
 
49
87
  case 3:
50
- return _context2.abrupt("return", _context2.sent);
88
+ _context2.t1 = _a = _context2.sent;
89
+ _context2.t0 = _context2.t1 !== null;
90
+
91
+ if (!_context2.t0) {
92
+ _context2.next = 7;
93
+ break;
94
+ }
95
+
96
+ _context2.t0 = _a !== void 0;
97
+
98
+ case 7:
99
+ if (!_context2.t0) {
100
+ _context2.next = 11;
101
+ break;
102
+ }
103
+
104
+ _context2.t2 = _a;
105
+ _context2.next = 12;
106
+ break;
107
+
108
+ case 11:
109
+ _context2.t2 = '';
110
+
111
+ case 12:
112
+ return _context2.abrupt("return", _context2.t2);
51
113
 
52
- case 4:
114
+ case 13:
53
115
  case "end":
54
116
  return _context2.stop();
55
117
  }