@intuitionrobotics/thunderstorm 0.41.69 → 0.41.72

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 (167) hide show
  1. package/app-backend/api/v1/utils/version/_assert.js +1 -1
  2. package/app-backend/api/v1/utils/version/_assert.js.map +1 -1
  3. package/app-backend/api/v1/utils/version/assert.js +13 -58
  4. package/app-backend/api/v1/utils/version/assert.js.map +1 -1
  5. package/app-backend/core/BaseStorm.js +34 -87
  6. package/app-backend/core/BaseStorm.js.map +1 -1
  7. package/app-backend/core/Storm.js +42 -112
  8. package/app-backend/core/Storm.js.map +1 -1
  9. package/app-backend/exceptions.js +11 -27
  10. package/app-backend/exceptions.js.map +1 -1
  11. package/app-backend/modules/CleanupScheduler.js +24 -92
  12. package/app-backend/modules/CleanupScheduler.js.map +1 -1
  13. package/app-backend/modules/FirestoreBackupScheduler.js +47 -138
  14. package/app-backend/modules/FirestoreBackupScheduler.js.map +1 -1
  15. package/app-backend/modules/ForceUpgrade.js +31 -82
  16. package/app-backend/modules/ForceUpgrade.js.map +1 -1
  17. package/app-backend/modules/http/AxiosHttpModule.js +116 -184
  18. package/app-backend/modules/http/AxiosHttpModule.js.map +1 -1
  19. package/app-backend/modules/proxy/RemoteProxy.js +40 -90
  20. package/app-backend/modules/proxy/RemoteProxy.js.map +1 -1
  21. package/app-backend/modules/proxy/RemoteProxyCaller.js +49 -122
  22. package/app-backend/modules/proxy/RemoteProxyCaller.js.map +1 -1
  23. package/app-backend/modules/server/HttpServer.js +153 -216
  24. package/app-backend/modules/server/HttpServer.js.map +1 -1
  25. package/app-backend/modules/server/server-api.js +236 -361
  26. package/app-backend/modules/server/server-api.js.map +1 -1
  27. package/app-backend/modules/server/server-errors.js +51 -91
  28. package/app-backend/modules/server/server-errors.js.map +1 -1
  29. package/app-backend/utils/LogClient_File.js +23 -42
  30. package/app-backend/utils/LogClient_File.js.map +1 -1
  31. package/app-backend/utils/file.js +7 -50
  32. package/app-backend/utils/file.js.map +1 -1
  33. package/app-backend/utils/promisify-request.js +13 -43
  34. package/app-backend/utils/promisify-request.js.map +1 -1
  35. package/app-backend/utils/to-be-removed.js +7 -8
  36. package/app-backend/utils/to-be-removed.js.map +1 -1
  37. package/app-backend/utils/types.js +1 -1
  38. package/app-backend/utils/types.js.map +1 -1
  39. package/app-frontend/components/ActionButton.js +5 -5
  40. package/app-frontend/components/ActionButton.js.map +1 -1
  41. package/app-frontend/components/DropDown.js +91 -119
  42. package/app-frontend/components/DropDown.js.map +1 -1
  43. package/app-frontend/components/FilterInput.js +31 -48
  44. package/app-frontend/components/FilterInput.js.map +1 -1
  45. package/app-frontend/components/GenericSelect.js +30 -59
  46. package/app-frontend/components/GenericSelect.js.map +1 -1
  47. package/app-frontend/components/GenericTabs.js +5 -23
  48. package/app-frontend/components/GenericTabs.js.map +1 -1
  49. package/app-frontend/components/Overlay.js +15 -34
  50. package/app-frontend/components/Overlay.js.map +1 -1
  51. package/app-frontend/components/TS_Input.js +43 -60
  52. package/app-frontend/components/TS_Input.js.map +1 -1
  53. package/app-frontend/components/TS_Table.js +31 -48
  54. package/app-frontend/components/TS_Table.js.map +1 -1
  55. package/app-frontend/components/TS_TextArea.js +21 -48
  56. package/app-frontend/components/TS_TextArea.js.map +1 -1
  57. package/app-frontend/components/Tabs.js +16 -33
  58. package/app-frontend/components/Tabs.js.map +1 -1
  59. package/app-frontend/components/adapter/Adapter.js +103 -154
  60. package/app-frontend/components/adapter/Adapter.js.map +1 -1
  61. package/app-frontend/components/adapter/BaseRenderer.js +9 -32
  62. package/app-frontend/components/adapter/BaseRenderer.js.map +1 -1
  63. package/app-frontend/components/checkbox/TS_Checkbox.js +12 -29
  64. package/app-frontend/components/checkbox/TS_Checkbox.js.map +1 -1
  65. package/app-frontend/components/checkbox/TS_CheckboxField.js +16 -34
  66. package/app-frontend/components/checkbox/TS_CheckboxField.js.map +1 -1
  67. package/app-frontend/components/form/Form.js +21 -39
  68. package/app-frontend/components/form/Form.js.map +1 -1
  69. package/app-frontend/components/playground/Example_NewProps.js +25 -53
  70. package/app-frontend/components/playground/Example_NewProps.js.map +1 -1
  71. package/app-frontend/components/playground/Playground.js +21 -49
  72. package/app-frontend/components/playground/Playground.js.map +1 -1
  73. package/app-frontend/components/tree/MenuComponent.js +11 -27
  74. package/app-frontend/components/tree/MenuComponent.js.map +1 -1
  75. package/app-frontend/components/tree/MultiTypeAdaptor.js +16 -32
  76. package/app-frontend/components/tree/MultiTypeAdaptor.js.map +1 -1
  77. package/app-frontend/components/tree/SimpleTreeNodeRenderer.js +18 -52
  78. package/app-frontend/components/tree/SimpleTreeNodeRenderer.js.map +1 -1
  79. package/app-frontend/components/tree/Tree.js +142 -178
  80. package/app-frontend/components/tree/Tree.js.map +1 -1
  81. package/app-frontend/components/treeicons.js +5 -5
  82. package/app-frontend/components/treeicons.js.map +1 -1
  83. package/app-frontend/core/AbstractThunder.js +27 -43
  84. package/app-frontend/core/AbstractThunder.js.map +1 -1
  85. package/app-frontend/core/AppPage.js +16 -32
  86. package/app-frontend/core/AppPage.js.map +1 -1
  87. package/app-frontend/core/AppWrapper.js +9 -10
  88. package/app-frontend/core/AppWrapper.js.map +1 -1
  89. package/app-frontend/core/BaseComponent.js +62 -106
  90. package/app-frontend/core/BaseComponent.js.map +1 -1
  91. package/app-frontend/core/SimpleScriptInjector.js +12 -31
  92. package/app-frontend/core/SimpleScriptInjector.js.map +1 -1
  93. package/app-frontend/core/Thunder.js +32 -48
  94. package/app-frontend/core/Thunder.js.map +1 -1
  95. package/app-frontend/core/thunder-dispatcher.js +18 -67
  96. package/app-frontend/core/thunder-dispatcher.js.map +1 -1
  97. package/app-frontend/modules/ConnectivityModule.js +16 -32
  98. package/app-frontend/modules/ConnectivityModule.js.map +1 -1
  99. package/app-frontend/modules/ForceUpgrade.js +17 -33
  100. package/app-frontend/modules/ForceUpgrade.js.map +1 -1
  101. package/app-frontend/modules/HistoryModule.js +51 -79
  102. package/app-frontend/modules/HistoryModule.js.map +1 -1
  103. package/app-frontend/modules/ResourcesModule.js +12 -28
  104. package/app-frontend/modules/ResourcesModule.js.map +1 -1
  105. package/app-frontend/modules/StorageModule.js +47 -68
  106. package/app-frontend/modules/StorageModule.js.map +1 -1
  107. package/app-frontend/modules/ThunderstormModule.js +15 -31
  108. package/app-frontend/modules/ThunderstormModule.js.map +1 -1
  109. package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js +24 -41
  110. package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js.map +1 -1
  111. package/app-frontend/modules/component-loader/entry-component-loading-module.js +19 -36
  112. package/app-frontend/modules/component-loader/entry-component-loading-module.js.map +1 -1
  113. package/app-frontend/modules/dialog/Dialog.js +55 -96
  114. package/app-frontend/modules/dialog/Dialog.js.map +1 -1
  115. package/app-frontend/modules/dialog/DialogModule.js +48 -84
  116. package/app-frontend/modules/dialog/DialogModule.js.map +1 -1
  117. package/app-frontend/modules/http/HttpClient.js +46 -93
  118. package/app-frontend/modules/http/HttpClient.js.map +1 -1
  119. package/app-frontend/modules/http/XhrHttpModule.js +66 -88
  120. package/app-frontend/modules/http/XhrHttpModule.js.map +1 -1
  121. package/app-frontend/modules/locale/LocaleModule.js +23 -50
  122. package/app-frontend/modules/locale/LocaleModule.js.map +1 -1
  123. package/app-frontend/modules/menu/MenuAndButton.js +23 -40
  124. package/app-frontend/modules/menu/MenuAndButton.js.map +1 -1
  125. package/app-frontend/modules/menu/MenuModule.js +25 -42
  126. package/app-frontend/modules/menu/MenuModule.js.map +1 -1
  127. package/app-frontend/modules/menu/PopupMenu.js +37 -64
  128. package/app-frontend/modules/menu/PopupMenu.js.map +1 -1
  129. package/app-frontend/modules/routing/RoutingModule.js +47 -66
  130. package/app-frontend/modules/routing/RoutingModule.js.map +1 -1
  131. package/app-frontend/modules/routing/route.js +31 -33
  132. package/app-frontend/modules/routing/route.js.map +1 -1
  133. package/app-frontend/modules/toaster/BaseToaster.js +18 -36
  134. package/app-frontend/modules/toaster/BaseToaster.js.map +1 -1
  135. package/app-frontend/modules/toaster/Toaster.js +12 -38
  136. package/app-frontend/modules/toaster/Toaster.js.map +1 -1
  137. package/app-frontend/modules/toaster/ToasterModule.js +61 -88
  138. package/app-frontend/modules/toaster/ToasterModule.js.map +1 -1
  139. package/app-frontend/modules/tooltip/Tooltip.js +25 -52
  140. package/app-frontend/modules/tooltip/Tooltip.js.map +1 -1
  141. package/app-frontend/modules/tooltip/TooltipModule.js +32 -51
  142. package/app-frontend/modules/tooltip/TooltipModule.js.map +1 -1
  143. package/app-frontend/tools/KeyboardListener.js +24 -41
  144. package/app-frontend/tools/KeyboardListener.js.map +1 -1
  145. package/app-frontend/tools/Stylable.js +14 -28
  146. package/app-frontend/tools/Stylable.js.map +1 -1
  147. package/app-frontend/utils/tools.js +8 -8
  148. package/app-frontend/utils/tools.js.map +1 -1
  149. package/app-frontend/widgets/FieldEditor.js +16 -32
  150. package/app-frontend/widgets/FieldEditor.js.map +1 -1
  151. package/app-frontend/widgets/FieldEditorClick.js +32 -49
  152. package/app-frontend/widgets/FieldEditorClick.js.map +1 -1
  153. package/app-frontend/widgets/FieldEditorWithButtons.js +33 -49
  154. package/app-frontend/widgets/FieldEditorWithButtons.js.map +1 -1
  155. package/app-frontend/widgets/click-to-drag/ClickToDrag.js +25 -41
  156. package/app-frontend/widgets/click-to-drag/ClickToDrag.js.map +1 -1
  157. package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.js +22 -38
  158. package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.js.map +1 -1
  159. package/package.json +4 -4
  160. package/shared/BaseHttpModule.js +44 -64
  161. package/shared/BaseHttpModule.js.map +1 -1
  162. package/shared/BaseHttpRequest.js +122 -176
  163. package/shared/BaseHttpRequest.js.map +1 -1
  164. package/shared/request-types.js +4 -19
  165. package/shared/request-types.js.map +1 -1
  166. package/test-backend/StormTester.js +37 -90
  167. package/test-backend/StormTester.js.map +1 -1
