@robotical/webapp-types 3.10.2 → 3.11.0

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 (30) hide show
  1. package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +12 -1
  2. package/dist-types/src/application/ApplicationManager/ApplicationManager.js +21 -0
  3. package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +14 -0
  4. package/dist-types/src/application/RAFTs/Marty/Marty.js +77 -1
  5. package/dist-types/src/application/RAFTs/Marty/notifications-manager/RICNotificationsManager.d.ts +15 -0
  6. package/dist-types/src/application/RAFTs/Marty/notifications-manager/RICNotificationsManager.js +498 -0
  7. package/dist-types/src/application/RAFTs/Marty/notifications-manager/ReportedWarningsState.d.ts +59 -0
  8. package/dist-types/src/application/RAFTs/Marty/notifications-manager/ReportedWarningsState.js +145 -0
  9. package/dist-types/src/application/RAFTs/RAFT.js +11 -1
  10. package/dist-types/src/components/modals/InBtButAPressed/index.d.ts +2 -0
  11. package/dist-types/src/components/modals/InBtButAPressed/index.js +21 -0
  12. package/dist-types/src/components/modals/InBtButAPressed/styles.d.ts +5 -0
  13. package/dist-types/src/components/modals/InBtButAPressed/styles.js +11 -0
  14. package/dist-types/src/services/logger/Logger.d.ts +5 -5
  15. package/dist-types/src/services/logger/Logger.js +40 -11
  16. package/dist-types/src/store/user-role-context.d.ts +12 -0
  17. package/dist-types/src/store/user-role-context.js +33 -0
  18. package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +3 -1
  19. package/dist-types/src/types/communication-between-apps/wrapper-communication.js +2 -0
  20. package/dist-types/src/types/userDeviceInfo.d.ts +6 -0
  21. package/dist-types/src/utils/warranty-service/cookies.d.ts +19 -0
  22. package/dist-types/src/utils/warranty-service/cookies.js +76 -0
  23. package/dist-types/src/utils/warranty-service/warranty-service-utils.d.ts +10 -0
  24. package/dist-types/src/utils/warranty-service/warranty-service-utils.js +232 -0
  25. package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +13 -1
  26. package/dist-types/src/wrapper-app/WrapperAppManager.js +109 -0
  27. package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +48 -21
  28. package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +4 -0
  29. package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +13 -0
  30. package/package.json +1 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The ReportedWarningsState class is used to store the reported warnings from Marty.
