@robotical/webapp-types 3.17.39 → 3.17.41

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,3 +1,4 @@
1
+ import type { RestMessageOptions } from "../../types/communication-between-apps/wrapper-communication";
1
2
  import { ConnectionAttemptResults, RaftConnectionMethod, RaftTypeE } from "../../types/raft";
2
3
  import { RaftInfoEvents } from "../../types/events/raft-info";
3
4
  import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
@@ -58,7 +59,7 @@ export default class RAFT implements RICInterface {
58
59
  /**
59
60
  * Send a REST message to the RAFT
60
61
  */
61
- sendRestMessage(msg: string, params?: object): Promise<RaftOKFail>;
62
+ sendRestMessage(msg: string, params?: object, options?: RestMessageOptions): Promise<RaftOKFail>;
62
63
  /**
63
64
  * Highlights the raft
64
65
  */
@@ -175,10 +175,10 @@ var RAFT = /** @class */ (function () {
175
175
  /**
176
176
  * Send a REST message to the RAFT
177
177
  */
178
- RAFT.prototype.sendRestMessage = function (msg, params) {
178
+ RAFT.prototype.sendRestMessage = function (msg, params, options) {
179
179
  return __awaiter(this, void 0, void 0, function () {
180
180
  return __generator(this, function (_a) {
181
- return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_SEND_REST, { raftId: this.id, msg: msg, params: params })];
181
+ return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_SEND_REST, { raftId: this.id, msg: msg, params: params, options: options })];
182
182
  });
183
183
  });
184
184
  };
@@ -8,6 +8,9 @@ export interface IWrapperSentMessage {
8
8
  data?: any;
9
9
  messagePromiseId: string;
10
10
  }