@@ -1,28 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
33
9
  });
34
10
  };
35
- var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
- function verb(n) { return function (v) { return step([n, v]); }; }
39
- function step(op) {
40
- if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
42
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
- if (y = 0, t) op = [op[0] & 2, t.value];
44
- switch (op[0]) {
45
- case 0: case 1: t = op; break;
46
- case 4: _.label++; return { value: op[1], done: false };
47
- case 5: _.label++; y = op[1]; op = [0]; continue;
48
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
- default:
50
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
- if (t[2]) _.ops.pop();
55
- _.trys.pop(); continue;
56
- }
57
- op = body.call(thisArg, _);
58
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
- }
61
- };
62
11
  Object.defineProperty(exports, "__esModule", { value: true });
63
12
  exports.AxiosHttpModule = exports.AxiosHttpModule_Class = void 0;
64
13
  /*
@@ -82,26 +31,24 @@ exports.AxiosHttpModule = exports.AxiosHttpModule_Class = void 0;
82
31
  * limitations under the License.
83
32
  */
84
33
  // noinspection TypeScriptPreferShortImport
85
- var axios_1 = require("axios");
86
- var types_1 = require("../../../shared/types");
87
- var ts_common_1 = require("@intuitionrobotics/ts-common");
88
- var BaseHttpRequest_1 = require("../../../shared/BaseHttpRequest");
89
- var BaseHttpModule_1 = require("../../../shared/BaseHttpModule");
90
- var fs = require("fs");
91
- var AxiosHttpModule_Class = /** @class */ (function (_super) {
92
- __extends(AxiosHttpModule_Class, _super);
93
- function AxiosHttpModule_Class() {
94
- var _this = _super !== null && _super.apply(this, arguments) || this;
95
- _this.requestOption = {};
96
- return _this;
34
+ const axios_1 = require("axios");
35
+ const types_1 = require("../../../shared/types");
36
+ const ts_common_1 = require("@intuitionrobotics/ts-common");
37
+ const BaseHttpRequest_1 = require("../../../shared/BaseHttpRequest");
38
+ const BaseHttpModule_1 = require("../../../shared/BaseHttpModule");
39
+ const fs = require("fs");
40
+ class AxiosHttpModule_Class extends BaseHttpModule_1.BaseHttpModule_Class {
41
+ constructor() {
42
+ super(...arguments);
43
+ this.requestOption = {};
97
44
  }
98
- AxiosHttpModule_Class.prototype.init = function () {
99
- _super.prototype.init.call(this);
100
- var origin = this.config.origin;
45
+ init() {
46
+ super.init();
47
+ const origin = this.config.origin;
101
48
  if (origin)
102
49
  this.origin = origin;
103
- };
104
- AxiosHttpModule_Class.prototype.createRequest = function (method, key, data) {
50
+ }
51
+ createRequest(method, key, data) {
105
52
  return new AxiosHttpRequest(key, data, this.shouldCompress())
106
53
  .setOrigin(this.origin)
107
54
  .setMethod(method)
@@ -111,139 +58,124 @@ var AxiosHttpModule_Class = /** @class */ (function (_super) {
111
58
  .setHandleRequestFailure(this.handleRequestFailure)
112
59
  .setDefaultRequestHandler(this.processDefaultResponseHandlers)
113
60
  .setRequestOption(this.requestOption);
114
- };
115
- AxiosHttpModule_Class.prototype.setRequestOption = function (requestOption) {
61
+ }
62
+ setRequestOption(requestOption) {
116
63
  this.requestOption = requestOption;
117
64
  return this;
118
- };
119
- AxiosHttpModule_Class.prototype.downloadFile = function (url, outputFile, key) {
120
- if (key === void 0) { key = "Download file: " + url; }
121
- return __awaiter(this, void 0, void 0, function () {
122
- var downloadRequest, downloadResponse, outputFolder;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0: return [4 /*yield*/, this.createRequest(types_1.HttpMethod.GET, key)
126
- .setResponseType("arraybuffer")
127
- .setUrl(url)];
128
- case 1:
129
- downloadRequest = _a.sent();
130
- return [4 /*yield*/, downloadRequest.executeSync()];
131
- case 2:
132
- downloadResponse = _a.sent();
133
- outputFolder = outputFile.substring(0, outputFile.lastIndexOf("/"));
134
- if (!fs.existsSync(outputFolder))
135
- fs.mkdirSync(outputFolder);
136
- fs.writeFileSync(outputFile, downloadResponse);
137
- return [2 /*return*/, outputFile];
138
- }
139
- });
65
+ }
66
+ downloadFile(url, outputFile, key = `Download file: ${url}`) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const downloadRequest = yield this.createRequest(types_1.HttpMethod.GET, key)
69
+ .setResponseType("arraybuffer")
70
+ .setUrl(url);
71
+ const downloadResponse = yield downloadRequest.executeSync();
72
+ const outputFolder = outputFile.substring(0, outputFile.lastIndexOf("/"));
73
+ if (!fs.existsSync(outputFolder))
74
+ fs.mkdirSync(outputFolder);
75
+ fs.writeFileSync(outputFile, downloadResponse);
76
+ return outputFile;
140
77
  });
141
- };
142
- return AxiosHttpModule_Class;
143
- }(BaseHttpModule_1.BaseHttpModule_Class));
78
+ }
79
+ }
144
80
  exports.AxiosHttpModule_Class = AxiosHttpModule_Class;
