@robotical/webapp-types 3.23.8 → 3.23.10

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marty-web-app",
3
- "version": "3.23.8",
3
+ "version": "3.23.10",
4
4
  "private": true,
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -1,11 +1,11 @@
1
- import { RICHWElem, RICHWElemList } from "@robotical/ricjs";
1
+ import { RICHWElemList } from "@robotical/ricjs";
2
2
  import Marty from "../Marty";
3
3
  export declare class RICNotificationsManager {
4
4
  private marty;
5
5
  constructor(marty: Marty);
6
- msgBodyDecider(report: any, hwElems: RICHWElem[]): void;
6
+ msgBodyDecider(report: any): void;
7
7
  reportNofication(report: any): Promise<void>;
8
- getHwStatus(stringify?: boolean, maxRetries?: number, delayMs?: number): Promise<string | RICHWElemList["hw"]>;
8
+ getHwStatus(stringify?: boolean, notificationType?: string, maxRetries?: number, delayMs?: number): Promise<string | RICHWElemList["hw"]>;
9
9
  getHWNameGivenIdNo(hwStatusArr: RICHWElemList["hw"], IDNo: number): string | number | null;
10
10
  getHwRevAndVersion(): Promise<string>;
11
11
  martyNameStr(): Promise<string>;
@@ -41,7 +41,6 @@ import RICServoFaultDetector from "@robotical/ricjs/dist/RICServoFaultDetector";
41
41
  import { toast } from "react-toastify";
42
42
  import { ReportedWarningsState } from "./ReportedWarningsState";
43
43
  import { createTicket, isSerialNumberRegistered } from "../../../../utils/warranty-service/warranty-service-utils";
44
- import { RICHWElemList_Str } from "@robotical/roboticaljs";
45
44
  import Logger from "../../../../services/logger/Logger";
46
45
  var SHOW_LOGS = true;
47
46
  var TAG = "RICNotificationsManager";
@@ -59,7 +58,6 @@ var CacheManager = /** @class */ (function () {
59
58
  return CacheManager.instances.get(key);
60
59
  };
61
60
  CacheManager.HW_STATUS_KEY = 'HW_STATUS';
62
- CacheManager.HW_ELEMS_KEY = 'HW_ELEMS';
63
61
  CacheManager.SYSTEM_INFO_KEY = 'SYSTEM_INFO';
64
62
  CacheManager.instances = new Map();
65
63
  return CacheManager;
@@ -85,29 +83,14 @@ var LastReportedCache = /** @class */ (function () {
85
83
  };
86
84
  return LastReportedCache;
87
85
  }());
88
- var isCompressedHardwareElementList = function (value) {
89
- return value !== null &&
90
- typeof value === "object" &&
91
- Array.isArray(value.hw);
92
- };
93
86
  var RICNotificationsManager = /** @class */ (function () {
94
87
  function RICNotificationsManager(marty) {
95
88
  this.marty = marty;
96
89
  }
97
- RICNotificationsManager.prototype.msgBodyDecider = function (report, hwElems) {
98
- Logger.info(SHOW_LOGS, TAG, "msgBodyDecider", report, hwElems);
90
+ RICNotificationsManager.prototype.msgBodyDecider = function (report) {
91
+ Logger.info(SHOW_LOGS, TAG, "msgBodyDecider", report);
99
92
  switch (report.msgBody) {
100
93
  case "overCurrentDet":
101
- if (!report.hasOwnProperty("IDNo"))
102
- break;
103
- var motor = report.IDNo;
104
- var motorElem = hwElems.find(function (_a) {
105
- var IDNo = _a.IDNo;
106
- return IDNo === report.IDNo;
107
- });
108
- if (motorElem !== undefined) {
109
- motor = motorElem.name;
110
- }
111
94
  // TODO: add warnings manager to display warnings to user
112
95
  // adding warning to the manager where the warning message to
113
96
  // be displayed is decided
@@ -127,83 +110,57 @@ var RICNotificationsManager = /** @class */ (function () {
127
110
  // REPORT notifications are messages generated by RIC in response to certain events, including raw i2c events and motor safeties
128
111
  RICNotificationsManager.prototype.reportNofication = function (report) {
129
112
  return __awaiter(this, void 0, void 0, function () {
130
- var hwElemsCached_str, hwElems, hwElemsResponse, hwElems_str;
131
113
  return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0:
134
- Logger.info(SHOW_LOGS, TAG, "reportNotification Report callback", report);
135
- hwElemsCached_str = CacheManager.getInstance(CacheManager.HW_ELEMS_KEY, 30000).getLastReported();
136
- if (!hwElemsCached_str) return [3 /*break*/, 1];
137
- Logger.info(SHOW_LOGS, TAG, "got hw elems from cache", hwElemsCached_str);
138
- hwElems = RICHWElemList_Str.expand(hwElemsCached_str);
139
- return [3 /*break*/, 3];
140
- case 1:
141
- Logger.info(SHOW_LOGS, TAG, "getting hw elems from rest");
142
- return [4 /*yield*/, this.marty.sendRestMessage("hwstatus/strstat")];
143
- case 2:
144
- hwElemsResponse = _a.sent();
145
- if (!isCompressedHardwareElementList(hwElemsResponse)) {
146
- Logger.error(SHOW_LOGS, TAG, "Invalid hardware status response", {
147
- responseType: hwElemsResponse === null ? "null" : typeof hwElemsResponse,
148
- hasHardwareElements: hwElemsResponse !== null &&
149
- typeof hwElemsResponse === "object" &&
150
- "hw" in hwElemsResponse,
151
- });
152
- return [2 /*return*/];
114
+ Logger.info(SHOW_LOGS, TAG, "reportNotification Report callback", report);
115
+ if (report.hasOwnProperty("msgType")) {
116
+ if (report.msgType === "raw") {
117
+ this.handleServoFaultRawMsg(report);
118
+ return [2 /*return*/];
119
+ }
120
+ if (report.msgType === "warn" && report.hasOwnProperty("msgBody")) {
121
+ if (report.msgBody === "servoFaultDet") {
122
+ // if there is a servo fault, we want to get the servo fault data using the servo fault detector
123
+ Logger.info(SHOW_LOGS, TAG, "servo fault detected, sending atomic read operation");
124
+ // this.handleServoFaultRawMsg(report); // DEBUGGING ONLY
125
+ this.marty.sendAtomicReadOperation(); // this will trigger reportMsgCallback, and so the above code will be executed
153
126
  }
154
- hwElems_str = hwElemsResponse;
155
- CacheManager.getInstance(CacheManager.HW_ELEMS_KEY, 30000).setLastReported(hwElems_str);
156
- hwElems = RICHWElemList_Str.expand(hwElems_str);
157
- _a.label = 3;
158
- case 3:
159
- Logger.info(SHOW_LOGS, TAG, "hw elems: ", hwElems);
160
- if (report.hasOwnProperty("msgType")) {
161
- if (report.msgType === "raw") {
162
- this.handleServoFaultRawMsg(report);
163
- return [2 /*return*/];
164
- }
165
- if (report.msgType === "warn" && report.hasOwnProperty("msgBody")) {
166
- if (report.msgBody === "servoFaultDet") {
167
- // if there is a servo fault, we want to get the servo fault data using the servo fault detector
168
- Logger.info(SHOW_LOGS, TAG, "servo fault detected, sending atomic read operation");
169
- // this.handleServoFaultRawMsg(report); // DEBUGGING ONLY
170
- this.marty.sendAtomicReadOperation(); // this will trigger reportMsgCallback, and so the above code will be executed
171
- }
172
- else if (report.msgBody === "elemCommsFailDet") {
173
- this.handleElemCommsFailDet(report);
174
- }
175
- else if (report.msgBody === "busFailDet") {
176
- this.handleBusFailDet(report);
177
- }
178
- else {
179
- Logger.info(SHOW_LOGS, TAG, "Unknown msgBody", report.msgBody);
180
- }
181
- ///////
182
- this.msgBodyDecider(report, hwElems.hw);
183
- }
184
- else {
185
- Logger.debug(SHOW_LOGS, TAG, "Either msgType or msgBody not found in report", report.msgType, report.msgBody);
186
- }
127
+ else if (report.msgBody === "elemCommsFailDet") {
128
+ this.handleElemCommsFailDet(report);
129
+ }
130
+ else if (report.msgBody === "busFailDet") {
131
+ this.handleBusFailDet(report);
187
132
  }
188
133
  else {
189
- Logger.debug(SHOW_LOGS, TAG, "Didn't find msgType in report", report);
134
+ Logger.info(SHOW_LOGS, TAG, "Unknown msgBody", report.msgBody);
190
135
  }
191
- return [2 /*return*/];
136
+ ///////
137
+ this.msgBodyDecider(report);
138
+ }
139
+ else {
140
+ Logger.debug(SHOW_LOGS, TAG, "Either msgType or msgBody not found in report", report.msgType, report.msgBody);
141
+ }
142
+ }
143
+ else {
144
+ Logger.debug(SHOW_LOGS, TAG, "Didn't find msgType in report", report);
192
145
  }
146
+ return [2 /*return*/];
193
147
  });
194
148
  });
195
149
  };
196
- RICNotificationsManager.prototype.getHwStatus = function (stringify, maxRetries, delayMs) {
150
+ RICNotificationsManager.prototype.getHwStatus = function (stringify, notificationType, maxRetries, delayMs) {
151
+ var _a;
197
152
  if (stringify === void 0) { stringify = true; }
153
+ if (notificationType === void 0) { notificationType = "unknown"; }
198
154
  if (maxRetries === void 0) { maxRetries = 10; }
199
155
  if (delayMs === void 0) { delayMs = 1000; }
200
156
  return __awaiter(this, void 0, void 0, function () {
201
- var i, cachedHwStatus, hwStatusResponse, err_1;
202
- return __generator(this, function (_a) {
203
- switch (_a.label) {
157
+ var lastResultCode, i, cachedHwStatus, hwStatusResponse, err_1;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
204
160
  case 0:
161
+ lastResultCode = "unknown";
205
162
  i = 0;
206
- _a.label = 1;
163
+ _b.label = 1;
207
164
  case 1:
208
165
  if (!(i < maxRetries)) return [3 /*break*/, 11];
209
166
  cachedHwStatus = CacheManager.getInstance(CacheManager.HW_STATUS_KEY, 30000).getLastReported();
@@ -211,38 +168,43 @@ var RICNotificationsManager = /** @class */ (function () {
211
168
  Logger.info(SHOW_LOGS, TAG, "got hw status from cache");
212
169
  return [2 /*return*/, stringify ? JSON.stringify(cachedHwStatus.hw) : cachedHwStatus.hw];
213
170
  }
214
- _a.label = 2;
171
+ _b.label = 2;
215
172
  case 2:
216
- _a.trys.push([2, 7, , 10]);
173
+ _b.trys.push([2, 7, , 10]);
217
174
  return [4 /*yield*/, this.marty.sendRestMessage('hwstatus')];
218
175
  case 3:
219
- hwStatusResponse = _a.sent();
176
+ hwStatusResponse = _b.sent();
220
177
  if (!((hwStatusResponse === null || hwStatusResponse === void 0 ? void 0 : hwStatusResponse.rslt) === 'ok' && (hwStatusResponse === null || hwStatusResponse === void 0 ? void 0 : hwStatusResponse.hw))) return [3 /*break*/, 4];
221
178
  CacheManager.getInstance(CacheManager.HW_STATUS_KEY, 30000).setLastReported(hwStatusResponse);
222
179
  Logger.info(SHOW_LOGS, TAG, "got hw status from rest");
223
180
  return [2 /*return*/, stringify ? JSON.stringify(hwStatusResponse.hw) : hwStatusResponse.hw];
224
181
  case 4:
182
+ lastResultCode = (_a = hwStatusResponse === null || hwStatusResponse === void 0 ? void 0 : hwStatusResponse.rslt) !== null && _a !== void 0 ? _a : (hwStatusResponse === null ? "null" : typeof hwStatusResponse);
225
183
  Logger.info(SHOW_LOGS, TAG, "Couldn't get hwstatus: retrying...");
226
184
  if (!(i < maxRetries - 1)) return [3 /*break*/, 6];
227
185
  return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, delayMs); })];
228
186
  case 5:
229
- _a.sent();
230
- _a.label = 6;
187
+ _b.sent();
188
+ _b.label = 6;
231
189
  case 6: return [3 /*break*/, 10];
232
190
  case 7:
233
- err_1 = _a.sent();
234
- Logger.error(SHOW_LOGS, TAG, "Failed to get hardware status; retrying", err_1);
191
+ err_1 = _b.sent();
192
+ lastResultCode = "exception";
193
+ Logger.info(SHOW_LOGS, TAG, "Failed to get hardware status; retrying", err_1);
235
194
  if (!(i < maxRetries - 1)) return [3 /*break*/, 9];
236
195
  return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, delayMs); })];
237
196
  case 8:
238
- _a.sent();
239
- _a.label = 9;
197
+ _b.sent();
198
+ _b.label = 9;
240
199
  case 9: return [3 /*break*/, 10];
241
200
  case 10:
242
201
  i++;
243
202
  return [3 /*break*/, 1];
244
203
  case 11:
245
- Logger.info(SHOW_LOGS, TAG, "Couldn't get hwstatus: returning empty array");
204
+ Logger.warn(SHOW_LOGS, TAG, "Hardware status unavailable; using element ID fallback", {
205
+ notificationType: notificationType,
206
+ resultCode: lastResultCode,
207
+ });
246
208
  return [2 /*return*/, stringify ? "[]" : []];
247
209
  }
248
210
  });
@@ -333,7 +295,7 @@ var RICNotificationsManager = /** @class */ (function () {
333
295
  servoHornPositionError: "Servo Horn Position Error",
334
296
  };
335
297
  if (!detectedServoFaults) return [3 /*break*/, 10];
336
- return [4 /*yield*/, this.getHwStatus(false)];
298
+ return [4 /*yield*/, this.getHwStatus(false, report.msgType)];
337
299
  case 1:
338
300
  hwStatusArr = _d.sent();
339
301
  hwStatus = JSON.stringify(hwStatusArr);
@@ -419,7 +381,7 @@ var RICNotificationsManager = /** @class */ (function () {
419
381
  var hwStatusArr, hwStatus, elemName, martyNameStr, appVersion, versionsInfo, enhancedDescription, userInfo;
420
382
  return __generator(this, function (_a) {
421
383
  switch (_a.label) {
422
- case 0: return [4 /*yield*/, this.getHwStatus(false)];
384
+ case 0: return [4 /*yield*/, this.getHwStatus(false, report.msgBody)];
423
385
  case 1:
424
386
  hwStatusArr = _a.sent();
425
387
  hwStatus = JSON.stringify(hwStatusArr);
@@ -470,7 +432,7 @@ var RICNotificationsManager = /** @class */ (function () {
470
432
  var hwStatusArr, hwStatus, elemName, martyNameStr, appVersion, versionsInfo, enhancedDescription, userInfo;
471
433
  return __generator(this, function (_a) {
472
434
  switch (_a.label) {
473
- case 0: return [4 /*yield*/, this.getHwStatus(false)];
435
+ case 0: return [4 /*yield*/, this.getHwStatus(false, report.msgBody)];
474
436
  case 1:
475
437
  hwStatusArr = _a.sent();
476
438
  hwStatus = JSON.stringify(hwStatusArr);
@@ -216,7 +216,11 @@ function QRContent(_a) {
216
216
  return;
217
217
  }
218
218
  var disposition = reportQRScannerError(error);
219
- if (disposition === "detector-unavailable") {
219
+ if (disposition === "permission-denied") {
220
+ onScannerUnavailable();
221
+ window.applicationManager.toaster.error("Camera access was not granted. Allow camera access for Robotical in your phone settings, or for this website in your browser settings, then select QR Code Verification to try again. You can also use LED verification.", { autoClose: false });
222
+ }
223
+ else if (disposition === "detector-unavailable") {
220
224
  resetBarcodeDetectorModule();
221
225
  onScannerUnavailable();
222
226
  window.applicationManager.toaster.error("QR scanning is unavailable. Please use LED verification or select QR Code Verification to try again.", { autoClose: false });
@@ -229,6 +233,10 @@ function QRContent(_a) {
229
233
  onScannerUnavailable();
230
234
  window.applicationManager.toaster.error("The camera is already in use. Close the other app using it and select QR Code Verification to try again, or use LED verification.", { autoClose: false });
231
235
  }
236
+ else {
237
+ onScannerUnavailable();
238
+ window.applicationManager.toaster.error("The QR camera could not start. Select QR Code Verification to try again, or use LED verification.", { autoClose: false });
239
+ }
232
240
  };
233
241
  var isWebapp = ((_b = window.applicationManager.deviceInfo) === null || _b === void 0 ? void 0 : _b.manufacturer) === "Webapp";
234
242
  return (_jsx("div", __assign({ className: styles.QRcontainer }, { children: _jsx("div", __assign({ className: styles.QRscannerContainer }, { children: _jsx(SwitchableCameraScanner, { styles: { container: { transform: isWebapp ? 'scaleX(-1)' : 'none' } }, onError: onScannerError, formats: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.23.8",
3
+ "version": "3.23.10",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",