11
+ export type RestMessageOptions = {
12
+ waitForResponse?: boolean;
13
+ };
11
14
  export declare enum AppSentMessage {
12
15
  RAFT_IS_CONNECTED = "RAFT_IS_CONNECTED",
13
16
  RAFT_CONNECT = "RAFT_CONNECT",
@@ -11,6 +11,7 @@ export type UserDeviceInfo = {
11
11
  isEmulator: boolean;
12
12
  isTablet: boolean;
13
13
  appVersion: string;
14
+ latestAppVersion?: string;
14
15
  downloadedBuildVersion?: string;
15
16
  };
16
17
  export type CustomBluetoothItem = {
@@ -1,4 +1,5 @@
1
1
  import { RaftInfoEvents } from "../types/events/raft-info";
2
+ import type { RestMessageOptions } from "../types/communication-between-apps/wrapper-communication";
2
3
  import { ConnectionAttemptResults, RaftConnectionMethod } from "../types/raft";
3
4
  import Connector from "./connectors/Connector";
4
5
  import { RaftConnEvent, RaftPublishEvent, RaftUpdateEvent } from "@robotical/raftjs";
@@ -73,7 +74,7 @@ export declare class WrapperAppManager {
73
74
  /**
74
75
  * Send a REST message to the RAFT
75
76
  */
76
- sendRestMessage(msg: string, params: object | undefined, raftId: string): Promise<import("@robotical/raftjs").RaftOKFail>;
77
+ sendRestMessage(msg: string, params: object | undefined, raftId: string, options?: RestMessageOptions): Promise<import("@robotical/raftjs").RaftOKFail>;
77
78
  /**
78
79
  * Removes marty after a certain time
79
80
  * Removes from the martys list after x seconds so that we can still get the last event
@@ -286,10 +286,10 @@ var WrapperAppManager = /** @class */ (function () {
286
286
  /**
287
287
  * Send a REST message to the RAFT
288
288
  */
289
- WrapperAppManager.prototype.sendRestMessage = function (msg, params, raftId) {
289
+ WrapperAppManager.prototype.sendRestMessage = function (msg, params, raftId, options) {
290
290
  return __awaiter(this, void 0, void 0, function () {
291
291
  return __generator(this, function (_a) {
292
- return [2 /*return*/, this.connectors[raftId].sendRestMessage(msg, params)];
292
+ return [2 /*return*/, this.connectors[raftId].sendRestMessage(msg, params, options)];
293
293
  });
294
294
  });
295
295
  };
@@ -217,7 +217,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
217
217
  case 21: return [3 /*break*/, 51];
218
218
  case 22:
219
219
  _b.trys.push([22, 24, , 25]);
220
- return [4 /*yield*/, wrapperAppManager.sendRestMessage(data.msg, data.params, data.raftId)];
220
+ return [4 /*yield*/, wrapperAppManager.sendRestMessage(data.msg, data.params, data.raftId, data.options)];
221
221
  case 23:
222
222
  restResults = _b.sent();
223
223
  window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: restResults, messagePromiseId: messagePromiseId });
@@ -1,4 +1,5 @@
1
1
  import { RaftInfoEvents } from "../../types/events/raft-info";
2
+ import type { RestMessageOptions } from "../../types/communication-between-apps/wrapper-communication";
2
3
  import { ConnectionAttemptResults, RaftTypeE } from "../../types/raft";
3
4
  import { RaftObserver } from "../../application/RAFTs/RaftObserver";
4
5
  import ConnectorInterface from "./ConnectorInterface";
@@ -27,7 +28,7 @@ declare class Connector implements ConnectorInterface {
27
28
  /**
28
29
  * Send a REST message to the RAFT
29
30
  */
30
- sendRestMessage(msg: string, params?: object): Promise<RaftOKFail>;
31
+ sendRestMessage(msg: string, params?: object, options?: RestMessageOptions): Promise<RaftOKFail>;
31
32
  /**
32
33
  * Verify correct RAFT is selected
33
34
  */
@@ -38,9 +38,20 @@ import { RaftInfoEvents } from "../../types/events/raft-info";
38
38
  import { WrapperSentMessage } from "../../types/communication-between-apps/wrapper-communication";
39
39
  import Logger from "../../services/logger/Logger";
40
40
  import { RaftTypeE } from "../../types/raft";
41
- import { RaftConnEvent, RaftUpdateEvent, } from "@robotical/raftjs";
41
+ import { RaftConnEvent, RaftUpdateEvent, RICRESTElemCode, } from "@robotical/raftjs";
42
42
  var SHOW_LOGS = true;
43
43
  var TAG = "Connector";
44
+ var formatRestCommand = function (msg, params) {
45
+ var paramEntries = Object.entries(params || {});
46
+ var paramQueryStr = "";
47
+ for (var _i = 0, paramEntries_1 = paramEntries; _i < paramEntries_1.length; _i++) {
48
+ var param = paramEntries_1[_i];
49
+ if (paramQueryStr.length > 0)
50
+ paramQueryStr += "&";
51
+ paramQueryStr += param[0] + "=" + param[1];
52
+ }
53
+ return paramQueryStr.length > 0 ? msg + "?" + paramQueryStr : msg;
54
+ };
44
55
  var Connector = /** @class */ (function () {
45
56
  function Connector(id, connManager) {
46
57
  var _this = this;
@@ -97,10 +108,20 @@ var Connector = /** @class */ (function () {
97
108
  /**
98
109
  * Send a REST message to the RAFT
99
110
  */
100
- Connector.prototype.sendRestMessage = function (msg, params) {
111
+ Connector.prototype.sendRestMessage = function (msg, params, options) {
101
112
  return __awaiter(this, void 0, void 0, function () {
113
+ var command, sent;
102
114
  return __generator(this, function (_a) {
103
- return [2 /*return*/, this.connManager.getConnector().sendRICRESTMsg(msg, params || {})];
115
+ switch (_a.label) {
116
+ case 0:
117
+ if (!((options === null || options === void 0 ? void 0 : options.waitForResponse) === false)) return [3 /*break*/, 2];
118
+ command = formatRestCommand(msg, params);
119
+ return [4 /*yield*/, this.connManager.getConnector().getRaftMsgHandler().sendRICRESTNoResp(command, RICRESTElemCode.RICREST_ELEM_CODE_URL)];
120
+ case 1:
121
+ sent = _a.sent();
122
+ return [2 /*return*/, { rslt: sent ? "ok" : "fail" }];
123
+ case 2: return [2 /*return*/, this.connManager.getConnector().sendRICRESTMsg(msg, params || {})];
124
+ }
104
125
  });
105
126
  });
106
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.17.39",
3
+ "version": "3.17.41",
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",