145
81
  exports.AxiosHttpModule = new AxiosHttpModule_Class();
146
- var AxiosHttpRequest = /** @class */ (function (_super) {
147
- __extends(AxiosHttpRequest, _super);
148
- function AxiosHttpRequest(requestKey, requestData, shouldCompress) {
149
- var _this = _super.call(this, requestKey, requestData) || this;
150
- _this.requestOption = {};
151
- _this.compress = shouldCompress === undefined ? false : shouldCompress;
152
- _this.cancelSignal = axios_1.default.CancelToken.source();
153
- return _this;
82
+ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
83
+ constructor(requestKey, requestData, shouldCompress) {
84
+ super(requestKey, requestData);
85
+ this.requestOption = {};
86
+ this.compress = shouldCompress === undefined ? false : shouldCompress;
87
+ this.cancelSignal = axios_1.default.CancelToken.source();
154
88
  }
155
- AxiosHttpRequest.prototype.getStatus = function () {
89
+ getStatus() {
156
90
  if (!this.status)
157
91
  throw new ts_common_1.BadImplementationException('Missing status..');
158
92
  return this.status;
159
- };
160
- AxiosHttpRequest.prototype.getResponse = function () {
93
+ }
94
+ getResponse() {
161
95
  var _a;
162
96
  return (_a = this.response) === null || _a === void 0 ? void 0 : _a.data;
163
- };
164
- AxiosHttpRequest.prototype.resolveResponse = function () {
97
+ }
98
+ resolveResponse() {
165
99
  return this.getResponse();
166
- };
167
- AxiosHttpRequest.prototype.abortImpl = function () {
168
- this.cancelSignal.cancel("Request with key: '" + this.key + "' aborted by the user.");
169
- };
170
- AxiosHttpRequest.prototype.getErrorResponse = function () {
100
+ }
101
+ abortImpl() {
102
+ this.cancelSignal.cancel(`Request with key: '${this.key}' aborted by the user.`);
103
+ }
104
+ getErrorResponse() {
171
105
  return { debugMessage: this.getResponse() };
172
- };
173
- AxiosHttpRequest.prototype.setRequestOption = function (requestOption) {
106
+ }
107
+ setRequestOption(requestOption) {
174
108
  this.requestOption = requestOption;
175
109
  return this;
176
- };
177
- AxiosHttpRequest.prototype.executeImpl = function () {
178
- var _this = this;
110
+ }
111
+ executeImpl() {
179
112
  //loop through whatever preprocessor
180
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
181
- var nextOperator, fullUrl, body, headers, options, _a, e_1;
182
- var _this = this;
183
- var _b, _c;
184
- return __generator(this, function (_d) {
185
- switch (_d.label) {
186
- case 0:
187
- if (this.aborted)
188
- return [2 /*return*/, resolve()];
189
- nextOperator = this.url.indexOf("?") === -1 ? "?" : "&";
190
- fullUrl = Object.keys(this.params).reduce(function (url, paramKey) {
191
- var param = _this.params[paramKey];
192
- if (!param)
193
- return url;
194
- var toRet = "" + url + nextOperator + paramKey + "=" + encodeURIComponent(param);
195
- nextOperator = "&";
196
- return toRet;
197
- }, this.url);
198
- body = this.body;
199
- if (body)
200
- this.addHeader("Content-Length", "" + body.length);
201
- headers = Object.keys(this.headers).reduce(function (carry, headerKey) {
202
- carry[headerKey] = _this.headers[headerKey].join('; ');
203
- return carry;
204
- }, {});
205
- options = __assign(__assign({}, this.requestOption), { url: fullUrl, method: this.method, headers: headers,
206
- // TODO will probably need to use the abortController with a timeout for this.
207
- timeout: this.timeout, cancelToken: this.cancelSignal.token });
208
- if (body)
209
- options.data = body;
210
- if (this.responseType)
211
- options.responseType = this.responseType;
212
- _d.label = 1;
213
- case 1:
214
- _d.trys.push([1, 3, , 4]);
215
- _a = this;
216
- return [4 /*yield*/, axios_1.default.request(options)];
217
- case 2:
218
- _a.response = _d.sent();
219
- this.status = ((_b = this.response) === null || _b === void 0 ? void 0 : _b.status) || 200;
220
- return [2 /*return*/, resolve()];
221
- case 3:
222
- e_1 = _d.sent();
223
- // console.log('In catch');
224
- // TODO handle this here
225
- // if (xhr.readyState === 4 && xhr.status === 0) {
226
- // reject(new HttpException(404, this.url));
227
- // return;
228
- // }
229
- if (axios_1.default.isCancel(e_1)) {
230
- // Should already be set when I abort but just in case its aborted somehow else
231
- this.aborted = true;
232
- console.log('Api cancelled: ', e_1.message);
233
- }
234
- this.response = e_1.response;
235
- this.status = ((_c = this.response) === null || _c === void 0 ? void 0 : _c.status) || 500;
236
- return [2 /*return*/, reject(e_1)];
237
- case 4: return [2 /*return*/];
113
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
114
+ var _a, _b;
115
+ if (this.aborted)
116
+ return resolve();
117
+ let nextOperator = this.url.indexOf("?") === -1 ? "?" : "&";
118
+ const fullUrl = Object.keys(this.params).reduce((url, paramKey) => {
119
+ const param = this.params[paramKey];
120
+ if (!param)
121
+ return url;
122
+ const toRet = `${url}${nextOperator}${paramKey}=${encodeURIComponent(param)}`;
123
+ nextOperator = "&";
124
+ return toRet;
125
+ }, this.url);
126
+ // TODO set progress listener
127
+ // this.xhr.upload.onprogress = this.onProgressListener;
128
+ const body = this.body;
129
+ if (body)
130
+ this.addHeader("Content-Length", `${body.length}`);
131
+ // TODO add zipping of body
132
+ // if (typeof body === "string" && this.compress)
133
+ // return gzip(body, (error: Error | null, result: Buffer) => {
134
+ // if (error)
135
+ // return reject(error);
136
+ //
137
+ // xhr.send(result);
138
+ // });
139
+ //
140
+ // this.xhr.send(body as BodyInit);
141
+ const headers = Object.keys(this.headers).reduce((carry, headerKey) => {
142
+ carry[headerKey] = this.headers[headerKey].join('; ');
143
+ return carry;
144
+ }, {});
145
+ const options = Object.assign(Object.assign({}, this.requestOption), { url: fullUrl, method: this.method, headers: headers,
146
+ // TODO will probably need to use the abortController with a timeout for this.
147
+ timeout: this.timeout, cancelToken: this.cancelSignal.token });
148
+ if (body)
149
+ options.data = body;
150
+ if (this.responseType)
151
+ options.responseType = this.responseType;
152
+ try {
153
+ this.response = yield axios_1.default.request(options);
154
+ this.status = ((_a = this.response) === null || _a === void 0 ? void 0 : _a.status) || 200;
155
+ return resolve();
156
+ }
157
+ catch (e) {
158
+ // console.log('In catch');
159
+ // TODO handle this here
160
+ // if (xhr.readyState === 4 && xhr.status === 0) {
161
+ // reject(new HttpException(404, this.url));
162
+ // return;
163
+ // }
164
+ if (axios_1.default.isCancel(e)) {
165
+ // Should already be set when I abort but just in case its aborted somehow else
166
+ this.aborted = true;
167
+ console.log('Api cancelled: ', e.message);
238
168
  }
239
- });
240
- }); });
241
- };
242
- AxiosHttpRequest.prototype.getResponseHeader = function (headerKey) {
169
+ this.response = e.response;
170
+ this.status = ((_b = this.response) === null || _b === void 0 ? void 0 : _b.status) || 500;
171
+ return reject(e);
172
+ }
173
+ }));
174
+ }
175
+ getResponseHeader(headerKey) {
243
176
  if (!this.response)
244
- throw new ts_common_1.BadImplementationException("axios didn't return yet");
177
+ throw new ts_common_1.BadImplementationException(`axios didn't return yet`);
245
178
  return this.response.headers[headerKey];
246
- };
247
- return AxiosHttpRequest;
248
- }(BaseHttpRequest_1.BaseHttpRequest));
179
+ }
180
+ }
249
181
  //# sourceMappingURL=AxiosHttpModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosHttpModule.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/http/AxiosHttpModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2CAA2C;AAC3C,+BAA0B;AAC1B,+CAM+B;AAC/B,0DAGsC;AACtC,mEAAgE;AAChE,iEAAoE;AAQpE,uBAAyB;A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AM,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC7C,IAAI,CAAC,MAAM,GAAG,OAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;gBAC3C,OAAO,OAAO,EAAE,CAAC;aACjB;YAAC,OAAO,CAAC,EAAE;gBACX,2BAA2B;gBAC3B,wBAAwB;gBACxB,mDAAmD;gBACnD,8CAA8C;gBAC9C,YAAY;gBACZ,KAAK;gBAEL,IAAI,eAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACtB,+EAA+E;oBAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;oBACpB,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;iBAC1C;gBAED,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;gBAC3B,IAAI,CAAC,MAAM,GAAG,OAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;gBAC3C,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;aACjB;QACF,CAAC,CAAA,CAAC,CAAC;IACJ,CAAC;IAED,iBAAiB,CAAC,SAAiB;QAClC,IAAI,CAAC,IAAI,CAAC,QAAQ;YACjB,MAAM,IAAI,sCAA0B,CAAC,yBAAyB,CAAC,CAAC;QAEjE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACD"}