3
+ * One of the main purposes of this class is to prevent duplicate warnings from being
4
+ * displayed to the user.
5
+ */
6
+ import { RaftLog } from "@robotical/raftjs";
7
+ // we won't store these warnings in the cached warnings state, and so they won't be displayed or stored to the warranty service db, only to the general db
8
+ var ERRORS_TO_IGNORE = [
9
+ // eyes faulty connection
10
+ "Eyes Servo Fault Detected: Faulty drive Connection",
11
+ "8 Servo Fault Detected: Faulty drive Connection",
12
+ "Eyes Servo Fault Detected: Faulty drive connection",
13
+ "8 Servo Fault Detected: Faulty drive connection",
14
+ // right arm faulty connection
15
+ "RightArm Servo Fault Detected: Faulty drive Connection",
16
+ "7 Servo Fault Detected: Faulty drive Connection",
17
+ "RightArm Servo Fault Detected: Faulty drive connection",
18
+ "7 Servo Fault Detected: Faulty drive connection",
19
+ // left arm faulty connection
20
+ "LeftArm Servo Fault Detected: Faulty drive Connection",
21
+ "6 Servo Fault Detected: Faulty drive Connection",
22
+ "LeftArm Servo Fault Detected: Faulty drive connection",
23
+ "6 Servo Fault Detected: Faulty drive connection",
24
+ // all servo horn position errors
25
+ "Servo Horn Position Error"
26
+ ];
27
+ var ReportedWarningsState = /** @class */ (function () {
28
+ function ReportedWarningsState() {
29
+ this.reportedWarnings = new Map(); // warnings that have been reported to the user
30
+ this.cachedWarnings = new Map(); // warnings from the robot in the last 5 minutes
31
+ }
32
+ ReportedWarningsState.getInstanceOrInstantiate = function () {
33
+ if (!ReportedWarningsState.instance) {
34
+ ReportedWarningsState.instance = new ReportedWarningsState();
35
+ }
36
+ return ReportedWarningsState.instance;
37
+ };
38
+ ReportedWarningsState.shouldIgnoreWarning = function (warning) {
39
+ var shouldIgnore = false;
40
+ ERRORS_TO_IGNORE.forEach(function (error) {
41
+ if (warning.toLowerCase().includes(error.toLowerCase())) {
42
+ shouldIgnore = true;
43
+ }
44
+ });
45
+ return shouldIgnore;
46
+ };
47
+ /**
48
+ * This method is used to add a warning to the reported warnings state.
49
+ * @param warning The warning to be added to the reported warnings state.
50
+ * @returns true if the warning was added to the reported warnings state, false otherwise.
51
+ */
52
+ ReportedWarningsState.prototype.addWarning = function (warning) {
53
+ if (this.reportedWarnings.has(warning)) {
54
+ // If the warning has already been added, do not add it again.
55
+ return false;
56
+ }
57
+ else {
58
+ this.reportedWarnings.set(warning, {});
59
+ }
60
+ return true;
61
+ };
62
+ /**
63
+ * This method is used to remove a warning from the reported warnings state.
64
+ * @param warning The warning to be removed from the reported warnings state.
65
+ * @returns true if the warning was removed from the reported warnings state, false otherwise.
66
+ * */
67
+ ReportedWarningsState.prototype.removeWarning = function (warning) {
68
+ if (this.reportedWarnings.has(warning)) {
69
+ this.reportedWarnings.delete(warning);
70
+ return true;
71
+ }
72
+ return false;
73
+ };
74
+ /**
75
+ * This method is used to clear all warnings from the reported warnings state.
76
+ * */
77
+ ReportedWarningsState.prototype.clearWarnings = function () {
78
+ this.reportedWarnings.clear();
79
+ };
80
+ /**
81
+ * This method is used to get the reported warnings state.
82
+ * @returns The reported warnings state.
83
+ * */
84
+ ReportedWarningsState.prototype.getReportedWarnings = function () {
85
+ return this.reportedWarnings;
86
+ };
87
+ /**
88
+ * This method is used to set the reported warnings state.
89
+ * @param reportedWarnings The reported warnings state to be set.
90
+ * */
91
+ ReportedWarningsState.prototype.setReportedWarnings = function (reportedWarnings) {
92
+ this.reportedWarnings = reportedWarnings;
93
+ };
94
+ /**
95
+ * This method is used to check if a warning exists in the reported warnings state.
96
+ * @param warning The warning to be checked.
97
+ * @returns true if the warning exists in the reported warnings state, false otherwise.
98
+ * */
99
+ ReportedWarningsState.prototype.warningExists = function (warning) {
100
+ return this.reportedWarnings.has(warning);
101
+ };
102
+ /**
103
+ * This method is used to add a warning to the cached warnings state.
104
+ * @param warning The warning to be added to the cached warnings state.
105
+ * @returns true if the warning was added to the cached warnings state, false otherwise.
106
+ * */
107
+ ReportedWarningsState.prototype.addCachedWarning = function (warningsKey) {
108
+ if (this.cachedWarnings.has(warningsKey)) {
109
+ var cachedWarningsArr = this.cachedWarnings.get(warningsKey);
110
+ if (cachedWarningsArr) {
111
+ RaftLog.debug("addCachedWarning -- adding cached warning, cachedWarningsArr.length: " + cachedWarningsArr.length);
112
+ cachedWarningsArr.push({ timestamp: Date.now() });
113
+ }
114
+ }
115
+ else {
116
+ RaftLog.debug("addCachedWarning -- adding cached warning first time");
117
+ this.cachedWarnings.set(warningsKey, [{ timestamp: Date.now() }]);
118
+ }
119
+ return true;
120
+ };
121
+ /**
122
+ * This method is used to check if there are x number of warnings let last y minutes.
123
+ * @param warningsKey The key to the cached warnings state.
124
+ * @param numWarnings The number of warnings to check for.
125
+ * @param minutes The number of minutes to check for.
126
+ * @returns true if there are x number of warnings let last y minutes, false otherwise.
127
+ * */
128
+ ReportedWarningsState.prototype.hasNumWarningsInLastMinutes = function (warningsKey, numWarnings, minutes) {
129
+ if (this.cachedWarnings.has(warningsKey)) {
130
+ var cachedWarningsArr = this.cachedWarnings.get(warningsKey);
131
+ if (cachedWarningsArr) {
132
+ var now = Date.now();
133
+ var lastMinutes_1 = now - minutes * 60 * 1000;
134
+ var filteredWarnings = cachedWarningsArr.filter(function (warning) { return warning.timestamp > lastMinutes_1; });
135
+ RaftLog.debug("hasNumWarningsInLastMinutes -- filteredWarnings.length: " + filteredWarnings.length);
136
+ RaftLog.debug("hasNumWarningsInLastMinutes -- has ".concat(numWarnings, " warnings in last ").concat(minutes, " mins ") + (filteredWarnings.length >= numWarnings ? "true" : "false"));
137
+ return filteredWarnings.length >= numWarnings;
138
+ }
139
+ }
140
+ RaftLog.debug("hasNumWarningsInLastMinutes -- does not have cached warnings");
141
+ return false;
142
+ };
143
+ return ReportedWarningsState;
144
+ }());
145
+ export { ReportedWarningsState };
@@ -40,6 +40,7 @@ import { RaftInfoEvents } from "../../types/events/raft-info";
40
40
  import { RaftConnEvent, RaftPublishEvent, } from "@robotical/raftjs";
