@intuitionrobotics/thunderstorm 0.46.0 → 0.47.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.
- package/app-backend/api/v1/utils/version/_assert.js +20 -0
- package/app-backend/api/v1/utils/version/_assert.js.map +1 -1
- package/app-backend/api/v1/utils/version/assert.js +20 -0
- package/app-backend/api/v1/utils/version/assert.js.map +1 -1
- package/app-backend/core/BaseStorm.d.ts +1 -1
- package/app-backend/core/BaseStorm.js +22 -2
- package/app-backend/core/BaseStorm.js.map +1 -1
- package/app-backend/core/Storm.d.ts +7 -0
- package/app-backend/core/Storm.js +46 -9
- package/app-backend/core/Storm.js.map +1 -1
- package/app-backend/exceptions.d.ts +3 -3
- package/app-backend/exceptions.js +2 -2
- package/app-backend/exceptions.js.map +1 -1
- package/app-backend/modules/CleanupScheduler.d.ts +2 -2
- package/app-backend/modules/CleanupScheduler.js +5 -6
- package/app-backend/modules/CleanupScheduler.js.map +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.d.ts +3 -3
- package/app-backend/modules/FirestoreBackupScheduler.js +9 -23
- package/app-backend/modules/FirestoreBackupScheduler.js.map +1 -1
- package/app-backend/modules/ForceUpgrade.d.ts +2 -2
- package/app-backend/modules/ForceUpgrade.js +28 -8
- package/app-backend/modules/ForceUpgrade.js.map +1 -1
- package/app-backend/modules/SlackModule.d.ts +5 -6
- package/app-backend/modules/SlackModule.js +7 -9
- package/app-backend/modules/SlackModule.js.map +1 -1
- package/app-backend/modules/_imports.d.ts +10 -0
- package/app-backend/modules/_imports.js +47 -0
- package/app-backend/modules/_imports.js.map +1 -0
- package/app-backend/modules/http/AxiosHttpModule.d.ts +7 -17
- package/app-backend/modules/http/AxiosHttpModule.js +47 -20
- package/app-backend/modules/http/AxiosHttpModule.js.map +1 -1
- package/app-backend/modules/http/types.d.ts +5 -5
- package/app-backend/modules/proxy/RemoteProxy.d.ts +3 -4
- package/app-backend/modules/proxy/RemoteProxy.js +30 -11
- package/app-backend/modules/proxy/RemoteProxy.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxyCaller.d.ts +7 -7
- package/app-backend/modules/proxy/RemoteProxyCaller.js +30 -12
- package/app-backend/modules/proxy/RemoteProxyCaller.js.map +1 -1
- package/app-backend/modules/server/HttpServer.d.ts +5 -6
- package/app-backend/modules/server/HttpServer.js +32 -10
- package/app-backend/modules/server/HttpServer.js.map +1 -1
- package/app-backend/modules/server/server-api.d.ts +9 -13
- package/app-backend/modules/server/server-api.js +23 -52
- package/app-backend/modules/server/server-api.js.map +1 -1
- package/app-backend/modules/server/server-errors.d.ts +2 -2
- package/app-backend/modules/server/server-errors.js +26 -7
- package/app-backend/modules/server/server-errors.js.map +1 -1
- package/app-backend/utils/LogClient_File.d.ts +2 -2
- package/app-backend/utils/LogClient_File.js +30 -12
- package/app-backend/utils/LogClient_File.js.map +1 -1
- package/app-backend/utils/file.js +20 -0
- package/app-backend/utils/file.js.map +1 -1
- package/app-backend/utils/promisify-request.js +4 -5
- package/app-backend/utils/promisify-request.js.map +1 -1
- package/app-backend/utils/to-be-removed.js +2 -2
- package/app-backend/utils/to-be-removed.js.map +1 -1
- package/app-backend/utils/types.d.ts +10 -7
- package/app-backend/utils/types.js +22 -2
- package/app-backend/utils/types.js.map +1 -1
- package/app-frontend/components/ActionButton.js +20 -0
- package/app-frontend/components/ActionButton.js.map +1 -1
- package/app-frontend/components/DropDown.d.ts +4 -4
- package/app-frontend/components/DropDown.js +25 -6
- package/app-frontend/components/DropDown.js.map +1 -1
- package/app-frontend/components/FilterInput.d.ts +2 -2
- package/app-frontend/components/FilterInput.js +23 -4
- package/app-frontend/components/FilterInput.js.map +1 -1
- package/app-frontend/components/GenericSelect.d.ts +2 -2
- package/app-frontend/components/GenericSelect.js.map +1 -1
- package/app-frontend/components/GenericTabs.d.ts +4 -0
- package/app-frontend/components/GenericTabs.js +11 -0
- package/app-frontend/components/GenericTabs.js.map +1 -0
- package/app-frontend/components/Overlay.d.ts +2 -2
- package/app-frontend/components/Overlay.js +20 -0
- package/app-frontend/components/Overlay.js.map +1 -1
- package/app-frontend/components/TS_Input.d.ts +2 -2
- package/app-frontend/components/TS_Input.js +23 -3
- package/app-frontend/components/TS_Input.js.map +1 -1
- package/app-frontend/components/TS_Table.d.ts +8 -8
- package/app-frontend/components/TS_Table.js +20 -0
- package/app-frontend/components/TS_Table.js.map +1 -1
- package/app-frontend/components/TS_TextArea.d.ts +2 -2
- package/app-frontend/components/TS_TextArea.js +20 -0
- package/app-frontend/components/TS_TextArea.js.map +1 -1
- package/app-frontend/components/Tabs.d.ts +2 -2
- package/app-frontend/components/adapter/Adapter.d.ts +15 -15
- package/app-frontend/components/adapter/Adapter.js +6 -6
- package/app-frontend/components/adapter/Adapter.js.map +1 -1
- package/app-frontend/components/adapter/BaseRenderer.d.ts +7 -7
- package/app-frontend/components/adapter/BaseRenderer.js +20 -0
- package/app-frontend/components/adapter/BaseRenderer.js.map +1 -1
- package/app-frontend/components/checkbox/TS_Checkbox.d.ts +3 -3
- package/app-frontend/components/checkbox/TS_Checkbox.js +1 -2
- package/app-frontend/components/checkbox/TS_Checkbox.js.map +1 -1
- package/app-frontend/components/checkbox/TS_CheckboxField.d.ts +3 -3
- package/app-frontend/components/checkbox/TS_CheckboxField.js +18 -0
- package/app-frontend/components/checkbox/TS_CheckboxField.js.map +1 -1
- package/app-frontend/components/form/Form.d.ts +4 -5
- package/app-frontend/components/form/Form.js +22 -2
- package/app-frontend/components/form/Form.js.map +1 -1
- package/app-frontend/components/form/types.d.ts +5 -6
- package/app-frontend/components/form/types.js +20 -0
- package/app-frontend/components/form/types.js.map +1 -1
- package/app-frontend/components/playground/Playground.d.ts +3 -3
- package/app-frontend/components/playground/Playground.js +2 -3
- package/app-frontend/components/playground/Playground.js.map +1 -1
- package/app-frontend/components/tree/MenuComponent.d.ts +1 -1
- package/app-frontend/components/tree/MenuComponent.js +22 -2
- package/app-frontend/components/tree/MenuComponent.js.map +1 -1
- package/app-frontend/components/tree/MultiTypeAdaptor.d.ts +1 -1
- package/app-frontend/components/tree/MultiTypeAdaptor.js +22 -2
- package/app-frontend/components/tree/MultiTypeAdaptor.js.map +1 -1
- package/app-frontend/components/tree/SimpleTreeNodeRenderer.js +20 -0
- package/app-frontend/components/tree/SimpleTreeNodeRenderer.js.map +1 -1
- package/app-frontend/components/tree/Tree.d.ts +4 -4
- package/app-frontend/components/tree/Tree.js +13 -13
- package/app-frontend/components/tree/Tree.js.map +1 -1
- package/app-frontend/components/tree/types.d.ts +1 -1
- package/app-frontend/components/tree/types.js +20 -0
- package/app-frontend/components/tree/types.js.map +1 -1
- package/app-frontend/components/treeicons.js.map +1 -1
- package/app-frontend/components/types.d.ts +2 -2
- package/app-frontend/components/types.js +20 -0
- package/app-frontend/components/types.js.map +1 -1
- package/app-frontend/core/AbstractThunder.d.ts +4 -1
- package/app-frontend/core/AbstractThunder.js +32 -0
- package/app-frontend/core/AbstractThunder.js.map +1 -1
- package/app-frontend/core/AppPage.d.ts +1 -1
- package/app-frontend/core/AppPage.js +20 -0
- package/app-frontend/core/AppPage.js.map +1 -1
- package/app-frontend/core/AppWrapper.d.ts +1 -1
- package/app-frontend/core/AppWrapper.js +23 -2
- package/app-frontend/core/AppWrapper.js.map +1 -1
- package/app-frontend/core/BaseComponent.d.ts +1 -2
- package/app-frontend/core/BaseComponent.js +18 -18
- package/app-frontend/core/BaseComponent.js.map +1 -1
- package/app-frontend/core/SimpleScriptInjector.d.ts +1 -1
- package/app-frontend/core/SimpleScriptInjector.js +22 -2
- package/app-frontend/core/SimpleScriptInjector.js.map +1 -1
- package/app-frontend/core/Thunder.js +27 -8
- package/app-frontend/core/Thunder.js.map +1 -1
- package/app-frontend/core/thunder-dispatcher.d.ts +5 -6
- package/app-frontend/core/thunder-dispatcher.js +7 -19
- package/app-frontend/core/thunder-dispatcher.js.map +1 -1
- package/app-frontend/modules/ConnectivityModule.d.ts +1 -1
- package/app-frontend/modules/ConnectivityModule.js +4 -4
- package/app-frontend/modules/ConnectivityModule.js.map +1 -1
- package/app-frontend/modules/ForceUpgrade.d.ts +2 -2
- package/app-frontend/modules/ForceUpgrade.js +25 -6
- package/app-frontend/modules/ForceUpgrade.js.map +1 -1
- package/app-frontend/modules/HistoryModule.d.ts +2 -3
- package/app-frontend/modules/HistoryModule.js +6 -10
- package/app-frontend/modules/HistoryModule.js.map +1 -1
- package/app-frontend/modules/ResourcesModule.d.ts +2 -2
- package/app-frontend/modules/ResourcesModule.js +2 -2
- package/app-frontend/modules/ResourcesModule.js.map +1 -1
- package/app-frontend/modules/StorageModule.d.ts +1 -1
- package/app-frontend/modules/StorageModule.js +5 -6
- package/app-frontend/modules/StorageModule.js.map +1 -1
- package/app-frontend/modules/ThunderstormModule.d.ts +2 -2
- package/app-frontend/modules/ThunderstormModule.js +3 -3
- package/app-frontend/modules/ThunderstormModule.js.map +1 -1
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.d.ts +3 -3
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js +20 -0
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js.map +1 -1
- package/app-frontend/modules/component-loader/entry-component-loading-module.d.ts +1 -1
- package/app-frontend/modules/component-loader/entry-component-loading-module.js +25 -4
- package/app-frontend/modules/component-loader/entry-component-loading-module.js.map +1 -1
- package/app-frontend/modules/dialog/Dialog.d.ts +5 -5
- package/app-frontend/modules/dialog/Dialog.js +23 -1
- package/app-frontend/modules/dialog/Dialog.js.map +1 -1
- package/app-frontend/modules/dialog/DialogModule.d.ts +3 -3
- package/app-frontend/modules/dialog/DialogModule.js +24 -4
- package/app-frontend/modules/dialog/DialogModule.js.map +1 -1
- package/app-frontend/modules/http/HttpClient.js +20 -0
- package/app-frontend/modules/http/HttpClient.js.map +1 -1
- package/app-frontend/modules/http/XhrHttpModule.d.ts +3 -19
- package/app-frontend/modules/http/XhrHttpModule.js +21 -22
- package/app-frontend/modules/http/XhrHttpModule.js.map +1 -1
- package/app-frontend/modules/locale/LocaleModule.d.ts +2 -2
- package/app-frontend/modules/locale/LocaleModule.js +6 -7
- package/app-frontend/modules/locale/LocaleModule.js.map +1 -1
- package/app-frontend/modules/locale/types.d.ts +3 -3
- package/app-frontend/modules/menu/MenuAndButton.d.ts +1 -1
- package/app-frontend/modules/menu/MenuAndButton.js +3 -3
- package/app-frontend/modules/menu/MenuAndButton.js.map +1 -1
- package/app-frontend/modules/menu/MenuModule.d.ts +3 -3
- package/app-frontend/modules/menu/MenuModule.js +5 -6
- package/app-frontend/modules/menu/MenuModule.js.map +1 -1
- package/app-frontend/modules/menu/PopupMenu.d.ts +3 -3
- package/app-frontend/modules/menu/PopupMenu.js +4 -4
- package/app-frontend/modules/menu/PopupMenu.js.map +1 -1
- package/app-frontend/modules/routing/RoutingModule.d.ts +4 -4
- package/app-frontend/modules/routing/RoutingModule.js +25 -6
- package/app-frontend/modules/routing/RoutingModule.js.map +1 -1
- package/app-frontend/modules/routing/route.d.ts +1 -1
- package/app-frontend/modules/routing/route.js +20 -0
- package/app-frontend/modules/routing/route.js.map +1 -1
- package/app-frontend/modules/toaster/BaseToaster.d.ts +4 -4
- package/app-frontend/modules/toaster/BaseToaster.js +22 -0
- package/app-frontend/modules/toaster/BaseToaster.js.map +1 -1
- package/app-frontend/modules/toaster/Toaster.js +20 -0
- package/app-frontend/modules/toaster/Toaster.js.map +1 -1
- package/app-frontend/modules/toaster/ToasterModule.d.ts +5 -5
- package/app-frontend/modules/toaster/ToasterModule.js +28 -8
- package/app-frontend/modules/toaster/ToasterModule.js.map +1 -1
- package/app-frontend/modules/tooltip/Tooltip.d.ts +2 -2
- package/app-frontend/modules/tooltip/Tooltip.js +22 -2
- package/app-frontend/modules/tooltip/Tooltip.js.map +1 -1
- package/app-frontend/modules/tooltip/TooltipModule.d.ts +3 -3
- package/app-frontend/modules/tooltip/TooltipModule.js +25 -6
- package/app-frontend/modules/tooltip/TooltipModule.js.map +1 -1
- package/app-frontend/tools/KeyboardListener.d.ts +1 -1
- package/app-frontend/tools/KeyboardListener.js +17 -0
- package/app-frontend/tools/KeyboardListener.js.map +1 -1
- package/app-frontend/tools/Stylable.d.ts +1 -1
- package/app-frontend/tools/Stylable.js +20 -0
- package/app-frontend/tools/Stylable.js.map +1 -1
- package/app-frontend/types/renderer-map.js +21 -1
- package/app-frontend/types/renderer-map.js.map +1 -1
- package/app-frontend/utils/tools.js +23 -3
- package/app-frontend/utils/tools.js.map +1 -1
- package/app-frontend/widgets/FieldEditor.d.ts +1 -1
- package/app-frontend/widgets/FieldEditorClick.d.ts +2 -2
- package/app-frontend/widgets/FieldEditorClick.js +3 -3
- package/app-frontend/widgets/FieldEditorClick.js.map +1 -1
- package/app-frontend/widgets/FieldEditorWithButtons.d.ts +2 -2
- package/app-frontend/widgets/FieldEditorWithButtons.js +3 -3
- package/app-frontend/widgets/FieldEditorWithButtons.js.map +1 -1
- package/app-frontend/widgets/click-to-drag/ClickToDrag.d.ts +2 -2
- package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.d.ts +2 -2
- package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.js.map +1 -1
- package/backend-test.d.ts +1 -0
- package/backend-test.js +38 -0
- package/backend-test.js.map +1 -0
- package/backend.d.ts +17 -0
- package/backend.js +54 -0
- package/backend.js.map +1 -0
- package/frontend.d.ts +54 -0
- package/frontend.js +91 -0
- package/frontend.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.js +41 -0
- package/index.js.map +1 -1
- package/package.json +8 -8
- package/shared/BaseHttpModule.d.ts +4 -6
- package/shared/BaseHttpModule.js +5 -6
- package/shared/BaseHttpModule.js.map +1 -1
- package/shared/BaseHttpRequest.d.ts +5 -7
- package/shared/BaseHttpRequest.js +12 -13
- package/shared/BaseHttpRequest.js.map +1 -1
- package/shared/consts.d.ts +1 -1
- package/shared/consts.js +20 -0
- package/shared/consts.js.map +1 -1
- package/shared/force-upgrade.d.ts +2 -2
- package/shared/force-upgrade.js +20 -0
- package/shared/force-upgrade.js.map +1 -1
- package/shared/request-types.d.ts +5 -5
- package/shared/request-types.js +21 -1
- package/shared/request-types.js.map +1 -1
- package/shared/types.d.ts +12 -11
- package/shared/types.js +21 -1
- package/shared/types.js.map +1 -1
- package/test-backend/StormTester.js +27 -7
- package/test-backend/StormTester.js.map +1 -1
- package/test-frontend/ThunderTester.js +20 -0
- package/test-frontend/ThunderTester.js.map +1 -1
- package/app-frontend/components/playground/Example_NewProps.d.ts +0 -23
- package/app-frontend/components/playground/Example_NewProps.js +0 -43
- package/app-frontend/components/playground/Example_NewProps.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlackModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SlackModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"SlackModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SlackModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAOsC;AACtC,4CAA6E;AA6B7E,MAAa,iBACT,SAAQ,kBAAkB;IAI1B;QACI,KAAK,CAAC,aAAa,CAAC,CAAC;QAHjB,eAAU,GAAe,EAAE,CAAC;IAIpC,CAAC;IAES,IAAI;QACV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;YAClB,OAAM;QACV,mGAAmG;QAEnG,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAS,CACpB,IAAI,CAAC,MAAM,CAAC,KAAK,kBAEb,sBAAsB,EAAE,IAAI,IACzB,IAAI,CAAC,MAAM,CAAC,WAAW,EAC5B,CAAC;IACX,CAAC;IAEY,WAAW,CAAC,YAA0B;;YAC/C,MAAM,UAAU,GAAiB,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC;gBAChE,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;aACtC,CAAC,CAAC,CAAC,YAAY,CAAC;YAEjB,MAAM,IAAI,GAAG,IAAI,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M,CAAC,QAAQ,CAAC;gBAC3G,OAAO;YAEX,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;gBAC1C,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;oBACrB,OAAM;YACd,CAAC;YAED,MAAM,mBAAW,CAAC,WAAW,CAAC,SAAS,OAAO,QAAQ,CAAC,CAAC;QAC5D,CAAC;KAAA;CACJ;AAtBD,gEAsBC;AAEY,QAAA,oBAAoB,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./server/server-api";
|
|
2
|
+
export * from "./server/HttpServer";
|
|
3
|
+
export * from "./proxy/RemoteProxyCaller";
|
|
4
|
+
export * from "./proxy/RemoteProxy";
|
|
5
|
+
export * from "../exceptions";
|
|
6
|
+
export * from "../utils/promisify-request";
|
|
7
|
+
export * from "../utils/to-be-removed";
|
|
8
|
+
export * from "./CleanupScheduler";
|
|
9
|
+
export * from "./FirestoreBackupScheduler";
|
|
10
|
+
export * from "../../index";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Thunderstorm is a full web app framework!
|
|
4
|
+
*
|
|
5
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
6
|
+
* Typescript & React frontend infrastructure
|
|
7
|
+
*
|
|
8
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
34
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
__exportStar(require("./server/server-api"), exports);
|
|
38
|
+
__exportStar(require("./server/HttpServer"), exports);
|
|
39
|
+
__exportStar(require("./proxy/RemoteProxyCaller"), exports);
|
|
40
|
+
__exportStar(require("./proxy/RemoteProxy"), exports);
|
|
41
|
+
__exportStar(require("../exceptions"), exports);
|
|
42
|
+
__exportStar(require("../utils/promisify-request"), exports);
|
|
43
|
+
__exportStar(require("../utils/to-be-removed"), exports);
|
|
44
|
+
__exportStar(require("./CleanupScheduler"), exports);
|
|
45
|
+
__exportStar(require("./FirestoreBackupScheduler"), exports);
|
|
46
|
+
__exportStar(require("../../index"), exports);
|
|
47
|
+
//# sourceMappingURL=_imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_imports.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/_imports.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,sDAAoC;AACpC,sDAAoC;AAEpC,4DAA0C;AAC1C,sDAAoC;AAEpC,gDAA8B;AAC9B,6DAA2C;AAC3C,yDAAuC;AAEvC,qDAAmC;AACnC,6DAA2C;AAE3C,8CAA4B"}
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
import { ApiTypeBinder,
|
|
1
|
+
import { ApiTypeBinder, HttpMethod, QueryParams } from "../../../shared/types";
|
|
2
2
|
import { BaseHttpRequest } from "../../../shared/BaseHttpRequest";
|
|
3
|
-
import { BaseHttpModule_Class } from "../../../shared/BaseHttpModule";
|
|
3
|
+
import { BaseHttpModule_Class, HttpConfig } from "../../../shared/BaseHttpModule";
|
|
4
4
|
import { Axios_RequestConfig } from "./types";
|
|
5
5
|
export declare class AxiosHttpModule_Class extends BaseHttpModule_Class {
|
|
6
6
|
private requestOption;
|
|
7
7
|
constructor(name?: string);
|
|
8
8
|
init(): void;
|
|
9
|
-
createRequest<Binder extends ApiTypeBinder<
|
|
9
|
+
createRequest<Binder extends ApiTypeBinder<U, R, B, P, E>, U extends string = Binder["url"], R = Binder["response"], B = Binder["body"], P extends QueryParams = Binder["queryParams"], E extends void | object = Binder["error"]>(method: HttpMethod, key: string, data?: string): BaseHttpRequest<Binder>;
|
|
10
10
|
setRequestOption(requestOption: Axios_RequestConfig): this;
|
|
11
11
|
downloadFile(url: string, outputFile: string, key?: string): Promise<string>;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type DeriveRealBinder<Binder> = Binder extends ApiTypeBinder<infer U, infer R, infer B, infer P> ? ApiTypeBinder<U, R, B, P> : void;
|
|
14
14
|
export declare const AxiosHttpModule: AxiosHttpModule_Class;
|
|
15
|
-
declare class
|
|
16
|
-
private response?;
|
|
17
|
-
private cancelSignal;
|
|
18
|
-
protected status?: number;
|
|
15
|
+
export declare class AxiosHttpClient extends BaseHttpModule_Class {
|
|
19
16
|
private requestOption;
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
22
|
-
getResponse(): any;
|
|
23
|
-
protected resolveResponse(): any;
|
|
24
|
-
protected abortImpl(): void;
|
|
25
|
-
getErrorResponse(): ErrorResponse<DeriveErrorType<Binder>>;
|
|
17
|
+
constructor(name: string, config: HttpConfig);
|
|
18
|
+
createRequest<Binder extends ApiTypeBinder<U, R, B, P, E>, U extends string = Binder["url"], R = Binder["response"], B = Binder["body"], P extends QueryParams = Binder["queryParams"], E extends void | object = Binder["error"]>(method: HttpMethod, key: string, data?: string): BaseHttpRequest<Binder>;
|
|
26
19
|
setRequestOption(requestOption: Axios_RequestConfig): this;
|
|
27
|
-
protected executeImpl(): Promise<void>;
|
|
28
|
-
getResponseHeader(headerKey: string): string | undefined;
|
|
29
20
|
}
|
|
30
|
-
export {};
|
|
@@ -9,11 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AxiosHttpModule = exports.AxiosHttpModule_Class = void 0;
|
|
13
|
-
// noinspection TypeScriptPreferShortImport
|
|
12
|
+
exports.AxiosHttpClient = exports.AxiosHttpModule = exports.AxiosHttpModule_Class = void 0;
|
|
14
13
|
const axios_1 = require("axios");
|
|
15
14
|
const types_1 = require("../../../shared/types");
|
|
16
|
-
const
|
|
15
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
17
16
|
const BaseHttpRequest_1 = require("../../../shared/BaseHttpRequest");
|
|
18
17
|
const BaseHttpModule_1 = require("../../../shared/BaseHttpModule");
|
|
19
18
|
const fs = require("fs");
|
|
@@ -68,7 +67,7 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
68
67
|
}
|
|
69
68
|
getStatus() {
|
|
70
69
|
if (!this.status)
|
|
71
|
-
throw new
|
|
70
|
+
throw new ts_common_1.BadImplementationException('Missing status..');
|
|
72
71
|
return this.status;
|
|
73
72
|
}
|
|
74
73
|
getResponse() {
|
|
@@ -95,14 +94,17 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
95
94
|
if (this.aborted)
|
|
96
95
|
return resolve();
|
|
97
96
|
let nextOperator = this.url.indexOf("?") === -1 ? "?" : "&";
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
let fullUrl = this.url;
|
|
98
|
+
const params = this.params;
|
|
99
|
+
if (params)
|
|
100
|
+
fullUrl = (0, ts_common_1._keys)(params).reduce((url, paramKey) => {
|
|
101
|
+
const param = params[paramKey];
|
|
102
|
+
if (!param)
|
|
103
|
+
return url;
|
|
104
|
+
const toRet = `${url}${nextOperator}${String(paramKey)}=${encodeURIComponent(param)}`;
|
|
105
|
+
nextOperator = "&";
|
|
106
|
+
return toRet;
|
|
107
|
+
}, this.url);
|
|
106
108
|
// TODO set progress listener
|
|
107
109
|
// this.xhr.upload.onprogress = this.onProgressListener;
|
|
108
110
|
const body = this.body;
|
|
@@ -137,18 +139,16 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
137
139
|
return resolve();
|
|
138
140
|
}
|
|
139
141
|
catch (e) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// return;
|
|
145
|
-
// }
|
|
142
|
+
if (!(e instanceof axios_1.default.AxiosError)) {
|
|
143
|
+
this.status = 500;
|
|
144
|
+
return reject(e);
|
|
145
|
+
}
|
|
146
146
|
if (axios_1.default.isCancel(e)) {
|
|
147
147
|
// Should already be set when I abort but just in case its aborted somehow else
|
|
148
148
|
this.aborted = true;
|
|
149
149
|
console.log('Api cancelled: ', e.message);
|
|
150
150
|
}
|
|
151
|
-
this.response = e
|
|
151
|
+
this.response = e["response"];
|
|
152
152
|
this.status = ((_b = this.response) === null || _b === void 0 ? void 0 : _b.status) || 500;
|
|
153
153
|
return reject(e);
|
|
154
154
|
}
|
|
@@ -156,8 +156,35 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
156
156
|
}
|
|
157
157
|
getResponseHeader(headerKey) {
|
|
158
158
|
if (!this.response)
|
|
159
|
-
throw new
|
|
159
|
+
throw new ts_common_1.BadImplementationException(`axios didn't return yet`);
|
|
160
160
|
return this.response.headers[headerKey];
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
+
class AxiosHttpClient extends BaseHttpModule_1.BaseHttpModule_Class {
|
|
164
|
+
constructor(name, config) {
|
|
165
|
+
super(name);
|
|
166
|
+
this.requestOption = {};
|
|
167
|
+
this.setConfig(config);
|
|
168
|
+
super.init();
|
|
169
|
+
const origin = this.config.origin;
|
|
170
|
+
if (origin)
|
|
171
|
+
this.origin = origin;
|
|
172
|
+
}
|
|
173
|
+
createRequest(method, key, data) {
|
|
174
|
+
return new AxiosHttpRequest(key, data, this.shouldCompress())
|
|
175
|
+
.setOrigin(this.origin)
|
|
176
|
+
.setMethod(method)
|
|
177
|
+
.setTimeout(this.timeout)
|
|
178
|
+
.setDefaultHeaders(this.defaultHeaders)
|
|
179
|
+
.setHandleRequestSuccess(this.handleRequestSuccess)
|
|
180
|
+
.setHandleRequestFailure(this.handleRequestFailure)
|
|
181
|
+
.setDefaultRequestHandler(this.processDefaultResponseHandlers)
|
|
182
|
+
.setRequestOption(this.requestOption);
|
|
183
|
+
}
|
|
184
|
+
setRequestOption(requestOption) {
|
|
185
|
+
this.requestOption = requestOption;
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.AxiosHttpClient = AxiosHttpClient;
|
|
163
190
|
//# sourceMappingURL=AxiosHttpModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosHttpModule.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/http/AxiosHttpModule.ts"],"names":[],"mappings":";;;;;;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CAAC,IAAI,EAAE,CAAA;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,IAAI,MAAM;YACN,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED,aAAa,CAKkC,MAAkB,EAAE,GAAW,EAAE,IAAa;QACzF,OAAO,IAAI,gBAAgB,CAAS,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;aAChE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;aACtB,SAAS,CAAC,MAAM,CAAC;aACjB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;aACxB,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC;aACtC,uBAAuB,CAAC,IAAI,CAAC,oBAAoB,CAAC;aAClD,uBAAuB,CAAC,IAAI,CAAC,oBAAoB,CAAC;aAClD,wBAAwB,CAAC,IAAI,CAAC,8BAA8B,CAAC;aAC7D,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,gBAAgB,CAAC,aAAkC;QAC/C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AAnCD,0CAmCC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosRequestConfig, AxiosResponse, CancelTokenSource, Method, ResponseType } from "axios";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
2
|
+
export type Axios_RequestConfig = AxiosRequestConfig;
|
|
3
|
+
export type Axios_Response<T = any> = AxiosResponse<T>;
|
|
4
|
+
export type Axios_CancelTokenSource = CancelTokenSource;
|
|
5
|
+
export type Axios_Method = Method;
|
|
6
|
+
export type Axios_ResponseType = ResponseType;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Module } from "@intuitionrobotics/ts-common
|
|
2
|
-
import { ObjectTS } from "@intuitionrobotics/ts-common/utils/types";
|
|
1
|
+
import { Module, ObjectTS } from "@intuitionrobotics/ts-common";
|
|
3
2
|
import { ServerApi_Middleware } from "../server/HttpServer";
|
|
4
3
|
import { HttpRequestData } from "../server/server-api";
|
|
5
4
|
import { ExpressRequest, QueryRequestInfo } from "../../utils/types";
|
|
6
|
-
|
|
5
|
+
type ProxyConfig = {
|
|
7
6
|
extras?: ObjectTS;
|
|
8
7
|
urls: string[];
|
|
9
8
|
secret: string;
|
|
10
9
|
};
|
|
11
|
-
export
|
|
10
|
+
export type RemoteProxyConfig = {
|
|
12
11
|
remotes: {
|
|
13
12
|
[proxyId: string]: ProxyConfig;
|
|
14
13
|
};
|
|
@@ -10,11 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RemoteProxy = exports.RemoteProxy_Class = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/*
|
|
14
|
+
* Thunderstorm is a full web app framework!
|
|
15
|
+
*
|
|
16
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
17
|
+
* Typescript & React frontend infrastructure
|
|
18
|
+
*
|
|
19
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
15
34
|
const HttpServer_1 = require("../server/HttpServer");
|
|
16
|
-
const
|
|
17
|
-
class RemoteProxy_Class extends
|
|
35
|
+
const exceptions_1 = require("../../exceptions");
|
|
36
|
+
class RemoteProxy_Class extends ts_common_1.Module {
|
|
18
37
|
constructor() {
|
|
19
38
|
super("RemoteProxy");
|
|
20
39
|
this.Middleware = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,7 +63,7 @@ class RemoteProxy_Class extends module_1.Module {
|
|
|
44
63
|
}
|
|
45
64
|
init() {
|
|
46
65
|
if (!this.config)
|
|
47
|
-
throw new
|
|
66
|
+
throw new ts_common_1.ImplementationMissingException("MUST specify config for this module!!");
|
|
48
67
|
if (!this.config.secretHeaderName)
|
|
49
68
|
this.config.secretHeaderName = 'x-secret';
|
|
50
69
|
if (!this.config.proxyHeaderName)
|
|
@@ -54,21 +73,21 @@ class RemoteProxy_Class extends module_1.Module {
|
|
|
54
73
|
}
|
|
55
74
|
assertSecret(request) {
|
|
56
75
|
if (!this.secretHeader || !this.proxyHeader)
|
|
57
|
-
throw new
|
|
76
|
+
throw new ts_common_1.ImplementationMissingException("MUST add RemoteProxy to your module list!!!");
|
|
58
77
|
const secret = this.getSecretHeader(request);
|
|
59
78
|
const proxyId = this.getProxyHeader(request);
|
|
60
79
|
const expectedSecret = this.config.remotes[proxyId];
|
|
61
80
|
if (!proxyId)
|
|
62
|
-
throw new
|
|
81
|
+
throw new exceptions_1.ApiException(403, `Missing proxy declaration in config for ${proxyId} !!`);
|
|
63
82
|
if (!secret)
|
|
64
|
-
throw new
|
|
83
|
+
throw new exceptions_1.ApiException(403, `Missing secret !!`);
|
|
65
84
|
if (!expectedSecret)
|
|
66
|
-
throw new
|
|
85
|
+
throw new exceptions_1.ApiException(403, `ProxyId '${proxyId}' is not registered for remote access !!`);
|
|
67
86
|
if (expectedSecret.secret !== secret)
|
|
68
|
-
throw new
|
|
87
|
+
throw new exceptions_1.ApiException(403, `Secret does not match for proxyId: ${proxyId}`);
|
|
69
88
|
const requestUrl = request.path;
|
|
70
89
|
if (!expectedSecret.urls || !expectedSecret.urls.includes(requestUrl))
|
|
71
|
-
throw new
|
|
90
|
+
throw new exceptions_1.ApiException(403, `Requested url '${requestUrl}' is not allowed from proxyId: ${proxyId}`);
|
|
72
91
|
return expectedSecret.extras;
|
|
73
92
|
}
|
|
74
93
|
processApi(request, requestData) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteProxy.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"RemoteProxy.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAA8F;AAE9F,qDAAqE;AACrE,iDAA8C;AAiB9C,MAAa,iBACT,SAAQ,kBAAc;IAGtB;QACI,KAAK,CAAC,aAAa,CAAC,CAAC;QAuBhB,eAAU,GAAyB,CAAO,OAAuB,EAAE,EAAE;YAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC1C,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAC,CAAA;QAC1D,CAAC,CAAA,CAAC;IAzBF,CAAC;IAEK,kBAAkB,CAAC,OAAuB;;YAC5C,IAAI,IAAwB,CAAC;YAC7B,IAAI,CAAC;gBACD,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;YACb,CAAC;YACD,OAAO;gBACH,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE;gBACnB,IAAI;aACP,CAAC;QACN,CAAC;KAAA;IAED,cAAc,CAAC,OA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B,CAAC,CAAC;QAErD,IAAI,CAAC,cAAc;YACf,MAAM,IAAI,yBAAY,CAAC,GAAG,EAAE,YAAY,OAAO,0CAA0C,CAAC,CAAC;QAE/F,IAAI,cAAc,CAAC,MAAM,KAAK,MAAM;YAChC,MAAM,IAAI,yBAAY,CAAC,GAAG,EAAE,sCAAsC,OAAO,EAAE,CAAC,CAAC;QAEjF,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YACjE,MAAM,IAAI,yBAAY,CAAC,GAAG,EAAE,kBAAkB,UAAU,kCAAkC,OAAO,EAAE,CAAC,CAAC;QAEzG,OAAO,cAAc,CAAC,MAAM,CAAC;IACjC,CAAC;IAEK,UAAU,CAAC,OAAuB,EAAE,WAA4B;;YAClE,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;KAAA;CACJ;AAjFD,8CAiFC;AAEY,QAAA,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module } from "@intuitionrobotics/ts-common
|
|
2
|
-
import {
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { ApiWithBody, ApiWithQuery, QueryParams } from "../../../shared/types";
|
|
3
3
|
import { AxiosResponse } from "axios";
|
|
4
|
-
export
|
|
4
|
+
export type RemoteServerConfig = {
|
|
5
5
|
secretHeaderName: string;
|
|
6
6
|
proxyHeaderName: string;
|
|
7
7
|
proxyId: string;
|
|
@@ -11,16 +11,16 @@ export declare type RemoteServerConfig = {
|
|
|
11
11
|
export declare abstract class RemoteProxyCaller<Config extends RemoteServerConfig> extends Module<Config> {
|
|
12
12
|
constructor(name: string);
|
|
13
13
|
protected init(): void;
|
|
14
|
-
protected executeGetRequest: <Binder extends
|
|
14
|
+
protected executeGetRequest: <Binder extends ApiWithQuery<U, R, P>, U extends string = Binder["url"], R = Binder["response"], P extends QueryParams = Binder["queryParams"]>(url: U, _params: P, _headers?: {
|
|
15
15
|
[key: string]: string;
|
|
16
16
|
} | undefined) => Promise<R>;
|
|
17
|
-
protected executeGetRequestImpl: <Binder extends
|
|
17
|
+
protected executeGetRequestImpl: <Binder extends ApiWithQuery<U, R, P>, U extends string = Binder["url"], R = Binder["response"], P extends QueryParams = Binder["queryParams"]>(url: U, _params: P, _headers?: {
|
|
18
18
|
[key: string]: string;
|
|
19
19
|
} | undefined) => Promise<AxiosResponse<R, any>>;
|
|
20
|
-
protected executePostRequest: <Binder extends
|
|
20
|
+
protected executePostRequest: <Binder extends ApiWithBody<U, R, B>, U extends string = Binder["url"], R = Binder["response"], B = Binder["body"]>(url: U, body: B, _headers?: {
|
|
21
21
|
[key: string]: string;
|
|
22
22
|
} | undefined) => Promise<R>;
|
|
23
|
-
protected executePostRequestImpl: <Binder extends
|
|
23
|
+
protected executePostRequestImpl: <Binder extends ApiWithBody<U, R, B>, U extends string = Binder["url"], R = Binder["response"], B = Binder["body"]>(url: U, body: B, _headers?: {
|
|
24
24
|
[key: string]: string;
|
|
25
25
|
} | undefined) => Promise<AxiosResponse<R, any>>;
|
|
26
26
|
private executeRequest;
|
|
@@ -10,12 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RemoteProxyCaller = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/*
|
|
14
|
+
* Thunderstorm is a full web app framework!
|
|
15
|
+
*
|
|
16
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
17
|
+
* Typescript & React frontend infrastructure
|
|
18
|
+
*
|
|
19
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
16
34
|
const promisify_request_1 = require("../../utils/promisify-request");
|
|
17
|
-
const
|
|
18
|
-
class RemoteProxyCaller extends
|
|
35
|
+
const exceptions_1 = require("../../exceptions");
|
|
36
|
+
class RemoteProxyCaller extends ts_common_1.Module {
|
|
19
37
|
// noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
|
|
20
38
|
constructor(name) {
|
|
21
39
|
super(name);
|
|
@@ -53,7 +71,7 @@ class RemoteProxyCaller extends module_1.Module {
|
|
|
53
71
|
return this.executeRequest(proxyRequest);
|
|
54
72
|
});
|
|
55
73
|
this.executeRequest = (proxyRequest) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const response = yield promisify_request_1.promisifyRequest(proxyRequest);
|
|
74
|
+
const response = yield (0, promisify_request_1.promisifyRequest)(proxyRequest);
|
|
57
75
|
if (proxyRequest.headers) {
|
|
58
76
|
delete proxyRequest.headers[this.config.secretHeaderName];
|
|
59
77
|
delete proxyRequest.headers["Authorization"];
|
|
@@ -63,9 +81,9 @@ class RemoteProxyCaller extends module_1.Module {
|
|
|
63
81
|
if (statusCode < 200 || statusCode >= 300) {
|
|
64
82
|
const errorResponse = response.data;
|
|
65
83
|
if (!errorResponse)
|
|
66
|
-
throw new
|
|
84
|
+
throw new exceptions_1.ApiException(500, `Extraneous error ${(0, ts_common_1.__stringify)(response)}, Proxy Request: ${(0, ts_common_1.__stringify)(proxyRequest, true)}`);
|
|
67
85
|
const debugMessage = typeof errorResponse === 'object' ? errorResponse['debugMessage'] : errorResponse;
|
|
68
|
-
const e = new
|
|
86
|
+
const e = new exceptions_1.ApiException(response.status, `Redirect proxy error: ${debugMessage} \n Proxy Request: ${(0, ts_common_1.__stringify)(proxyRequest, true)}`);
|
|
69
87
|
if (errorResponse.error)
|
|
70
88
|
e.setErrorBody(errorResponse.error);
|
|
71
89
|
throw e;
|
|
@@ -75,13 +93,13 @@ class RemoteProxyCaller extends module_1.Module {
|
|
|
75
93
|
}
|
|
76
94
|
init() {
|
|
77
95
|
if (!this.config)
|
|
78
|
-
throw new
|
|
96
|
+
throw new ts_common_1.ImplementationMissingException(`MUST specify config for ${this.getName()}`);
|
|
79
97
|
if (!this.config.proxyId)
|
|
80
|
-
throw new
|
|
98
|
+
throw new ts_common_1.ImplementationMissingException(`MUST specify the proxyId for ${this.getName()}`);
|
|
81
99
|
if (!this.config.url)
|
|
82
|
-
throw new
|
|
100
|
+
throw new ts_common_1.ImplementationMissingException(`MUST specify the url for the remote server for ${this.getName()}`);
|
|
83
101
|
if (!this.config.secret)
|
|
84
|
-
throw new
|
|
102
|
+
throw new ts_common_1.ImplementationMissingException(`MUST specify the secret for the remote server for ${this.getName()}`);
|
|
85
103
|
if (!this.config.secretHeaderName)
|
|
86
104
|
this.config.secretHeaderName = 'x-secret';
|
|
87
105
|
if (!this.config.proxyHeaderName)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteProxyCaller.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxyCaller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"RemoteProxyCaller.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxyCaller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4D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AAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAEpH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC7B,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,UAAU,CAAC;QAE9C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe;YAC5B,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,SAAS,CAAC;IAChD,CAAC;CAsFJ;AAhHD,8CAgHC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { Module, ObjectTS } from "@intuitionrobotics/ts-common";
|
|
2
3
|
import { ApiResponse, HttpRequestData, ServerApi } from "./server-api";
|
|
3
4
|
import { ApiException } from "../../exceptions";
|
|
4
5
|
import { Express, ExpressRequest, ExpressRequestHandler } from "../../utils/types";
|
|
5
|
-
|
|
6
|
-
import { Module } from '@intuitionrobotics/ts-common/core/module';
|
|
7
|
-
declare type ConfigType = {
|
|
6
|
+
type ConfigType = {
|
|
8
7
|
port: number;
|
|
9
8
|
baseUrl: string;
|
|
10
9
|
cors: {
|
|
@@ -19,9 +18,9 @@ declare type ConfigType = {
|
|
|
19
18
|
};
|
|
20
19
|
bodyParserLimit: number | string;
|
|
21
20
|
};
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
|
|
21
|
+
export type HttpErrorHandler = (requestData: HttpRequestData, error: ApiException) => Promise<string>;
|
|
22
|
+
export type ServerApi_Middleware = (request: ExpressRequest, data: HttpRequestData, response: ApiResponse, scopes: string[]) => Promise<ObjectTS | void>;
|
|
23
|
+
type HttpRoute = {
|
|
25
24
|
methods: string[];
|
|
26
25
|
path: string;
|
|
27
26
|
};
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Thunderstorm is a full web app framework!
|
|
4
|
+
*
|
|
5
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
6
|
+
* Typescript & React frontend infrastructure
|
|
7
|
+
*
|
|
8
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
2
22
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
23
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
24
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,15 +30,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
30
|
};
|
|
11
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
32
|
exports.HeaderKey = exports.RouteResolver = exports.HttpServer_Class = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* Module dependencies.
|
|
35
|
+
*/
|
|
13
36
|
const compression = require("compression");
|
|
14
37
|
const fs = require("fs");
|
|
38
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
15
39
|
const server_api_1 = require("./server-api");
|
|
16
40
|
const exceptions_1 = require("../../exceptions");
|
|
17
41
|
const express = require("express");
|
|
18
42
|
const server_errors_1 = require("./server-errors");
|
|
19
|
-
const
|
|
20
|
-
const types_1 = require("@intuitionrobotics/ts-common/core/logger/types");
|
|
21
|
-
const consts_1 = require("../../../shared/consts");
|
|
43
|
+
const _imports_1 = require("../_imports");
|
|
22
44
|
const ALL_Methods = [
|
|
23
45
|
'GET',
|
|
24
46
|
'PUT',
|
|
@@ -34,13 +56,13 @@ const DefaultHeaders = [
|
|
|
34
56
|
'authorization'
|
|
35
57
|
];
|
|
36
58
|
const ExposedHeaders = [
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
_imports_1.HeaderKey_FunctionExecutionId,
|
|
60
|
+
_imports_1.HeaderKey_JWT
|
|
39
61
|
];
|
|
40
|
-
class HttpServer_Class extends
|
|
62
|
+
class HttpServer_Class extends ts_common_1.Module {
|
|
41
63
|
constructor(_express) {
|
|
42
64
|
super("HttpServer");
|
|
43
|
-
this.errorMessageComposer = server_errors_1.DefaultApiErrorMessageComposer();
|
|
65
|
+
this.errorMessageComposer = (0, server_errors_1.DefaultApiErrorMessageComposer)();
|
|
44
66
|
this.express = _express;
|
|
45
67
|
}
|
|
46
68
|
setErrorMessageComposer(errorMessageComposer) {
|
|
@@ -58,7 +80,7 @@ class HttpServer_Class extends module_1.Module {
|
|
|
58
80
|
}
|
|
59
81
|
init() {
|
|
60
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
this.setMinLevel(server_api_1.ServerApi.isDebug ?
|
|
83
|
+
this.setMinLevel(server_api_1.ServerApi.isDebug ? ts_common_1.LogLevel.Verbose : ts_common_1.LogLevel.Info);
|
|
62
84
|
const baseUrl = this.config.baseUrl;
|
|
63
85
|
if (baseUrl) {
|
|
64
86
|
if (baseUrl.endsWith("/"))
|
|
@@ -82,7 +104,7 @@ class HttpServer_Class extends module_1.Module {
|
|
|
82
104
|
cors.exposedHeaders = ExposedHeaders;
|
|
83
105
|
cors.headers = DefaultHeaders.reduce((toRet, item) => {
|
|
84
106
|
if (!toRet.includes(item))
|
|
85
|
-
|
|
107
|
+
(0, ts_common_1.addItemToArray)(toRet, item);
|
|
86
108
|
return toRet;
|
|
87
109
|
}, cors.headers || []);
|
|
88
110
|
const resolveCorsOrigin = (origin) => {
|
|
@@ -147,7 +169,7 @@ class HttpServer_Class extends module_1.Module {
|
|
|
147
169
|
const routes = resolveRoutes(this.express._router.stack);
|
|
148
170
|
this.routes = routes.reduce((toRet, route) => {
|
|
149
171
|
const toAdd = Array.isArray(route) ? route : [route];
|
|
150
|
-
|
|
172
|
+
(0, ts_common_1.addAllItemToArray)(toRet, toAdd);
|
|
151
173
|
return toRet;
|
|
152
174
|
}, []);
|
|
153
175
|
console.timeEnd('Resolving Apis');
|