@@ -1,17 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -21,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
22
9
  });
23
10
  };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
11
  Object.defineProperty(exports, "__esModule", { value: true });
52
12
  exports.RemoteProxy = exports.RemoteProxy_Class = void 0;
53
13
  /*
@@ -70,38 +30,31 @@ exports.RemoteProxy = exports.RemoteProxy_Class = void 0;
70
30
  * See the License for the specific language governing permissions and
71
31
  * limitations under the License.
72
32
  */
73
- var ts_common_1 = require("@intuitionrobotics/ts-common");
74
- var HttpServer_1 = require("../server/HttpServer");
75
- var exceptions_1 = require("../../exceptions");
76
- var RemoteProxy_Class = /** @class */ (function (_super) {
77
- __extends(RemoteProxy_Class, _super);
78
- function RemoteProxy_Class() {
79
- var _this = _super !== null && _super.apply(this, arguments) || this;
80
- _this.Middleware = function (request) { return __awaiter(_this, void 0, void 0, function () {
81
- return __generator(this, function (_a) {
82
- exports.RemoteProxy.assertSecret(request);
83
- return [2 /*return*/];
84
- });
85
- }); };
86
- return _this;
33
+ const ts_common_1 = require("@intuitionrobotics/ts-common");
34
+ const HttpServer_1 = require("../server/HttpServer");
35
+ const exceptions_1 = require("../../exceptions");
36
+ class RemoteProxy_Class extends ts_common_1.Module {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.Middleware = (request) => __awaiter(this, void 0, void 0, function* () {
40
+ exports.RemoteProxy.assertSecret(request);
41
+ });
87
42
  }
88
- RemoteProxy_Class.prototype.__queryRequestInfo = function (request) {
89
- return __awaiter(this, void 0, void 0, function () {
90
- var data;
91
- return __generator(this, function (_a) {
92
- try {
93
- data = this.proxyHeader.get(request);
94
- }
95
- catch (e) {
96
- }
97
- return [2 /*return*/, {
98
- key: this.getName(),
99
- data: data
100
- }];
101
- });
43
+ __queryRequestInfo(request) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ let data;
46
+ try {
47
+ data = this.proxyHeader.get(request);
48
+ }
49
+ catch (e) {
50
+ }
51
+ return {
52
+ key: this.getName(),
53
+ data
54
+ };
102
55
  });
103
- };
104
- RemoteProxy_Class.prototype.init = function () {
56
+ }
57
+ init() {
105
58
  if (!this.config)
106
59
  throw new ts_common_1.ImplementationMissingException("MUST specify config for this module!!");
107
60
  if (!this.config.secretHeaderName)
@@ -110,35 +63,32 @@ var RemoteProxy_Class = /** @class */ (function (_super) {
110
63
  this.config.proxyHeaderName = 'x-proxy';
111
64
  this.secretHeader = new HttpServer_1.HeaderKey(this.config.secretHeaderName);
112
65
  this.proxyHeader = new HttpServer_1.HeaderKey(this.config.proxyHeaderName);
113
- };
114
- RemoteProxy_Class.prototype.assertSecret = function (request) {
66
+ }
67
+ assertSecret(request) {
115
68
  if (!this.secretHeader || !this.proxyHeader)
116
69
  throw new ts_common_1.ImplementationMissingException("MUST add RemoteProxy to your module list!!!");
117
- var secret = this.secretHeader.get(request);
118
- var proxyId = this.proxyHeader.get(request);
119
- var expectedSecret = this.config.remotes[proxyId];
70
+ const secret = this.secretHeader.get(request);
71
+ const proxyId = this.proxyHeader.get(request);
72
+ const expectedSecret = this.config.remotes[proxyId];
120
73
  if (!proxyId)
121
- throw new exceptions_1.ApiException(403, "Missing proxy declaration in config for " + proxyId + " !!");
74
+ throw new exceptions_1.ApiException(403, `Missing proxy declaration in config for ${proxyId} !!`);
122
75
  if (!secret)
123
- throw new exceptions_1.ApiException(403, "Missing secret !!");
76
+ throw new exceptions_1.ApiException(403, `Missing secret !!`);
124
77
  if (!expectedSecret)
125
- throw new exceptions_1.ApiException(403, "ProxyId '" + proxyId + "' is not registered for remote access !!");
78
+ throw new exceptions_1.ApiException(403, `ProxyId '${proxyId}' is not registered for remote access !!`);
126
79
  if (expectedSecret.secret !== secret)
127
- throw new exceptions_1.ApiException(403, "Secret does not match for proxyId: " + proxyId);
128
- var requestUrl = request.path;
80
+ throw new exceptions_1.ApiException(403, `Secret does not match for proxyId: ${proxyId}`);
81
+ const requestUrl = request.path;
129
82
  if (!expectedSecret.urls || !expectedSecret.urls.includes(requestUrl))
130
- throw new exceptions_1.ApiException(403, "Requested url '" + requestUrl + "' is not allowed from proxyId: " + proxyId);
83
+ throw new exceptions_1.ApiException(403, `Requested url '${requestUrl}' is not allowed from proxyId: ${proxyId}`);
131
84
  return expectedSecret.extras;
132
- };
133
- RemoteProxy_Class.prototype.processApi = function (request, requestData) {
134
- return __awaiter(this, void 0, void 0, function () {
135
- return __generator(this, function (_a) {
136
- return [2 /*return*/, this.assertSecret(request)];
137
- });
85
+ }
86
+ processApi(request, requestData) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ return this.assertSecret(request);
138
89
  });
139
- };
140
- return RemoteProxy_Class;
141
- }(ts_common_1.Module));
90
+ }
91
+ }
142
92
  exports.RemoteProxy_Class = RemoteProxy_Class;
143
93
  exports.RemoteProxy = new RemoteProxy_Class();
144
94
  //# sourceMappingURL=RemoteProxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteProxy.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0DAIsC;AAEtC,mDAG8B;AAC9B,+CAA8C;AAoB9C;IACS,qCAAc;IADvB;QAAA,qEAmEC;QAnDS,gBAAU,GAAyB,UAAO,OAAuB;;gBACzE,mBAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;;;aAClC,CAAC;;IAiDH,CAAC;IA/DM,8CAAkB,GAAxB,UAAyB,OAAuB;;;;gBAE/C,IAAI;oBACH,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;iBACrC;gBAAC,OAAO,CAAC,EAAE;iBACX;gBACD,sBAAO;wBACN,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE;wBACnB,IAAI,MAAA;qBACJ,EAAC;;;KACF;IAQS,gCAAI,GAAd;QACC,IAAI,CAAC,IAAI,CAAC,MAA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