@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,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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
const HttpServer_1 = require("../../../../modules/server/HttpServer");
|
|
4
24
|
module.exports = new HttpServer_1.RouteResolver(require, __dirname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_assert.js","sourceRoot":"","sources":["../../../../../../src/main/app-backend/api/v1/utils/version/_assert.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"_assert.js","sourceRoot":"","sources":["../../../../../../src/main/app-backend/api/v1/utils/version/_assert.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAEH,sEAAoE;AAEpE,MAAM,CAAC,OAAO,GAAG,IAAI,0BAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -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) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../../../../src/main/app-backend/api/v1/utils/version/assert.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../../../../src/main/app-backend/api/v1/utils/version/assert.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;AAGH,uEAI6C;AAC7C,sEAG+C;AAC/C,uDAAuD;AACvD,mEAA+D;AAI/D,MAAM,0BACL,SAAQ,sBAAqC;IAE7C;QACC,KAAK,CAAC,kBAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAChC,IAAI,CAAC,cAAc,CAAC,yCAAyB,EAAE,sCAAsB,CAAC,CAAC;IACxE,CAAC;IAEe,OAAO,CAAC,OAAuB,EAAE,QAAqB,EAAE,WAAe,EAAE,IAAU;;YAClG,OAAO,2BAAY,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;KAAA;CACD;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,8 +1,28 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.BaseStorm = void 0;
|
|
4
|
-
const
|
|
5
|
-
class BaseStorm extends
|
|
24
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
25
|
+
class BaseStorm extends ts_common_1.ModuleManager {
|
|
6
26
|
constructor() {
|
|
7
27
|
super(...arguments);
|
|
8
28
|
this.envKey = "dev";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseStorm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/BaseStorm.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BaseStorm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/BaseStorm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,4DAA2D;AAE3D,MAAsB,SAClB,SAAQ,yBAAa;IADzB;;QAEY,WAAM,GAAW,KAAK,CAAC;IASnC,CAAC;IARG,cAAc,CAAC,MAAc;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;AAXD,8BAWC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogClient } from "@intuitionrobotics/ts-common";
|
|
1
2
|
import { HttpServer_Class, RouteResolver } from "../modules/server/HttpServer";
|
|
2
3
|
import { ServerApi } from "../modules/server/server-api";
|
|
3
4
|
import { BaseStorm } from "./BaseStorm";
|
|
@@ -9,7 +10,13 @@ export declare class Storm extends BaseStorm {
|
|
|
9
10
|
private apis;
|
|
10
11
|
private readonly express;
|
|
11
12
|
private readonly httpServer;
|
|
13
|
+
private logClient;
|
|
14
|
+
private onDestroy?;
|
|
15
|
+
private readonly executionId;
|
|
12
16
|
constructor(_express?: Express);
|
|
17
|
+
getExecutionId(): string;
|
|
18
|
+
setLogClient(logClient: LogClient): this;
|
|
19
|
+
setOnDestroy(onDestroy?: () => Promise<void>): this;
|
|
13
20
|
static getInstance(): Storm;
|
|
14
21
|
getHttpServer(): HttpServer_Class;
|
|
15
22
|
init(): this;
|
|
@@ -1,11 +1,29 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.Storm = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const LogClient_Terminal_1 = require("@intuitionrobotics/ts-common/core/logger/LogClient_Terminal");
|
|
8
|
-
const firebase_function_1 = require("@intuitionrobotics/firebase/app-backend/functions/firebase-function");
|
|
24
|
+
const backend_1 = require("@intuitionrobotics/firebase/backend");
|
|
25
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
26
|
+
const backend_functions_1 = require("@intuitionrobotics/firebase/backend-functions");
|
|
9
27
|
const HttpServer_1 = require("../modules/server/HttpServer");
|
|
10
28
|
const server_api_1 = require("../modules/server/server-api");
|
|
11
29
|
const BaseStorm_1 = require("./BaseStorm");
|
|
@@ -15,9 +33,22 @@ class Storm extends BaseStorm_1.BaseStorm {
|
|
|
15
33
|
super();
|
|
16
34
|
this.functions = [];
|
|
17
35
|
this.apis = [];
|
|
36
|
+
this.logClient = ts_common_1.LogClient_Function;
|
|
18
37
|
this.express = _express || express();
|
|
19
38
|
this.httpServer = new HttpServer_1.HttpServer_Class(this.express);
|
|
20
|
-
this.addModules(this.httpServer,
|
|
39
|
+
this.addModules(this.httpServer, backend_1.FirebaseModule);
|
|
40
|
+
this.executionId = (0, ts_common_1.generateHex)(32);
|
|
41
|
+
}
|
|
42
|
+
getExecutionId() {
|
|
43
|
+
return this.executionId;
|
|
44
|
+
}
|
|
45
|
+
setLogClient(logClient) {
|
|
46
|
+
this.logClient = logClient;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
setOnDestroy(onDestroy) {
|
|
50
|
+
this.onDestroy = onDestroy;
|
|
51
|
+
return this;
|
|
21
52
|
}
|
|
22
53
|
static getInstance() {
|
|
23
54
|
return Storm.instance;
|
|
@@ -27,7 +58,7 @@ class Storm extends BaseStorm_1.BaseStorm {
|
|
|
27
58
|
}
|
|
28
59
|
init() {
|
|
29
60
|
var _a;
|
|
30
|
-
|
|
61
|
+
ts_common_1.BeLogged.addClient(process.env.GCLOUD_PROJECT && process.env.FUNCTIONS_EMULATOR ? ts_common_1.LogClient_Terminal : this.logClient);
|
|
31
62
|
server_api_1.ServerApi.isDebug = !!((_a = this.config) === null || _a === void 0 ? void 0 : _a.isDebug);
|
|
32
63
|
super.init();
|
|
33
64
|
const urlPrefix = !process.env.GCLOUD_PROJECT ? this.initialPath : "";
|
|
@@ -48,8 +79,14 @@ class Storm extends BaseStorm_1.BaseStorm {
|
|
|
48
79
|
return this;
|
|
49
80
|
}
|
|
50
81
|
startServer(onStarted) {
|
|
51
|
-
const modulesAsFunction = this.modules.filter((module) => module instanceof
|
|
52
|
-
|
|
82
|
+
const modulesAsFunction = this.modules.filter((module) => module instanceof backend_functions_1.FirebaseFunction);
|
|
83
|
+
const firebaseExpressFunction = new backend_functions_1.Firebase_ExpressFunction(this.httpServer.express);
|
|
84
|
+
const _onDestroy = this.onDestroy;
|
|
85
|
+
if (_onDestroy) {
|
|
86
|
+
modulesAsFunction.forEach(func => func.addOnDestroy(_onDestroy));
|
|
87
|
+
firebaseExpressFunction.addOnDestroy(_onDestroy);
|
|
88
|
+
}
|
|
89
|
+
this.functions = [firebaseExpressFunction,
|
|
53
90
|
...modulesAsFunction];
|
|
54
91
|
this.init();
|
|
55
92
|
onStarted && onStarted().catch(e => this.logError(e));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/Storm.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Storm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/Storm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,iEAAmE;AACnE,4DAOsC;AACtC,qFAAyG;AACzG,6DAA6E;AAC7E,6DAAuD;AACvD,2CAAsC;AAEtC,mCAAmC;AAEnC,MAAa,KACT,SAAQ,qBAAS;IAWjB,YAAY,QAAkB;QAC1B,KAAK,EAAE,CAAC;QATJ,cAAS,GAAU,EAAE,CAAC;QACtB,SAAI,GAAqB,EAAE,CAAC;QAG5B,cAAS,GAAc,8BAAkB,CAAC;QAM9C,IAAI,CAAC,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,6BAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,wBAAc,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,IAAA,uBAAW,EAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEM,YAAY,CAAC,SAAoB;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS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}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CustomException } from "@intuitionrobotics/ts-common
|
|
2
|
-
import { ErrorBody, ErrorResponse } from "../
|
|
1
|
+
import { CustomException } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { ErrorBody, ErrorResponse } from "../index";
|
|
3
3
|
export declare class ApiException<E extends object | void = void> extends CustomException {
|
|
4
4
|
readonly responseBody: ErrorResponse<E>;
|
|
5
5
|
readonly responseCode: number;
|
|
6
6
|
readonly setErrorBody: (errorBody: ErrorBody<E>) => this;
|
|
7
|
-
constructor(responseCode: number, debugMessage?: string, cause?:
|
|
7
|
+
constructor(responseCode: number, debugMessage?: string, cause?: any);
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiException = void 0;
|
|
4
|
-
const
|
|
5
|
-
class ApiException extends
|
|
4
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
5
|
+
class ApiException extends ts_common_1.CustomException {
|
|
6
6
|
constructor(responseCode, debugMessage, cause) {
|
|
7
7
|
super(ApiException, `${responseCode}-${JSON.stringify(debugMessage)}`, cause);
|
|
8
8
|
this.responseBody = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/main/app-backend/exceptions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/main/app-backend/exceptions.ts"],"names":[],"mappings":";;;AAAA,4DAA6D;AAM7D,MAAa,YACZ,SAAQ,2BAAe;IAUvB,YAAY,YAAoB,EAAE,YAAqB,EAAE,KAAW;QACnE,KAAK,CAAC,YAAY,EAAE,GAAG,YAAY,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAT/D,iBAAY,GAAqB,EAAE,CAAC;QAGpC,iBAAY,GAAG,CAAC,SAAuB,EAAE,EAAE;YAC1D,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;YACpC,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;QAKD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;CAED;AAlBD,oCAkBC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FirebaseScheduledFunction } from "@intuitionrobotics/firebase/app-backend/functions/firebase-function";
|
|
2
|
-
export
|
|
2
|
+
export type ActDetailsDoc = {
|
|
3
3
|
timestamp: number;
|
|
4
4
|
moduleKey: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type CleanupDetails = {
|
|
7
7
|
cleanup: () => Promise<void>;
|
|
8
8
|
interval: number;
|
|
9
9
|
moduleKey: string;
|
|
@@ -10,24 +10,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CleanupScheduler = exports.CleanupScheduler_Class = void 0;
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
13
14
|
const firebase_function_1 = require("@intuitionrobotics/firebase/app-backend/functions/firebase-function");
|
|
14
15
|
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/FirebaseModule");
|
|
15
|
-
const
|
|
16
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
17
|
-
const dispatch_onCleanupSchedulerAct = new dispatcher_1.Dispatcher("__onCleanupSchedulerAct");
|
|
16
|
+
const dispatch_onCleanupSchedulerAct = new ts_common_1.Dispatcher("__onCleanupSchedulerAct");
|
|
18
17
|
class CleanupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
19
18
|
constructor() {
|
|
20
19
|
super("CleanupScheduler");
|
|
21
20
|
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
const cleanupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('cleanup-status', ["moduleKey"]);
|
|
23
|
-
const cleanups = dispatch_onCleanupSchedulerAct.dispatchModule(
|
|
22
|
+
const cleanups = dispatch_onCleanupSchedulerAct.dispatchModule();
|
|
24
23
|
yield Promise.all(cleanups.map((cleanupItem) => __awaiter(this, void 0, void 0, function* () {
|
|
25
24
|
const doc = yield cleanupStatusCollection.queryUnique({ where: { moduleKey: cleanupItem.moduleKey } });
|
|
26
|
-
if (doc && doc.timestamp + cleanupItem.interval >
|
|
25
|
+
if (doc && doc.timestamp + cleanupItem.interval > (0, ts_common_1.currentTimeMillies)())
|
|
27
26
|
return;
|
|
28
27
|
try {
|
|
29
28
|
yield cleanupItem.cleanup();
|
|
30
|
-
yield cleanupStatusCollection.upsert({ timestamp:
|
|
29
|
+
yield cleanupStatusCollection.upsert({ timestamp: (0, ts_common_1.currentTimeMillies)(), moduleKey: cleanupItem.moduleKey });
|
|
31
30
|
}
|
|
32
31
|
catch (e) {
|
|
33
32
|
this.logWarning(`cleanup of ${cleanupItem.moduleKey} has failed with error '${e}'`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CleanupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/CleanupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CleanupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/CleanupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAGsC;AACtC,2GAA8G;AAC9G,2FAAsF;AAiBtF,MAAM,8BAA8B,GAAG,IAAI,sBAAU,CAAmD,yBAAyB,CAAC,CAAC;AAEnI,MAAa,sBACZ,SAAQ,6CAAyB;IAEjC;QACC,KAAK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
import { ActDetailsDoc } from "./CleanupScheduler";
|
|
3
3
|
import { FirestoreCollection } from "@intuitionrobotics/firebase/app-backend/firestore/FirestoreCollection";
|
|
4
|
-
import { FirestoreQuery } from "@intuitionrobotics/firebase
|
|
5
|
-
export
|
|
4
|
+
import { FirestoreQuery } from "@intuitionrobotics/firebase";
|
|
5
|
+
export type BackupDoc = ActDetailsDoc & {
|
|
6
6
|
backupPath: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type FirestoreBackupDetails<T extends object> = {
|
|
9
9
|
moduleKey: string;
|
|
10
10
|
interval: number;
|
|
11
11
|
keepInterval?: number;
|
|
@@ -10,22 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FirestoreBackupScheduler = exports.FirestoreBackupScheduler_Class = void 0;
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
13
14
|
const firebase_function_1 = require("@intuitionrobotics/firebase/app-backend/functions/firebase-function");
|
|
14
15
|
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/FirebaseModule");
|
|
15
|
-
const
|
|
16
|
-
const array_tools_1 = require("@intuitionrobotics/ts-common/utils/array-tools");
|
|
17
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
18
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
19
|
-
const utils_1 = require("@intuitionrobotics/ts-common/core/logger/utils");
|
|
20
|
-
const error_handling_1 = require("@intuitionrobotics/ts-common/core/error-handling");
|
|
21
|
-
const dispatch_onFirestoreBackupSchedulerAct = new dispatcher_1.Dispatcher("__onFirestoreBackupSchedulerAct");
|
|
16
|
+
const dispatch_onFirestoreBackupSchedulerAct = new ts_common_1.Dispatcher("__onFirestoreBackupSchedulerAct");
|
|
22
17
|
class FirestoreBackupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
23
18
|
constructor() {
|
|
24
19
|
super("FirestoreBackupScheduler");
|
|
25
20
|
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
26
21
|
const backupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('firestore-backup-status', ["moduleKey", "timestamp"]);
|
|
27
22
|
const backups = [];
|
|
28
|
-
|
|
23
|
+
(0, ts_common_1.filterInstances)(dispatch_onFirestoreBackupSchedulerAct.dispatchModule()).forEach(backupArray => {
|
|
29
24
|
backups.push(...backupArray);
|
|
30
25
|
});
|
|
31
26
|
const bucket = yield FirebaseModule_1.FirebaseModule.createAdminSession().getStorage().getOrCreateBucket();
|
|
@@ -37,25 +32,16 @@ class FirestoreBackupScheduler_Class extends firebase_function_1.FirebaseSchedul
|
|
|
37
32
|
};
|
|
38
33
|
const docs = yield backupStatusCollection.query(query);
|
|
39
34
|
const latestDoc = docs[0];
|
|
40
|
-
if (latestDoc && latestDoc.timestamp + backupItem.interval >
|
|
35
|
+
if (latestDoc && latestDoc.timestamp + backupItem.interval > (0, ts_common_1.currentTimeMillies)())
|
|
41
36
|
return;
|
|
42
|
-
const backupPath = `backup/firestore/${backupItem.moduleKey}/${
|
|
37
|
+
const backupPath = `backup/firestore/${backupItem.moduleKey}/${(0, ts_common_1.currentTimeMillies)()}.json`;
|
|
43
38
|
try {
|
|
44
39
|
const toBackupData = yield backupItem.collection.query(backupItem.backupQuery);
|
|
45
40
|
yield (yield bucket.getFile(backupPath)).write(toBackupData);
|
|
46
|
-
yield backupStatusCollection.upsert({
|
|
47
|
-
timestamp: date_time_tools_1.currentTimeMillies(),
|
|
48
|
-
moduleKey: backupItem.moduleKey,
|
|
49
|
-
backupPath
|
|
50
|
-
});
|
|
41
|
+
yield backupStatusCollection.upsert({ timestamp: (0, ts_common_1.currentTimeMillies)(), moduleKey: backupItem.moduleKey, backupPath });
|
|
51
42
|
const keepInterval = backupItem.keepInterval;
|
|
52
43
|
if (keepInterval) {
|
|
53
|
-
const queryOld = {
|
|
54
|
-
where: {
|
|
55
|
-
moduleKey: backupItem.moduleKey,
|
|
56
|
-
timestamp: { $lt: date_time_tools_1.currentTimeMillies() - keepInterval }
|
|
57
|
-
}
|
|
58
|
-
};
|
|
44
|
+
const queryOld = { where: { moduleKey: backupItem.moduleKey, timestamp: { $lt: (0, ts_common_1.currentTimeMillies)() - keepInterval } } };
|
|
59
45
|
const oldDocs = yield backupStatusCollection.query(queryOld);
|
|
60
46
|
yield Promise.all(oldDocs.map((oldDoc) => __awaiter(this, void 0, void 0, function* () {
|
|
61
47
|
yield (yield bucket.getFile(oldDoc.backupPath)).delete();
|
|
@@ -65,8 +51,8 @@ class FirestoreBackupScheduler_Class extends firebase_function_1.FirebaseSchedul
|
|
|
65
51
|
}
|
|
66
52
|
catch (e) {
|
|
67
53
|
this.logWarning(`backup of ${backupItem.moduleKey} has failed with error`, e);
|
|
68
|
-
const errorMessage = `Error backing up firestore collection config:\n ${
|
|
69
|
-
yield
|
|
54
|
+
const errorMessage = `Error backing up firestore collection config:\n ${(0, ts_common_1.__stringify)(backupItem, true)}\nError: ${(0, ts_common_1._logger_logException)(e)}`;
|
|
55
|
+
yield ts_common_1.dispatch_onServerError.dispatchModuleAsync(ts_common_1.ServerErrorSeverity.Critical, this, errorMessage);
|
|
70
56
|
}
|
|
71
57
|
})));
|
|
72
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirestoreBackupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/FirestoreBackupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2GAA8G;AAC9G,2FAAsF;
|
|
1
|
+
{"version":3,"file":"FirestoreBackupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/FirestoreBackupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAQsC;AACtC,2GAA8G;AAC9G,2FAAsF;AAqBtF,MAAM,s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AI,CAAC,YAAY,IAAA,gCAAoB,EAAC,CAAC,CAAC,EAAE,CAAC;oBAE3I,MAAM,kCAAsB,CAAC,mBAAmB,CAAC,+BAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;gBAEpG,CAAC;YACF,CAAC,CAAA,CAAC,CAAC,CAAC;QACL,CAAC,CAAA,CAAC;QAhDD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;CAgDD;AAtDD,wEAsDC;AAEY,QAAA,wBAAwB,GAAG,IAAI,8BAA8B,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
1
2
|
import { ServerApi_Middleware } from "./server/HttpServer";
|
|
2
3
|
import { UpgradeRequired } from "../../shared/force-upgrade";
|
|
3
4
|
import { PlatformName } from "../../shared/consts";
|
|
4
5
|
import { ExpressRequest } from "../utils/types";
|
|
5
|
-
|
|
6
|
-
declare type VersionConfig = {
|
|
6
|
+
type VersionConfig = {
|
|
7
7
|
[K in PlatformName]: {
|
|
8
8
|
regexp: string;
|
|
9
9
|
minimumValidVersion?: 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) {
|
|
@@ -8,20 +28,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
28
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
29
|
});
|
|
10
30
|
};
|
|
31
|
+
var _a;
|
|
11
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
33
|
exports.ForceUpgrade = void 0;
|
|
34
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
13
35
|
const HttpServer_1 = require("./server/HttpServer");
|
|
14
36
|
const exceptions_1 = require("../exceptions");
|
|
15
37
|
const force_upgrade_1 = require("../../shared/force-upgrade");
|
|
16
|
-
const module_1 = require("@intuitionrobotics/ts-common/core/module");
|
|
17
|
-
const exceptions_2 = require("@intuitionrobotics/ts-common/core/exceptions");
|
|
18
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
19
38
|
const Header_PlatformVersion = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey_PlatformVersion);
|
|
20
39
|
const Header_PlatformName = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey_PlatformName);
|
|
21
40
|
// const DefaultRegexps: { [k in PlatformName]: string } = {
|
|
22
41
|
// chrome: "Chrome/([0-9\.]+)"
|
|
23
42
|
// };
|
|
24
|
-
class ForceUpgrade_Class extends
|
|
43
|
+
class ForceUpgrade_Class extends ts_common_1.Module {
|
|
25
44
|
constructor() {
|
|
26
45
|
super("ForceUpgrade");
|
|
27
46
|
}
|
|
@@ -38,7 +57,7 @@ class ForceUpgrade_Class extends module_1.Module {
|
|
|
38
57
|
const regex = new RegExp(platformNameConfig.regexp);
|
|
39
58
|
const match = platformVersion.match(regex);
|
|
40
59
|
if (!match)
|
|
41
|
-
throw new
|
|
60
|
+
throw new ts_common_1.BadImplementationException(`Error extracting version.. \nVersion: '${platformVersion}'\n config: '${(0, ts_common_1.__stringify)(this.config)}'`);
|
|
42
61
|
const minimumValidVersion = platformNameConfig.minimumValidVersion;
|
|
43
62
|
if (!minimumValidVersion)
|
|
44
63
|
return {
|
|
@@ -46,13 +65,13 @@ class ForceUpgrade_Class extends module_1.Module {
|
|
|
46
65
|
};
|
|
47
66
|
const matchGroups = match.groups;
|
|
48
67
|
if (!matchGroups)
|
|
49
|
-
throw new
|
|
68
|
+
throw new ts_common_1.BadImplementationException(`If minimumValidVersion is provided ${platformNameConfig.minimumValidVersion}, then groups in regex have to be defined ${(0, ts_common_1.__stringify)(match)}. i.e. "(?<first>[0-9]+).(?<second>[0-9]+).(?<third>[0-9]+)"`);
|
|
50
69
|
const minimumVersionMatch = minimumValidVersion.match(regex);
|
|
51
70
|
if (!minimumVersionMatch)
|
|
52
|
-
throw new
|
|
71
|
+
throw new ts_common_1.BadImplementationException(`Error extracting minimum valid version. \nVersion: '${minimumValidVersion}'\n config: '${(0, ts_common_1.__stringify)(this.config)}'`);
|
|
53
72
|
const versionsGroups = minimumVersionMatch.groups;
|
|
54
73
|
if (!versionsGroups)
|
|
55
|
-
throw new
|
|
74
|
+
throw new ts_common_1.BadImplementationException(`If minimumValidVersion is provided ${platformNameConfig.minimumValidVersion}, then groups in regex have to be defined ${(0, ts_common_1.__stringify)(minimumVersionMatch)}. i.e. "(?<first>[0-9]+).(?<second>[0-9]+).(?<third>[0-9]+)"`);
|
|
56
75
|
const versions = Object.values(matchGroups);
|
|
57
76
|
const minimumVersions = Object.values(versionsGroups);
|
|
58
77
|
for (let i = 0; i < versions.length; i++) {
|
|
@@ -71,6 +90,7 @@ class ForceUpgrade_Class extends module_1.Module {
|
|
|
71
90
|
});
|
|
72
91
|
}
|
|
73
92
|
}
|
|
93
|
+
_a = ForceUpgrade_Class;
|
|
74
94
|
ForceUpgrade_Class.Middleware = (request) => __awaiter(void 0, void 0, void 0, function* () { return exports.ForceUpgrade.assertVersion(request); });
|
|
75
95
|
exports.ForceUpgrade = new ForceUpgrade_Class();
|
|
76
96
|
//# sourceMappingURL=ForceUpgrade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForceUpgrade.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ForceUpgrade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ForceUpgrade.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ForceUpgrade.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;AAEH,4DAIsC;AACtC,oDAG6B;AAE7B,8CAA2C;AAC3C,8DAIoC;AAWpC,MAAM,sBAAsB,GAAG,IAAI,sBAAS,CAAC,yCAAyB,CAAC,CAAC;AACxE,MAAM,mBAAmB,GAAG,IAAI,sBAAS,CAAC,sCAAsB,CAAC,CAAC;AAElE,4DAA4D;AAC5D,+BAA+B;AAC/B,KAAK;AAEL,MAAM,kBACL,SAAQ,kBAAqB;IAE7B;QACC,KAAK,CAAC,cAAc,CAAC,CAAC;IACvB,CAAC;IAID,cAAc,CAAC,OAAuB;QACrC,MAAM,eAAe,GAAG,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAiB,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEpE,IAAI,CAAC,YAAY;YAChB,MAAM,IAAI,yBAAY,CAAC,GAAG,EAAE,iCAAiC,CAAC,CAAC;QAEhE,IAAI,CAAC,eAAe;YACnB,MAAM,IAAI,yBAAY,CAAC,GAAG,EAAE,oCAAoC,CAAC,CAAC;QAEnE,MAAM,kBAAkB,GAAG,IAAI,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QACtD,MAAM,eAAe,GAAa,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAEhE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAEhC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI;gBACb,OAAO,EAAC,eAAe,EAAE,IAAI,EAAC,CAAA;QAChC,CAAC;QAED,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,CAAA;IAChC,CAAC;IAEK,aAAa,CAAC,OAAuB;;YAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,eAAe,CAAC,eAAe;gBAClC,MAAM,IAAI,yBAAY,CAAkB,GAAG,EAAE,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC,CAAA;QACnI,CAAC;KAAA;;;AA9De,6BAAU,GAAyB,CAAO,OAAuB,EAAE,EAAE,kDAAC,OAAA,oBAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA,GAAA,AAA/F,CAAgG;AAiE9G,QAAA,YAAY,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { OnApplicationError, ServerErrorSeverity } from "@intuitionrobotics/ts-common
|
|
2
|
-
import { Module } from "@intuitionrobotics/ts-common/core/module";
|
|
1
|
+
import { Module, OnApplicationError, ServerErrorSeverity } from "@intuitionrobotics/ts-common";
|
|
3
2
|
import { WebClientOptions } from "@slack/web-api";
|
|
4
|
-
|
|
3
|
+
type ConfigType = {
|
|
5
4
|
token: string;
|
|
6
5
|
defaultChannel: string;
|
|
7
6
|
throttlingTime?: number;
|
|
8
7
|
slackConfig?: Partial<WebClientOptions>;
|
|
9
8
|
};
|
|
10
|
-
|
|
9
|
+
type _SlackMessage = {
|
|
11
10
|
text: string;
|
|
12
11
|
channel: string;
|
|
13
12
|
};
|
|
14
|
-
export
|
|
13
|
+
export type SlackMessage = string | _SlackMessage;
|
|
15
14
|
export declare class SlackModule_Class extends Module<ConfigType> {
|
|
16
15
|
private web;
|
|
17
16
|
private messageMap;
|
|
@@ -21,7 +20,7 @@ export declare class SlackModule_Class extends Module<ConfigType> {
|
|
|
21
20
|
private postMessageImpl;
|
|
22
21
|
}
|
|
23
22
|
export declare const SlackModule: SlackModule_Class;
|
|
24
|
-
|
|
23
|
+
type ApiErrorConfig = {
|
|
25
24
|
exclude: string[];
|
|
26
25
|
minLevel: ServerErrorSeverity;
|
|
27
26
|
};
|
|
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Slack_ServerApiError = exports.Slack_ServerApiError_Class = exports.SlackModule = exports.SlackModule_Class = void 0;
|
|
13
|
-
const
|
|
14
|
-
const module_1 = require("@intuitionrobotics/ts-common/core/module");
|
|
15
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
16
14
|
const web_api_1 = require("@slack/web-api");
|
|
17
|
-
class SlackModule_Class extends
|
|
15
|
+
class SlackModule_Class extends ts_common_1.Module {
|
|
18
16
|
constructor() {
|
|
19
17
|
super("SlackModule");
|
|
20
18
|
this.messageMap = {};
|
|
@@ -32,7 +30,7 @@ class SlackModule_Class extends module_1.Module {
|
|
|
32
30
|
channel: this.config.defaultChannel
|
|
33
31
|
} : slackMessage;
|
|
34
32
|
const time = this.messageMap[parameters.text];
|
|
35
|
-
if (time &&
|
|
33
|
+
if (time && (0, ts_common_1.currentTimeMillies)() - time < (this.config.throttlingTime || ts_common_1.Minute))
|
|
36
34
|
return;
|
|
37
35
|
try {
|
|
38
36
|
return yield this.postMessageImpl(parameters);
|
|
@@ -45,23 +43,23 @@ class SlackModule_Class extends module_1.Module {
|
|
|
45
43
|
postMessageImpl(message) {
|
|
46
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
45
|
const res = yield this.web.chat.postMessage(message);
|
|
48
|
-
this.messageMap[message.text] =
|
|
46
|
+
this.messageMap[message.text] = (0, ts_common_1.currentTimeMillies)();
|
|
49
47
|
this.logDebug(`A message was posted to channel: ${message.channel} with message id ${res.ts} which contains the message ${message.text}`);
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
exports.SlackModule_Class = SlackModule_Class;
|
|
54
52
|
exports.SlackModule = new SlackModule_Class();
|
|
55
|
-
class Slack_ServerApiError_Class extends
|
|
53
|
+
class Slack_ServerApiError_Class extends ts_common_1.Module {
|
|
56
54
|
constructor() {
|
|
57
55
|
super("Slack_ServerApiError");
|
|
58
|
-
this.
|
|
56
|
+
this.setDefaultConfig({ exclude: [], minLevel: ts_common_1.ServerErrorSeverity.Info });
|
|
59
57
|
}
|
|
60
58
|
init() {
|
|
61
59
|
}
|
|
62
60
|
__processApplicationError(errorLevel, module, message) {
|
|
63
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
if (
|
|
62
|
+
if (ts_common_1.ServerErrorSeverity_Ordinal.indexOf(errorLevel) < ts_common_1.ServerErrorSeverity_Ordinal.indexOf(this.config.minLevel))
|
|
65
63
|
return;
|
|
66
64
|
for (const key of this.config.exclude || []) {
|
|
67
65
|
if (message.includes(key))
|