@intuitionrobotics/thunderstorm 0.44.16 → 0.45.1
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.js +27 -9
- package/app-backend/core/Storm.js.map +1 -1
- package/app-backend/exceptions.d.ts +2 -2
- package/app-backend/exceptions.js +22 -2
- package/app-backend/exceptions.js.map +1 -1
- package/app-backend/modules/CleanupScheduler.js +4 -5
- package/app-backend/modules/CleanupScheduler.js.map +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.d.ts +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.js +9 -23
- package/app-backend/modules/FirestoreBackupScheduler.js.map +1 -1
- package/app-backend/modules/ForceUpgrade.d.ts +1 -1
- package/app-backend/modules/ForceUpgrade.js +26 -8
- package/app-backend/modules/ForceUpgrade.js.map +1 -1
- package/app-backend/modules/SlackModule.d.ts +4 -2
- package/app-backend/modules/SlackModule.js +30 -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 +43 -0
- package/app-backend/modules/_imports.js.map +1 -0
- package/app-backend/modules/http/AxiosHttpModule.js +23 -3
- package/app-backend/modules/http/AxiosHttpModule.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxy.d.ts +1 -2
- 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 +1 -1
- package/app-backend/modules/proxy/RemoteProxyCaller.js +29 -11
- package/app-backend/modules/proxy/RemoteProxyCaller.js.map +1 -1
- package/app-backend/modules/server/HttpServer.d.ts +1 -2
- package/app-backend/modules/server/HttpServer.js +31 -9
- package/app-backend/modules/server/HttpServer.js.map +1 -1
- package/app-backend/modules/server/server-api.d.ts +1 -3
- package/app-backend/modules/server/server-api.js +25 -27
- package/app-backend/modules/server/server-api.js.map +1 -1
- package/app-backend/modules/server/server-errors.d.ts +1 -1
- 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 +22 -2
- package/app-backend/utils/promisify-request.js.map +1 -1
- package/app-backend/utils/to-be-removed.js +20 -0
- package/app-backend/utils/to-be-removed.js.map +1 -1
- package/app-backend/utils/types.d.ts +1 -1
- 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.js +24 -5
- package/app-frontend/components/DropDown.js.map +1 -1
- package/app-frontend/components/FilterInput.js +23 -4
- package/app-frontend/components/FilterInput.js.map +1 -1
- package/app-frontend/components/GenericSelect.js +20 -0
- 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.js +20 -0
- package/app-frontend/components/Overlay.js.map +1 -1
- 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 +1 -1
- 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.js +20 -0
- package/app-frontend/components/TS_TextArea.js.map +1 -1
- package/app-frontend/components/adapter/Adapter.js +26 -6
- package/app-frontend/components/adapter/Adapter.js.map +1 -1
- 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 +2 -2
- 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.js +18 -0
- package/app-frontend/components/checkbox/TS_CheckboxField.js.map +1 -1
- package/app-frontend/components/form/Form.d.ts +1 -2
- 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 +1 -2
- package/app-frontend/components/form/types.js +20 -0
- package/app-frontend/components/form/types.js.map +1 -1
- package/app-frontend/components/playground/Example_NewProps.js +20 -0
- package/app-frontend/components/playground/Example_NewProps.js.map +1 -1
- package/app-frontend/components/playground/Playground.js +21 -1
- package/app-frontend/components/playground/Playground.js.map +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.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.js +23 -3
- package/app-frontend/components/tree/Tree.js.map +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.js +20 -0
- package/app-frontend/components/types.js.map +1 -1
- package/app-frontend/core/AbstractThunder.d.ts +3 -0
- package/app-frontend/core/AbstractThunder.js +32 -0
- package/app-frontend/core/AbstractThunder.js.map +1 -1
- package/app-frontend/core/AppPage.js +20 -0
- package/app-frontend/core/AppPage.js.map +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 +4 -2
- package/app-frontend/core/BaseComponent.js +41 -18
- package/app-frontend/core/BaseComponent.js.map +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 +22 -3
- package/app-frontend/core/Thunder.js.map +1 -1
- package/app-frontend/core/thunder-dispatcher.d.ts +1 -2
- package/app-frontend/core/thunder-dispatcher.js +23 -13
- 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 +2 -2
- package/app-frontend/modules/ConnectivityModule.js.map +1 -1
- package/app-frontend/modules/ForceUpgrade.d.ts +1 -1
- package/app-frontend/modules/ForceUpgrade.js +23 -4
- package/app-frontend/modules/ForceUpgrade.js.map +1 -1
- package/app-frontend/modules/HistoryModule.d.ts +5 -3
- package/app-frontend/modules/HistoryModule.js +28 -9
- package/app-frontend/modules/HistoryModule.js.map +1 -1
- package/app-frontend/modules/ResourcesModule.d.ts +4 -1
- package/app-frontend/modules/ResourcesModule.js +25 -2
- package/app-frontend/modules/ResourcesModule.js.map +1 -1
- package/app-frontend/modules/StorageModule.d.ts +4 -1
- package/app-frontend/modules/StorageModule.js +26 -4
- package/app-frontend/modules/StorageModule.js.map +1 -1
- package/app-frontend/modules/ThunderstormModule.d.ts +1 -1
- package/app-frontend/modules/ThunderstormModule.js +3 -3
- package/app-frontend/modules/ThunderstormModule.js.map +1 -1
- 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.js +22 -0
- package/app-frontend/modules/dialog/Dialog.js.map +1 -1
- package/app-frontend/modules/dialog/DialogModule.d.ts +1 -1
- package/app-frontend/modules/dialog/DialogModule.js +22 -2
- 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.js +10 -9
- package/app-frontend/modules/http/XhrHttpModule.js.map +1 -1
- package/app-frontend/modules/locale/LocaleModule.d.ts +4 -1
- package/app-frontend/modules/locale/LocaleModule.js +24 -5
- package/app-frontend/modules/locale/LocaleModule.js.map +1 -1
- package/app-frontend/modules/locale/types.d.ts +3 -0
- package/app-frontend/modules/locale/types.js +20 -0
- package/app-frontend/modules/locale/types.js.map +1 -1
- package/app-frontend/modules/menu/MenuAndButton.js +2 -2
- package/app-frontend/modules/menu/MenuAndButton.js.map +1 -1
- package/app-frontend/modules/menu/MenuModule.d.ts +1 -1
- package/app-frontend/modules/menu/MenuModule.js +3 -4
- package/app-frontend/modules/menu/MenuModule.js.map +1 -1
- package/app-frontend/modules/menu/PopupMenu.js +2 -2
- package/app-frontend/modules/menu/PopupMenu.js.map +1 -1
- package/app-frontend/modules/routing/RoutingModule.d.ts +1 -1
- 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.js +20 -0
- package/app-frontend/modules/routing/route.js.map +1 -1
- 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 +1 -1
- package/app-frontend/modules/toaster/ToasterModule.js +25 -5
- package/app-frontend/modules/toaster/ToasterModule.js.map +1 -1
- 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 +1 -1
- package/app-frontend/modules/tooltip/TooltipModule.js +23 -4
- package/app-frontend/modules/tooltip/TooltipModule.js.map +1 -1
- package/app-frontend/tools/KeyboardListener.js +17 -0
- package/app-frontend/tools/KeyboardListener.js.map +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 +20 -0
- 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/backend-test.d.ts +1 -0
- package/backend-test.js +34 -0
- package/backend-test.js.map +1 -0
- package/backend.d.ts +17 -0
- package/backend.js +50 -0
- package/backend.js.map +1 -0
- package/frontend.d.ts +55 -0
- package/frontend.js +88 -0
- package/frontend.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.js +37 -0
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/shared/BaseHttpModule.d.ts +1 -1
- package/shared/BaseHttpModule.js +5 -6
- package/shared/BaseHttpModule.js.map +1 -1
- package/shared/BaseHttpRequest.js +27 -9
- package/shared/BaseHttpRequest.js.map +1 -1
- package/shared/consts.js +20 -0
- package/shared/consts.js.map +1 -1
- package/shared/force-upgrade.js +20 -0
- package/shared/force-upgrade.js.map +1 -1
- package/shared/request-types.js +20 -0
- package/shared/request-types.js.map +1 -1
- package/shared/types.js +20 -0
- package/shared/types.js.map +1 -1
- package/test-backend/StormTester.js +26 -6
- package/test-backend/StormTester.js.map +1 -1
- package/test-frontend/ThunderTester.js +20 -0
- package/test-frontend/ThunderTester.js.map +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
__exportStar(require("./server/server-api"), exports);
|
|
34
|
+
__exportStar(require("./server/HttpServer"), exports);
|
|
35
|
+
__exportStar(require("./proxy/RemoteProxyCaller"), exports);
|
|
36
|
+
__exportStar(require("./proxy/RemoteProxy"), exports);
|
|
37
|
+
__exportStar(require("../exceptions"), exports);
|
|
38
|
+
__exportStar(require("../utils/promisify-request"), exports);
|
|
39
|
+
__exportStar(require("../utils/to-be-removed"), exports);
|
|
40
|
+
__exportStar(require("./CleanupScheduler"), exports);
|
|
41
|
+
__exportStar(require("./FirestoreBackupScheduler"), exports);
|
|
42
|
+
__exportStar(require("../../index"), exports);
|
|
43
|
+
//# 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"}
|
|
@@ -10,10 +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.AxiosHttpModule = exports.AxiosHttpModule_Class = void 0;
|
|
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 Alan Ben
|
|
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
|
+
*/
|
|
13
33
|
// noinspection TypeScriptPreferShortImport
|
|
14
34
|
const axios_1 = require("axios");
|
|
15
35
|
const types_1 = require("../../../shared/types");
|
|
16
|
-
const
|
|
36
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
17
37
|
const BaseHttpRequest_1 = require("../../../shared/BaseHttpRequest");
|
|
18
38
|
const BaseHttpModule_1 = require("../../../shared/BaseHttpModule");
|
|
19
39
|
const fs = require("fs");
|
|
@@ -68,7 +88,7 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
68
88
|
}
|
|
69
89
|
getStatus() {
|
|
70
90
|
if (!this.status)
|
|
71
|
-
throw new
|
|
91
|
+
throw new ts_common_1.BadImplementationException('Missing status..');
|
|
72
92
|
return this.status;
|
|
73
93
|
}
|
|
74
94
|
getResponse() {
|
|
@@ -156,7 +176,7 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
156
176
|
}
|
|
157
177
|
getResponseHeader(headerKey) {
|
|
158
178
|
if (!this.response)
|
|
159
|
-
throw new
|
|
179
|
+
throw new ts_common_1.BadImplementationException(`axios didn't return yet`);
|
|
160
180
|
return this.response.headers[headerKey];
|
|
161
181
|
}
|
|
162
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosHttpModule.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/http/AxiosHttpModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,iCAA0B;AAC1B,iDAAoH;AACpH,
|
|
1
|
+
{"version":3,"file":"AxiosHttpModule.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/http/AxiosHttpModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2CAA2C;AAC3C,iCAA0B;AAC1B,iDAAoH;AACpH,4DAAoF;AACpF,qEAAgE;AAChE,mEAAo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BACnB,+EAA+E;oBAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;oBACpB,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;iBAC7C;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;aACpB;QACL,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;IAED,iBAAiB,CAAC,SAAiB;QAC/B,IAAI,CAAC,IAAI,CAAC,QAAQ;YACd,MAAM,IAAI,sCAA0B,CAAC,yBAAyB,CAAC,CAAC;QAEpE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;CACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
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";
|
|
@@ -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,OAA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
|
2
2
|
import { DeriveBodyType, DeriveQueryType, DeriveResponseType, DeriveUrlType, QueryParams } from "../../../shared/types";
|
|
3
3
|
import { AxiosResponse } from "axios";
|
|
4
4
|
export declare type RemoteServerConfig = {
|
|
@@ -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);
|
|
@@ -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 ${ts_common_1.__stringify(response)}, Proxy Request: ${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: ${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 module!!");
|
|
79
97
|
if (!this.config.proxyId)
|
|
80
|
-
throw new
|
|
98
|
+
throw new ts_common_1.ImplementationMissingException("MUST specify the proxyId for the proxy caller!!");
|
|
81
99
|
if (!this.config.url)
|
|
82
|
-
throw new
|
|
100
|
+
throw new ts_common_1.ImplementationMissingException("MUST specify the url for the remote server!!");
|
|
83
101
|
if (!this.config.secret)
|
|
84
|
-
throw new
|
|
102
|
+
throw new ts_common_1.ImplementationMissingException("MUST specify the secret for the remote server!!");
|
|
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
|
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CAA8B,CAAC,iDAAiD,CAAC,CAAC;QAEhG,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,9 +1,8 @@
|
|
|
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
|
-
import { ObjectTS } from '@intuitionrobotics/ts-common/utils/types';
|
|
6
|
-
import { Module } from '@intuitionrobotics/ts-common/core/module';
|
|
7
6
|
declare type ConfigType = {
|
|
8
7
|
port: number;
|
|
9
8
|
baseUrl: string;
|
|
@@ -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,10 +56,10 @@ 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
65
|
this.errorMessageComposer = server_errors_1.DefaultApiErrorMessageComposer();
|
|
@@ -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
|
+
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
|
+
ts_common_1.addAllItemToArray(toRet, toAdd);
|
|
151
173
|
return toRet;
|
|
152
174
|
}, []);
|
|
153
175
|
console.timeEnd('Resolving Apis');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpServer.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/server/HttpServer.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"HttpServer.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/server/HttpServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;AAEH;;G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GAAG,YAAY,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,OAAuB;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK;YACN,MAAM,IAAI,yBAAY,CAAC,IAAI,CAAC,YAAY,EAAE,4BAA4B,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAEtF,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAhBD,8BAgBC"}
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Created by tacb0ss on 11/07/2018.
|
|
4
4
|
*/
|
|
5
|
+
import { Logger, ObjectTS, ValidatorTypeResolver } from "@intuitionrobotics/ts-common";
|
|
5
6
|
import { Stream } from "stream";
|
|
6
7
|
import { ServerApi_Middleware } from "./HttpServer";
|
|
7
8
|
import { IncomingHttpHeaders } from "http";
|
|
8
9
|
import { ApiTypeBinder, ApiWithBody, ApiWithQuery, DeriveBodyType, DeriveQueryType, DeriveResponseType, DeriveUrlType, HttpMethod, QueryParams } from "../../../shared/types";
|
|
9
10
|
import { ApiException } from "../../exceptions";
|
|
10
11
|
import { ExpressRequest, ExpressResponse, ExpressRouter } from "../../utils/types";
|
|
11
|
-
import { Logger } from "@intuitionrobotics/ts-common/core/logger/Logger";
|
|
12
|
-
import { ValidatorTypeResolver } from "@intuitionrobotics/ts-common/validator/validator";
|
|
13
|
-
import { ObjectTS } from "@intuitionrobotics/ts-common/utils/types";
|
|
14
12
|
export declare type HttpRequestData = {
|
|
15
13
|
originalUrl: string;
|
|
16
14
|
headers: IncomingHttpHeaders;
|
|
@@ -30,20 +30,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.ApiResponse = exports.ServerApi_Redirect = exports.ServerApi_Proxy = exports.ServerApi_Post = exports.ServerApi_Get = exports.ServerApi = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* Created by tacb0ss on 11/07/2018.
|
|
35
|
+
*/
|
|
36
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
33
37
|
const url_1 = require("url");
|
|
38
|
+
// noinspection TypeScriptPreferShortImport
|
|
34
39
|
const types_1 = require("../../../shared/types");
|
|
35
40
|
const to_be_removed_1 = require("../../utils/to-be-removed");
|
|
36
41
|
const exceptions_1 = require("../../exceptions");
|
|
37
42
|
const RemoteProxy_1 = require("../proxy/RemoteProxy");
|
|
38
43
|
const Storm_1 = require("../../core/Storm");
|
|
39
|
-
|
|
40
|
-
const validator_1 = require("@intuitionrobotics/ts-common/validator/validator");
|
|
41
|
-
const types_2 = require("@intuitionrobotics/ts-common/core/logger/types");
|
|
42
|
-
const error_handling_1 = require("@intuitionrobotics/ts-common/core/error-handling");
|
|
43
|
-
const exceptions_2 = require("@intuitionrobotics/ts-common/core/exceptions");
|
|
44
|
-
const merge_tools_1 = require("@intuitionrobotics/ts-common/utils/merge-tools");
|
|
45
|
-
const object_tools_1 = require("@intuitionrobotics/ts-common/utils/object-tools");
|
|
46
|
-
class ServerApi extends Logger_1.Logger {
|
|
44
|
+
class ServerApi extends ts_common_1.Logger {
|
|
47
45
|
constructor(method, relativePath, tag) {
|
|
48
46
|
super(tag || relativePath);
|
|
49
47
|
this.printResponse = true;
|
|
@@ -98,8 +96,8 @@ class ServerApi extends Logger_1.Logger {
|
|
|
98
96
|
body: body
|
|
99
97
|
};
|
|
100
98
|
try {
|
|
101
|
-
this.bodyValidator &&
|
|
102
|
-
this.queryValidator &&
|
|
99
|
+
this.bodyValidator && ts_common_1.validate(body, this.bodyValidator);
|
|
100
|
+
this.queryValidator && ts_common_1.validate(reqQuery, this.queryValidator);
|
|
103
101
|
const context = yield this.applyMiddlewares(req, requestData, response, this.scopes);
|
|
104
102
|
const toReturn = yield this.process(req, response, reqQuery, body, context);
|
|
105
103
|
if (response.isConsumed())
|
|
@@ -118,11 +116,11 @@ class ServerApi extends Logger_1.Logger {
|
|
|
118
116
|
}
|
|
119
117
|
catch (err) {
|
|
120
118
|
let e = err;
|
|
121
|
-
let severity =
|
|
119
|
+
let severity = ts_common_1.ServerErrorSeverity.Warning;
|
|
122
120
|
if (typeof e === "string")
|
|
123
|
-
e = new
|
|
121
|
+
e = new ts_common_1.BadImplementationException(`String was thrown: ${e}`);
|
|
124
122
|
if (!(e instanceof Error) && typeof e === "object")
|
|
125
|
-
e = new
|
|
123
|
+
e = new ts_common_1.BadImplementationException(`Object instance was thrown: ${JSON.stringify(e)}`);
|
|
126
124
|
try {
|
|
127
125
|
this.logErrorBold(e);
|
|
128
126
|
}
|
|
@@ -131,36 +129,36 @@ class ServerApi extends Logger_1.Logger {
|
|
|
131
129
|
this.logErrorBold(`Original error thrown: ${JSON.stringify(e)}`);
|
|
132
130
|
this.logErrorBold(`-- Someone was stupid... you MUST only throw an Error and not objects or strings!! --`);
|
|
133
131
|
}
|
|
134
|
-
if (
|
|
132
|
+
if (ts_common_1.isErrorOfType(e, ts_common_1.ValidationException))
|
|
135
133
|
e = new exceptions_1.ApiException(400, "Validator exception", e);
|
|
136
|
-
if (!
|
|
134
|
+
if (!ts_common_1.isErrorOfType(e, exceptions_1.ApiException))
|
|
137
135
|
e = new exceptions_1.ApiException(500, "Unexpected server error", e);
|
|
138
|
-
const apiException =
|
|
136
|
+
const apiException = ts_common_1.isErrorOfType(e, exceptions_1.ApiException);
|
|
139
137
|
if (!apiException)
|
|
140
|
-
throw new
|
|
138
|
+
throw new ts_common_1.MUSTNeverHappenException("MUST NEVER REACH HERE!!!");
|
|
141
139
|
if (apiException.responseCode >= 500)
|
|
142
|
-
severity =
|
|
140
|
+
severity = ts_common_1.ServerErrorSeverity.Error;
|
|
143
141
|
else if (apiException.responseCode >= 400)
|
|
144
|
-
severity =
|
|
142
|
+
severity = ts_common_1.ServerErrorSeverity.Warning;
|
|
145
143
|
switch (apiException.responseCode) {
|
|
146
144
|
case 401:
|
|
147
|
-
severity =
|
|
145
|
+
severity = ts_common_1.ServerErrorSeverity.Debug;
|
|
148
146
|
break;
|
|
149
147
|
case 404:
|
|
150
|
-
severity =
|
|
148
|
+
severity = ts_common_1.ServerErrorSeverity.Info;
|
|
151
149
|
break;
|
|
152
150
|
case 403:
|
|
153
|
-
severity =
|
|
151
|
+
severity = ts_common_1.ServerErrorSeverity.Warning;
|
|
154
152
|
break;
|
|
155
153
|
case 500:
|
|
156
|
-
severity =
|
|
154
|
+
severity = ts_common_1.ServerErrorSeverity.Critical;
|
|
157
155
|
break;
|
|
158
156
|
}
|
|
159
157
|
try {
|
|
160
158
|
const httpServer = (_a = Storm_1.Storm.getInstance()) === null || _a === void 0 ? void 0 : _a.getHttpServer();
|
|
161
159
|
if (httpServer) {
|
|
162
160
|
const message = yield httpServer.errorMessageComposer(requestData, apiException);
|
|
163
|
-
yield
|
|
161
|
+
yield ts_common_1.dispatch_onServerError.dispatchModuleAsync([
|
|
164
162
|
severity,
|
|
165
163
|
httpServer,
|
|
166
164
|
message
|
|
@@ -175,7 +173,7 @@ class ServerApi extends Logger_1.Logger {
|
|
|
175
173
|
return response.exception(apiException);
|
|
176
174
|
}
|
|
177
175
|
});
|
|
178
|
-
this.setMinLevel(ServerApi.isDebug ?
|
|
176
|
+
this.setMinLevel(ServerApi.isDebug ? ts_common_1.LogLevel.Verbose : ts_common_1.LogLevel.Info);
|
|
179
177
|
this.method = method;
|
|
180
178
|
this.relativePath = `${relativePath}`;
|
|
181
179
|
}
|
|
@@ -235,7 +233,7 @@ class ServerApi extends Logger_1.Logger {
|
|
|
235
233
|
if (!this.middlewares)
|
|
236
234
|
return {};
|
|
237
235
|
const contextList = yield Promise.all(this.middlewares.map((m) => __awaiter(this, void 0, void 0, function* () { return m(req, requestData, response, scopes); })));
|
|
238
|
-
return contextList.reduce((acc, c) =>
|
|
236
|
+
return contextList.reduce((acc, c) => ts_common_1.merge(acc, c || {}), {});
|
|
239
237
|
});
|
|
240
238
|
}
|
|
241
239
|
}
|
|
@@ -274,7 +272,7 @@ class ServerApi_Redirect extends ServerApi {
|
|
|
274
272
|
}
|
|
275
273
|
process(request, response, queryParams, body) {
|
|
276
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
const query = queryParams ?
|
|
275
|
+
const query = queryParams ? ts_common_1._keys(queryParams).reduce((c, k) => c + '&' + k + '=' + queryParams[k], '?') : '';
|
|
278
276
|
response.redirect(this.responseCode, `${this.baseUrl}${this.redirectUrl}${query}`);
|
|
279
277
|
});
|
|
280
278
|
}
|