41
41
  import Logger from "../../services/logger/Logger";
42
42
  import randomHashGenerator from "../../utils/helpers/randomHashGenerator";
43
+ import { addRobotNameToSerialNumber, isSerialNumberRegistered } from "../../utils/warranty-service/warranty-service-utils";
43
44
  var SHOW_LOGS = true;
44
45
  var TAG = "RAFT";
45
46
  var RAFT = /** @class */ (function () {
@@ -329,12 +330,21 @@ var RAFT = /** @class */ (function () {
329
330
  switch (eventEnum) {
330
331
  case RaftConnEvent.CONN_VERIFIED_CORRECT:
331
332
  new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
332
- var robotId, raftType, deviceInfo, sessionId, deviceId;
333
+ var robotId, raftType, raftName, raftSerialNumber, deviceInfo, sessionId, deviceId;
334
+ var _this = this;
333
335
  return __generator(this, function (_a) {
334
336
  switch (_a.label) {
335
337
  case 0:
336
338
  robotId = this.id;
337
339
  raftType = this.type;
340
+ raftName = this.getFriendlyName();
341
+ raftSerialNumber = this.getSerialNumber();
342
+ isSerialNumberRegistered(raftSerialNumber).then(function (isRegistered) {
343
+ _this.isSerialNoRegisteredInWarranty = isRegistered;
344
+ if (_this.isSerialNoRegisteredInWarranty && raftName) {
345
+ addRobotNameToSerialNumber(raftSerialNumber, raftName);
346
+ }
347
+ });
338
348
  window.applicationManager.AnalyticsFacade.setRaftType(raftType);
339
349
  window.applicationManager.AnalyticsFacade.setRobotId(robotId);
340
350
  if (!!window.applicationManager.analyticsSessionId) return [3 /*break*/, 2];
@@ -0,0 +1,2 @@
1
+ declare function InBtButAPressedModalContent(): import("react/jsx-runtime").JSX.Element;
2
+ export default InBtButAPressedModalContent;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { ButtonsView, ModalText, ModalTitle, StyledView, StyledImage, } from "./styles";
4
+ import imageAbutton from "../../../assets/marty-a-button.png";
5
+ import modalState from "../../../state-observables/modal/ModalState";
6
+ import SimpleButton from "../../disposables/buttons/SimpleButton";
7
+ function InBtButAPressedModalContent() {
8
+ var _a = useState("Button A was pressed!"), modalText = _a[0], setModalText = _a[1];
9
+ var disconnectHandler = function () {
10
+ // disconnecting from marty
11
+ // window.marty.disconnect();
12
+ setTimeout(function () {
13
+ setModalText("Disconnected!");
14
+ }, 500);
15
+ setTimeout(function () {
16
+ modalState.closeModal();
17
+ }, 1000);
18
+ };
19
+ return (_jsxs(StyledView, { children: [_jsx(ModalTitle, { children: modalText }), modalText !== "Disconnected!" && (_jsx(ModalText, { children: "Someone has pressed the \"MODE\"/\"A\" button on the robot, if you would like to change mode you must first disconnect from the app and then press the A again!" })), _jsx(StyledImage, { src: imageAbutton }), modalText !== "Disconnected!" && (_jsxs(ButtonsView, { children: [_jsx(SimpleButton, { title: "Cancel", onClick: function () { return modalState.closeModal(); } }), _jsx(SimpleButton, { title: "Disconnect", onClick: disconnectHandler })] }))] }));
20
+ }
21
+ export default InBtButAPressedModalContent;
@@ -0,0 +1,5 @@
1
+ export declare const StyledView: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const ModalText: import("styled-components").StyledComponent<"p", any, {}, never>;
3
+ export declare const ModalTitle: import("styled-components").StyledComponent<"p", any, {}, never>;
4
+ export declare const ButtonsView: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const StyledImage: import("styled-components").StyledComponent<"img", any, {}, never>;
@@ -0,0 +1,11 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import styled from "styled-components";
6
+ export var StyledView = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-areas: \"modal-title modal-title\" \"modal-info marty-img\" \"buttons buttons\";\n grid-template-columns: 1fr 1fr;\n background-color: white;\n border-radius: 2rem;\n align-items: center;\n max-width: 90vw;\n max-height: 90vh;\n row-gap: 1rem;\n"], ["\n display: grid;\n grid-template-areas: \"modal-title modal-title\" \"modal-info marty-img\" \"buttons buttons\";\n grid-template-columns: 1fr 1fr;\n background-color: white;\n border-radius: 2rem;\n align-items: center;\n max-width: 90vw;\n max-height: 90vh;\n row-gap: 1rem;\n"])));
7
+ export var ModalText = styled.p(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n grid-area: modal-info;\n font-family: \"Lato Regular\";\n text-align: center;\n"], ["\n grid-area: modal-info;\n font-family: \"Lato Regular\";\n text-align: center;\n"])));
8
+ export var ModalTitle = styled.p(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n grid-area: modal-title;\n font-size: 2.2rem;\n font-family: \"Lato Regular\";\n text-align: center;\n"], ["\n grid-area: modal-title;\n font-size: 2.2rem;\n font-family: \"Lato Regular\";\n text-align: center;\n"])));
9
+ export var ButtonsView = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n grid-area: buttons;\n display: grid;\n grid-auto-flow: column;\n column-gap: 2rem;\n"], ["\n grid-area: buttons;\n display: grid;\n grid-auto-flow: column;\n column-gap: 2rem;\n"])));
10
+ export var StyledImage = styled.img(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n grid-area: marty-img;\n max-height: 40vh;\n max-width: 40vw;\n justify-self: center;\n"], ["\n grid-area: marty-img;\n max-height: 40vh;\n max-width: 40vw;\n justify-self: center;\n"])));
11
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -1,8 +1,8 @@
1
1
  declare class Logger {
2
- static info(SHOW_LOGS: boolean, tag: string, message: string): void;
3
- static error(SHOW_LOGS: boolean, tag: string, message: string): void;
4
- static debug(SHOW_LOGS: boolean, tag: string, message: string): void;
5
- static warn(SHOW_LOGS: boolean, tag: string, message: string): void;
6
- static phoneAppLog(SHOW_LOGS: boolean, tag: string, message: string): void;
2
+ static info(SHOW_LOGS: boolean, tag: string, ...messages: any[]): void;
3
+ static error(SHOW_LOGS: boolean, tag: string, ...messages: any[]): void;
4
+ static debug(SHOW_LOGS: boolean, tag: string, ...messages: any[]): void;
5
+ static warn(SHOW_LOGS: boolean, tag: string, ...messages: any[]): void;
6
+ static phoneAppLog(SHOW_LOGS: boolean, tag: string, ...messages: any[]): void;
7
7
  }
8
8
  export default Logger;
@@ -1,23 +1,52 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
1
10
  import { AppSentMessage } from "../../types/communication-between-apps/wrapper-communication";
2
11
  var SHOW_LOGS_GLOBAL = true;
3
12
  var Logger = /** @class */ (function () {
4
13
  function Logger() {
5
14
  }
6
- Logger.info = function (SHOW_LOGS, tag, message) {
7
- SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log('\x1b[34m%s\x1b[0m', "INFO: ".concat(tag), message); // Blue color for info logs
15
+ Logger.info = function (SHOW_LOGS, tag) {
16
+ var messages = [];
17
+ for (var _i = 2; _i < arguments.length; _i++) {
18
+ messages[_i - 2] = arguments[_i];
19
+ }
20
+ SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[34m%s\x1b[0m', "INFO: ".concat(tag)], messages, false)); // Blue color for info logs
8
21
  };
9
- Logger.error = function (SHOW_LOGS, tag, message) {
10
- SHOW_LOGS_GLOBAL && SHOW_LOGS && console.error('\x1b[31m%s\x1b[0m', "ERROR: ".concat(tag), message); // Red color for error logs
22
+ Logger.error = function (SHOW_LOGS, tag) {
23
+ var messages = [];
24
+ for (var _i = 2; _i < arguments.length; _i++) {
25
+ messages[_i - 2] = arguments[_i];
26
+ }
27
+ SHOW_LOGS_GLOBAL && SHOW_LOGS && console.error.apply(console, __spreadArray(['\x1b[31m%s\x1b[0m', "ERROR: ".concat(tag)], messages, false)); // Red color for error logs
11
28
  };
12
- Logger.debug = function (SHOW_LOGS, tag, message) {
13
- SHOW_LOGS_GLOBAL && SHOW_LOGS && console.debug('\x1b[35m%s\x1b[0m', "DEBUG: ".concat(tag), message); // Magenta color for debug logs
29
+ Logger.debug = function (SHOW_LOGS, tag) {
30
+ var messages = [];
31
+ for (var _i = 2; _i < arguments.length; _i++) {
32
+ messages[_i - 2] = arguments[_i];
33
+ }
34
+ SHOW_LOGS_GLOBAL && SHOW_LOGS && console.debug.apply(console, __spreadArray(['\x1b[35m%s\x1b[0m', "DEBUG: ".concat(tag)], messages, false)); // Magenta color for debug logs
14
35
  };
15
- Logger.warn = function (SHOW_LOGS, tag, message) {
16
- SHOW_LOGS_GLOBAL && SHOW_LOGS && console.warn('\x1b[33m%s\x1b[0m', "WARN: ".concat(tag), message); // Yellow color for warning logs
36
+ Logger.warn = function (SHOW_LOGS, tag) {
37
+ var messages = [];
38
+ for (var _i = 2; _i < arguments.length; _i++) {
39
+ messages[_i - 2] = arguments[_i];
40
+ }
41
+ SHOW_LOGS_GLOBAL && SHOW_LOGS && console.warn.apply(console, __spreadArray(['\x1b[33m%s\x1b[0m', "WARN: ".concat(tag)], messages, false)); // Yellow color for warning logs
17
42
  };
18
- Logger.phoneAppLog = function (SHOW_LOGS, tag, message) {
19
- SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log('\x1b[32m%s\x1b[0m', "PHONE APP: ".concat(tag), message); // Green color for phone app logs
20
- SHOW_LOGS_GLOBAL && window.wrapperCommunicator.sendMessageNoWait(AppSentMessage.LOG, { showLogs: SHOW_LOGS, tag: tag, message: message });
43
+ Logger.phoneAppLog = function (SHOW_LOGS, tag) {
44
+ var messages = [];
45
+ for (var _i = 2; _i < arguments.length; _i++) {
46
+ messages[_i - 2] = arguments[_i];
47
+ }
48
+ SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[32m%s\x1b[0m', "PHONE APP: ".concat(tag)], messages, false)); // Green color for phone app logs
49
+ SHOW_LOGS_GLOBAL && window.wrapperCommunicator.sendMessageNoWait(AppSentMessage.LOG, { showLogs: SHOW_LOGS, tag: tag, messages: messages });
21
50
  };
22
51
  return Logger;
23
52
  }());
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export type UserRole = "teacher" | "student" | null;
3
+ export type UserRoleContextTypes = {
4
+ userRole: UserRole;
5
+ setUserRole: (role: UserRole) => void;
6
+ };
7
+ declare const UserRoleContext: import("react").Context<UserRoleContextTypes>;
8
+ type UserRoleContextProviderTypes = {
9
+ children: React.ReactNode;
10
+ };
11
+ export declare function UserRoleContextProvider({ children, }: UserRoleContextProviderTypes): import("react/jsx-runtime").JSX.Element;
12
+ export default UserRoleContext;
@@ -0,0 +1,33 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { createContext, useState } from "react";
14
+ var UserRoleContext = createContext({
15
+ userRole: null,
16
+ setUserRole: function () { },
17
+ });
18
+ export function UserRoleContextProvider(_a) {
19
+ var children = _a.children;
20
+ var _b = useState(null), userRole = _b[0], setUserRole = _b[1];
21
+ var setUserRoleHandler = function (role) {
22
+ setUserRole(role);
23
+ };
24
+ var context = {
25
+ userRole: userRole,
26
+ setUserRole: setUserRoleHandler,
27
+ };
28
+ // we need to wire the context to the marty connector in
29
+ // order to be able to use the context/store outside of react components
30
+ window.applicationManager.setUserRoleCtx(context);
31
+ return (_jsx(UserRoleContext.Provider, __assign({ value: context }, { children: children })));
32
+ }
33
+ export default UserRoleContext;
@@ -29,9 +29,11 @@ export declare enum AppSentMessage {
29
29
  LIST_FILES_FROM_DEVICE_LOCAL_STORAGE = "LIST_FILES_FROM_DEVICE_LOCAL_STORAGE",
30
30
  LOG = "LOG",
31
31
  INJECT_JS = "INJECT_JS",
32
+ SCAN_FOR_POTENTIAL_WARRANTY_DEVICE = "SCAN_FOR_POTENTIAL_WARRANTY_DEVICE",
32
33
  MARTY_GET_COMMS_STATS = "MARTY_GET_COMMS_STATS",
33
34
  MARTY_CALIBRATE_COLOUR_SENSOR = "MARTY_CALIBRATE_COLOUR_SENSOR",
34
- GET_DEVICE_INFO = "GET_DEVICE_INFO"
35
+ GET_DEVICE_INFO = "GET_DEVICE_INFO",
36
+ SEND_ATOMIC_READ_OPERATION_TO_MARTY = "SEND_ATOMIC_READ_OPERATION_TO_MARTY"
35
37
  }
36
38
  export declare enum WrapperSentMessage {
37
39
  RAFT_PUBLISHED_EVENT = "RAFT_PUBLISHED_EVENT",
@@ -20,9 +20,11 @@ export var AppSentMessage;
20
20
  AppSentMessage["LIST_FILES_FROM_DEVICE_LOCAL_STORAGE"] = "LIST_FILES_FROM_DEVICE_LOCAL_STORAGE";
21
21
  AppSentMessage["LOG"] = "LOG";
22
22
  AppSentMessage["INJECT_JS"] = "INJECT_JS";
23
+ AppSentMessage["SCAN_FOR_POTENTIAL_WARRANTY_DEVICE"] = "SCAN_FOR_POTENTIAL_WARRANTY_DEVICE";
23
24
  AppSentMessage["MARTY_GET_COMMS_STATS"] = "MARTY_GET_COMMS_STATS";
24
25
  AppSentMessage["MARTY_CALIBRATE_COLOUR_SENSOR"] = "MARTY_CALIBRATE_COLOUR_SENSOR";
25
26
  AppSentMessage["GET_DEVICE_INFO"] = "GET_DEVICE_INFO";
27
+ AppSentMessage["SEND_ATOMIC_READ_OPERATION_TO_MARTY"] = "SEND_ATOMIC_READ_OPERATION_TO_MARTY";
26
28
  })(AppSentMessage || (AppSentMessage = {}));
27
29
  export var WrapperSentMessage;
28
30
  (function (WrapperSentMessage) {
@@ -11,3 +11,9 @@ export type UserDeviceInfo = {
11
11
  isEmulator: boolean;
12
12
  isTablet: boolean;
13
13
  };
14
+ export type CustomBluetoothItem = {
15
+ id?: string;
16
+ name?: string;
17
+ serialNumber: string;
18
+ type?: string;
19
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ Handling service program cookies
3
+ */
4
+ type OnboardingCookie = {
5
+ serialNumbers: Array<string>;
6
+ expires: string;
7
+ };
8
+ export declare function setOnboardingCookie(serialNumber: string): void;
9
+ export declare function getOnboardingCookie(): OnboardingCookie | undefined;
10
+ export declare function isOnboardingCookieExpired(): boolean;
11
+ export declare function appendSerialNumberToOnboardingCookie(serialNumber: string): void;
12
+ export declare function deleteOnboardingCookie(): void;
13
+ export declare class LocalStorageManager {
14
+ static setItem(name: string, value: object, expirationDays: number): void;
15
+ static getItem(name: string): any;
16
+ static removeItem(name: string): void;
17
+ static isDataExpired(dataExpiration: string): boolean;
18
+ }
19
+ export {};
@@ -0,0 +1,76 @@
1
+ /**
2
+ Handling service program cookies
3
+ */
4
+ var __assign = (this && this.__assign) || function () {
5
+ __assign = Object.assign || function(t) {
6
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7
+ s = arguments[i];
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
9
+ t[p] = s[p];
10
+ }
11
+ return t;
12
+ };
13
+ return __assign.apply(this, arguments);
14
+ };
15
+ var onboardingCookieName = '@serviceProgramOnboarding';
16
+ var onboardingCookieExpiration = 20; // days
17
+ export function setOnboardingCookie(serialNumber) {
18
+ LocalStorageManager.setItem(onboardingCookieName, { serialNumbers: [serialNumber] }, onboardingCookieExpiration);
19
+ }
20
+ export function getOnboardingCookie() {
21
+ return LocalStorageManager.getItem(onboardingCookieName);
22
+ }
23
+ export function isOnboardingCookieExpired() {
24
+ var onboardingCookie = getOnboardingCookie();
25
+ if (onboardingCookie) {
26
+ return LocalStorageManager.isDataExpired(onboardingCookie.expires);
27
+ }
28
+ return true;
29
+ }
30
+ export function appendSerialNumberToOnboardingCookie(serialNumber) {
31
+ var onboardingCookie = getOnboardingCookie();
32
+ if (onboardingCookie) {
33
+ if (onboardingCookie.serialNumbers.includes(serialNumber))
34
+ return;
35
+ onboardingCookie.serialNumbers.push(serialNumber);
36
+ LocalStorageManager.setItem(onboardingCookieName, onboardingCookie, onboardingCookieExpiration);
37
+ }
38
+ else {
39
+ LocalStorageManager.setItem(onboardingCookieName, { serialNumbers: [serialNumber] }, onboardingCookieExpiration);
40
+ }
41
+ }
42
+ export function deleteOnboardingCookie() {
43
+ LocalStorageManager.removeItem(onboardingCookieName);
44
+ }
45
+ var LocalStorageManager = /** @class */ (function () {
46
+ function LocalStorageManager() {
47
+ }
48
+ LocalStorageManager.setItem = function (name, value, expirationDays) {
49
+ var date = new Date();
50
+ date.setTime(date.getTime() + (expirationDays * 24 * 60 * 60 * 1000));
51
+ var expires = date.toUTCString();
52
+ var data = __assign(__assign({}, value), { expires: expires });
53
+ localStorage.setItem(name, JSON.stringify(data));
54
+ };
55
+ LocalStorageManager.getItem = function (name) {
56
+ var dataString = localStorage.getItem(name);
57
+ if (dataString) {
58
+ var data = JSON.parse(dataString);
59
+ return data;
60
+ }
61
+ return '';
62
+ };
63
+ LocalStorageManager.removeItem = function (name) {
64
+ localStorage.removeItem(name);
65
+ };
66
+ LocalStorageManager.isDataExpired = function (dataExpiration) {
67
+ var expirationDate = new Date(dataExpiration);
68
+ var now = new Date();
69
+ if (expirationDate < now) {
70
+ return true;
71
+ }
72
+ return false;
73
+ };
74
+ return LocalStorageManager;
75
+ }());
76
+ export { LocalStorageManager };
@@ -0,0 +1,10 @@
1
+ import { RegisteredUser } from "@robotical/appv2-warranty-service-lib/dist/types/serviceProgramDatabase";
2
+ export declare function shouldShowOnboardingModal(serialNo: string | undefined): Promise<boolean>;
3
+ export declare function getSerialNumberStubbornly(serialNumberGetter: () => string | undefined, attempts: number): Promise<string | undefined>;
4
+ export declare function registerUser(email: string, establishment: string, serialNumbers: string[]): Promise<boolean>;
5
+ export declare function isUserRegistered(email: string): Promise<boolean>;
6
+ export declare function getUserGivenEmail(email: string): Promise<RegisteredUser | null>;
7
+ export declare const isSerialNumberRegistered: (serialNo: string) => Promise<boolean>;
8
+ export declare const createTicket: (serialNo: string, title: string, description: string, robotName?: string, robotType?: string) => Promise<boolean>;
9
+ export declare const getEmailGivenSerialNumber: (serialNo: string) => Promise<string | undefined>;
10
+ export declare const addRobotNameToSerialNumber: (serialNo: string, name: string) => Promise<boolean>;