@intuitionrobotics/thunderstorm 0.43.1 → 0.43.3
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/core/Storm.d.ts +2 -3
- package/app-backend/core/Storm.js +4 -9
- package/app-backend/core/Storm.js.map +1 -1
- package/app-backend/modules/CleanupScheduler.js +1 -1
- package/app-backend/modules/CleanupScheduler.js.map +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.js +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.js.map +1 -1
- package/app-backend/modules/ForceUpgrade.d.ts +1 -0
- package/app-backend/modules/ForceUpgrade.js +3 -0
- package/app-backend/modules/ForceUpgrade.js.map +1 -1
- package/app-backend/modules/SlackModule.d.ts +36 -0
- package/app-backend/modules/SlackModule.js +97 -0
- package/app-backend/modules/SlackModule.js.map +1 -0
- package/app-backend/modules/http/AxiosHttpModule.d.ts +1 -0
- package/app-backend/modules/http/AxiosHttpModule.js +6 -4
- package/app-backend/modules/http/AxiosHttpModule.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxy.d.ts +3 -0
- package/app-backend/modules/proxy/RemoteProxy.js +12 -5
- package/app-backend/modules/proxy/RemoteProxy.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxyCaller.d.ts +2 -1
- package/app-backend/modules/proxy/RemoteProxyCaller.js +6 -3
- package/app-backend/modules/proxy/RemoteProxyCaller.js.map +1 -1
- package/app-backend/modules/server/HttpServer.d.ts +5 -7
- package/app-backend/modules/server/HttpServer.js +15 -12
- package/app-backend/modules/server/HttpServer.js.map +1 -1
- package/app-backend/modules/server/server-api.d.ts +7 -6
- package/app-backend/modules/server/server-api.js +26 -13
- package/app-backend/modules/server/server-api.js.map +1 -1
- package/app-backend/modules/server/server-errors.js +0 -1
- package/app-backend/modules/server/server-errors.js.map +1 -1
- package/app-frontend/components/ActionButton.d.ts +2 -2
- package/app-frontend/components/DropDown.d.ts +1 -1
- package/app-frontend/components/FilterInput.d.ts +1 -1
- package/app-frontend/components/GenericSelect.d.ts +1 -1
- package/app-frontend/components/TS_Input.d.ts +1 -1
- package/app-frontend/components/TS_Table.d.ts +1 -1
- package/app-frontend/components/TS_TextArea.d.ts +1 -1
- package/app-frontend/components/Tabs.d.ts +2 -2
- package/app-frontend/components/adapter/Adapter.d.ts +1 -1
- package/app-frontend/components/checkbox/TS_Checkbox.d.ts +2 -2
- package/app-frontend/components/checkbox/TS_CheckboxField.d.ts +1 -1
- package/app-frontend/components/form/Form.d.ts +1 -1
- package/app-frontend/components/playground/Example_NewProps.d.ts +1 -1
- package/app-frontend/components/playground/Playground.d.ts +1 -1
- package/app-frontend/components/tree/MenuComponent.d.ts +2 -2
- package/app-frontend/components/tree/SimpleTreeNodeRenderer.d.ts +1 -1
- package/app-frontend/components/tree/Tree.d.ts +1 -1
- package/app-frontend/components/treeicons.d.ts +3 -3
- package/app-frontend/core/AppWrapper.d.ts +2 -2
- package/app-frontend/modules/ConnectivityModule.js +1 -1
- package/app-frontend/modules/ConnectivityModule.js.map +1 -1
- package/app-frontend/modules/ForceUpgrade.d.ts +1 -0
- package/app-frontend/modules/ForceUpgrade.js +1 -1
- package/app-frontend/modules/ForceUpgrade.js.map +1 -1
- package/app-frontend/modules/HistoryModule.js +1 -1
- package/app-frontend/modules/HistoryModule.js.map +1 -1
- package/app-frontend/modules/ResourcesModule.js +1 -1
- package/app-frontend/modules/ResourcesModule.js.map +1 -1
- package/app-frontend/modules/StorageModule.d.ts +1 -0
- package/app-frontend/modules/StorageModule.js +1 -1
- package/app-frontend/modules/StorageModule.js.map +1 -1
- package/app-frontend/modules/ThunderstormModule.js +1 -1
- package/app-frontend/modules/ThunderstormModule.js.map +1 -1
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.d.ts +1 -1
- package/app-frontend/modules/component-loader/entry-component-loading-module.d.ts +1 -0
- package/app-frontend/modules/component-loader/entry-component-loading-module.js +1 -1
- package/app-frontend/modules/component-loader/entry-component-loading-module.js.map +1 -1
- package/app-frontend/modules/dialog/Dialog.d.ts +3 -3
- package/app-frontend/modules/dialog/DialogModule.js +1 -1
- package/app-frontend/modules/dialog/DialogModule.js.map +1 -1
- package/app-frontend/modules/http/XhrHttpModule.d.ts +1 -0
- package/app-frontend/modules/http/XhrHttpModule.js +3 -0
- package/app-frontend/modules/http/XhrHttpModule.js.map +1 -1
- package/app-frontend/modules/locale/LocaleModule.d.ts +1 -0
- package/app-frontend/modules/locale/LocaleModule.js +1 -1
- package/app-frontend/modules/locale/LocaleModule.js.map +1 -1
- package/app-frontend/modules/menu/MenuAndButton.d.ts +1 -1
- package/app-frontend/modules/menu/MenuModule.d.ts +1 -0
- package/app-frontend/modules/menu/MenuModule.js +1 -1
- package/app-frontend/modules/menu/MenuModule.js.map +1 -1
- package/app-frontend/modules/menu/PopupMenu.d.ts +1 -1
- package/app-frontend/modules/routing/RoutingModule.d.ts +2 -2
- package/app-frontend/modules/routing/RoutingModule.js +1 -1
- package/app-frontend/modules/routing/RoutingModule.js.map +1 -1
- package/app-frontend/modules/toaster/BaseToaster.d.ts +1 -1
- package/app-frontend/modules/toaster/Toaster.d.ts +2 -2
- package/app-frontend/modules/toaster/ToasterModule.d.ts +1 -0
- package/app-frontend/modules/toaster/ToasterModule.js +1 -1
- package/app-frontend/modules/toaster/ToasterModule.js.map +1 -1
- package/app-frontend/modules/tooltip/Tooltip.d.ts +2 -1
- package/app-frontend/modules/tooltip/TooltipModule.d.ts +1 -0
- package/app-frontend/modules/tooltip/TooltipModule.js +1 -1
- package/app-frontend/modules/tooltip/TooltipModule.js.map +1 -1
- package/app-frontend/tools/KeyboardListener.d.ts +1 -1
- package/app-frontend/widgets/FieldEditor.d.ts +1 -1
- package/app-frontend/widgets/FieldEditorClick.d.ts +1 -1
- package/app-frontend/widgets/FieldEditorWithButtons.d.ts +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/package.json +10 -24
- package/shared/BaseHttpModule.d.ts +1 -1
- package/shared/BaseHttpModule.js +2 -2
- package/shared/BaseHttpModule.js.map +1 -1
|
@@ -7,13 +7,12 @@ export declare class Storm extends BaseStorm {
|
|
|
7
7
|
private initialPath;
|
|
8
8
|
private functions;
|
|
9
9
|
private apis;
|
|
10
|
-
private express
|
|
10
|
+
private readonly express;
|
|
11
11
|
private readonly httpServer;
|
|
12
|
-
constructor();
|
|
12
|
+
constructor(_express?: Express);
|
|
13
13
|
static getInstance(): Storm;
|
|
14
14
|
getHttpServer(): HttpServer_Class;
|
|
15
15
|
init(): this;
|
|
16
|
-
setMainExpressApp(_express: Express): void;
|
|
17
16
|
registerApis(...apis: ServerApi<any>[]): this;
|
|
18
17
|
setInitialRouteResolver(routeResolver: RouteResolver): this;
|
|
19
18
|
setInitialRoutePath(initialPath: string): this;
|
|
@@ -29,11 +29,12 @@ const server_api_1 = require("../modules/server/server-api");
|
|
|
29
29
|
const BaseStorm_1 = require("./BaseStorm");
|
|
30
30
|
const express = require("express");
|
|
31
31
|
class Storm extends BaseStorm_1.BaseStorm {
|
|
32
|
-
constructor() {
|
|
32
|
+
constructor(_express) {
|
|
33
33
|
super();
|
|
34
34
|
this.functions = [];
|
|
35
35
|
this.apis = [];
|
|
36
|
-
this.
|
|
36
|
+
this.express = _express || express();
|
|
37
|
+
this.httpServer = new HttpServer_1.HttpServer_Class(this.express);
|
|
37
38
|
this.addModules(this.httpServer, backend_1.FirebaseModule);
|
|
38
39
|
}
|
|
39
40
|
static getInstance() {
|
|
@@ -48,16 +49,10 @@ class Storm extends BaseStorm_1.BaseStorm {
|
|
|
48
49
|
server_api_1.ServerApi.isDebug = !!((_a = this.config) === null || _a === void 0 ? void 0 : _a.isDebug);
|
|
49
50
|
super.init();
|
|
50
51
|
const urlPrefix = !process.env.GCLOUD_PROJECT ? this.initialPath : "";
|
|
51
|
-
|
|
52
|
-
this.httpServer.resolveApi(this.routeResolver, urlPrefix);
|
|
53
|
-
// Load from those passed by init
|
|
54
|
-
this.routeResolver.routeApis(this.apis, urlPrefix);
|
|
52
|
+
this.httpServer.resolveApi(this.routeResolver, urlPrefix, this.apis);
|
|
55
53
|
this.httpServer.printRoutes(process.env.GCLOUD_PROJECT ? this.initialPath : "");
|
|
56
54
|
return this;
|
|
57
55
|
}
|
|
58
|
-
setMainExpressApp(_express) {
|
|
59
|
-
this.express = _express;
|
|
60
|
-
}
|
|
61
56
|
registerApis(...apis) {
|
|
62
57
|
this.apis = apis;
|
|
63
58
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/Storm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,iEAAmE;AACnE,4DAAsG;AACtG,qFAAyG;AACzG,6DAA6E;AAC7E,6DAAuD;AACvD,2CAAsC;AAEtC,mCAAmC;AAEnC,MAAa,KACT,SAAQ,qBAAS;IAQjB;
|
|
1
|
+
{"version":3,"file":"Storm.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/Storm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,iEAAmE;AACnE,4DAAsG;AACtG,qFAAyG;AACzG,6DAA6E;AAC7E,6DAAuD;AACvD,2CAAsC;AAEtC,mCAAmC;AAEnC,MAAa,KACT,SAAQ,qBAAS;IAQjB,YAAY,QAAkB;QAC1B,KAAK,EAAE,CAAC;QANJ,cAAS,GAAU,EAAE,CAAC;QACtB,SAAI,GAAqB,EAAE,CAAC;QAMhC,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;IACrD,CAAC;IAED,M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AAC,MAAM,CAAC,CAAC,MAAc,EAA8B,EAAE,CAAC,MAAM,YAAY,oCAAgB,CAAC,CAAC;QAEtJ,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,4CAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnE,GAAG,iBAAiB,CAAC,CAAC;QAE1B,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,SAAS,IAAI,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QAE/B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9C,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC;QACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;IAED,KAAK,CAAC,SAA+B;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACJ;AAxED,sBAwEC"}
|
|
@@ -16,7 +16,7 @@ const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/Fireba
|
|
|
16
16
|
const dispatch_onCleanupSchedulerAct = new ts_common_1.Dispatcher("__onCleanupSchedulerAct");
|
|
17
17
|
class CleanupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
18
18
|
constructor() {
|
|
19
|
-
super();
|
|
19
|
+
super("CleanupScheduler");
|
|
20
20
|
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const cleanupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('cleanup-status', ["moduleKey"]);
|
|
22
22
|
const cleanups = dispatch_onCleanupSchedulerAct.dispatchModule([]);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAC,kBAAkB,CAAC,CAAC;QAI3B,qBAAgB,GAAG,GAAuB,EAAE;YAC3C,MAAM,uBAAuB,GAAG,+BAAc,CAAC,kBAAkB,EAAE,CAAC,YAAY,EAAE,CAAC,aAAa,CAAgB,gBAAgB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;YACjJ,MAAM,QAAQ,GAAG,8BAA8B,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YACnE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAM,WAAW,EAAC,EAAE;gBAClD,MAAM,GAAG,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,EAAC,EAAC,CAAC,CAAC;gBACnG,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,GAAG,8BAAkB,EAAE;oBACrE,OAAO;gBAER,IAAI;oBACH,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;oBAC5B,MAAM,uBAAuB,CAAC,MAAM,CAAC,EAAC,SAAS,EAAE,8BAAkB,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,EAAC,CAAC,CAAC;iBAC1G;gBAAC,OAAO,CAAC,EAAE;oBACX,IAAI,CAAC,UAAU,CAAC,cAAc,WAAW,CAAC,SAAS,2BAA2B,CAAC,GAAG,CAAC,CAAC;iBACpF;YACF,CAAC,CAAA,CAAC,CAAC,CAAC;QACL,CAAC,CAAA,CAAC;QAlBD,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;CAkBD;AAxBD,wDAwBC;AAEY,QAAA,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -16,7 +16,7 @@ const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/Fireba
|
|
|
16
16
|
const dispatch_onFirestoreBackupSchedulerAct = new ts_common_1.Dispatcher("__onFirestoreBackupSchedulerAct");
|
|
17
17
|
class FirestoreBackupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
18
18
|
constructor() {
|
|
19
|
-
super();
|
|
19
|
+
super("FirestoreBackupScheduler");
|
|
20
20
|
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const backupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('firestore-backup-status', ["moduleKey", "timestamp"]);
|
|
22
22
|
const backups = [];
|
|
@@ -1 +1 @@
|
|
|
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,sCAAsC,GAAG,IAAI,sBAAU,CAC5D,iCAAiC,CAAC,CAAC;AAEpC,MAAa,8BACZ,SAAQ,6CAAyB;IAEjC;QACC,KAAK,
|
|
1
|
+
{"version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,CAAC,SAAS,wBAAwB,EAAC,CAAC,CAAC,CAAC;oBAC7E,MAAM,YAAY,GAAG,mDAAmD,uBAAW,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,gCAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;oBAE3I,MAAM,kCAAsB,CAAC,mBAAmB,CAAC,CAAC,+BAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;iBAErG;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"}
|
|
@@ -10,6 +10,7 @@ declare type VersionConfig = {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
declare class ForceUpgrade_Class extends Module<VersionConfig> {
|
|
13
|
+
constructor();
|
|
13
14
|
static readonly Middleware: ServerApi_Middleware;
|
|
14
15
|
compareVersion(request: ExpressRequest): UpgradeRequired;
|
|
15
16
|
assertVersion(request: ExpressRequest): Promise<void>;
|
|
@@ -40,6 +40,9 @@ const Header_PlatformName = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey
|
|
|
40
40
|
// chrome: "Chrome/([0-9\.]+)"
|
|
41
41
|
// };
|
|
42
42
|
class ForceUpgrade_Class extends ts_common_1.Module {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("ForceUpgrade");
|
|
45
|
+
}
|
|
43
46
|
compareVersion(request) {
|
|
44
47
|
const platformVersion = Header_PlatformVersion.get(request);
|
|
45
48
|
const platformName = Header_PlatformName.get(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForceUpgrade.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ForceUpgrade.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;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CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,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;SAC/B;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,CAAC;AAiE9G,QAAA,YAAY,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by AlanBen on 29/08/2019.
|
|
3
|
+
*/
|
|
4
|
+
import { Module, OnApplicationError, ServerErrorSeverity } from "@intuitionrobotics/ts-common";
|
|
5
|
+
import { WebClientOptions } from "@slack/web-api";
|
|
6
|
+
declare type ConfigType = {
|
|
7
|
+
token: string;
|
|
8
|
+
defaultChannel: string;
|
|
9
|
+
throttlingTime?: number;
|
|
10
|
+
slackConfig?: Partial<WebClientOptions>;
|
|
11
|
+
};
|
|
12
|
+
declare type _SlackMessage = {
|
|
13
|
+
text: string;
|
|
14
|
+
channel: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type SlackMessage = string | _SlackMessage;
|
|
17
|
+
export declare class SlackModule_Class extends Module<ConfigType> {
|
|
18
|
+
private web;
|
|
19
|
+
private messageMap;
|
|
20
|
+
constructor();
|
|
21
|
+
protected init(): void;
|
|
22
|
+
postMessage(slackMessage: SlackMessage): Promise<void>;
|
|
23
|
+
private postMessageImpl;
|
|
24
|
+
}
|
|
25
|
+
export declare const SlackModule: SlackModule_Class;
|
|
26
|
+
declare type ApiErrorConfig = {
|
|
27
|
+
exclude: string[];
|
|
28
|
+
minLevel: ServerErrorSeverity;
|
|
29
|
+
};
|
|
30
|
+
export declare class Slack_ServerApiError_Class extends Module<ApiErrorConfig> implements OnApplicationError {
|
|
31
|
+
constructor();
|
|
32
|
+
protected init(): void;
|
|
33
|
+
__processApplicationError(errorLevel: ServerErrorSeverity, module: Module, message: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare const Slack_ServerApiError: Slack_ServerApiError_Class;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
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 Adam van der Kruk aka TacB0sS
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
23
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
27
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
28
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.Slack_ServerApiError = exports.Slack_ServerApiError_Class = exports.SlackModule = exports.SlackModule_Class = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* Created by AlanBen on 29/08/2019.
|
|
35
|
+
*/
|
|
36
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
37
|
+
const web_api_1 = require("@slack/web-api");
|
|
38
|
+
class SlackModule_Class extends ts_common_1.Module {
|
|
39
|
+
constructor() {
|
|
40
|
+
super("SlackModule");
|
|
41
|
+
this.messageMap = {};
|
|
42
|
+
}
|
|
43
|
+
init() {
|
|
44
|
+
if (!this.config.token)
|
|
45
|
+
return;
|
|
46
|
+
// throw new ImplementationMissingException('Missing config token for SlackModule. Please add it');
|
|
47
|
+
this.web = new web_api_1.WebClient(this.config.token, Object.assign({ rejectRateLimitedCalls: true }, this.config.slackConfig));
|
|
48
|
+
}
|
|
49
|
+
postMessage(slackMessage) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const parameters = typeof slackMessage === 'string' ? {
|
|
52
|
+
text: slackMessage,
|
|
53
|
+
channel: this.config.defaultChannel
|
|
54
|
+
} : slackMessage;
|
|
55
|
+
const time = this.messageMap[parameters.text];
|
|
56
|
+
if (time && ts_common_1.currentTimeMillies() - time < (this.config.throttlingTime || ts_common_1.Minute))
|
|
57
|
+
return;
|
|
58
|
+
try {
|
|
59
|
+
return yield this.postMessageImpl(parameters);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
this.logError(`Error while sending a message to channel: ${parameters.channel}`, e);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
postMessageImpl(message) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const res = yield this.web.chat.postMessage(message);
|
|
69
|
+
this.messageMap[message.text] = ts_common_1.currentTimeMillies();
|
|
70
|
+
this.logDebug(`A message was posted to channel: ${message.channel} with message id ${res.ts} which contains the message ${message.text}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.SlackModule_Class = SlackModule_Class;
|
|
75
|
+
exports.SlackModule = new SlackModule_Class();
|
|
76
|
+
class Slack_ServerApiError_Class extends ts_common_1.Module {
|
|
77
|
+
constructor() {
|
|
78
|
+
super("Slack_ServerApiError");
|
|
79
|
+
this.setDefaultConfig({ exclude: [], minLevel: ts_common_1.ServerErrorSeverity.Info });
|
|
80
|
+
}
|
|
81
|
+
init() {
|
|
82
|
+
}
|
|
83
|
+
__processApplicationError(errorLevel, module, message) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (ts_common_1.ServerErrorSeverity_Ordinal.indexOf(errorLevel) < ts_common_1.ServerErrorSeverity_Ordinal.indexOf(this.config.minLevel))
|
|
86
|
+
return;
|
|
87
|
+
for (const key of this.config.exclude || []) {
|
|
88
|
+
if (message.includes(key))
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
yield exports.SlackModule.postMessage(`\`\`\`${message}\`\`\``);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.Slack_ServerApiError_Class = Slack_ServerApiError_Class;
|
|
96
|
+
exports.Slack_ServerApiError = new Slack_ServerApiError_Class();
|
|
97
|
+
//# sourceMappingURL=SlackModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SlackModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;AAEH;;GAEG;AAEH,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,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC9C,IAAI,IAAI,IAAI,8BAAkB,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,kBAAM,CAAC;gBAC5E,OAAO;YAEX,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;aACjD;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,QAAQ,CAAC,6CAA6C,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;aACvF;QACL,CAA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4
4
|
import { Axios_RequestConfig } from "./types";
|
|
5
5
|
export declare class AxiosHttpModule_Class extends BaseHttpModule_Class {
|
|
6
6
|
private requestOption;
|
|
7
|
+
constructor(name?: string);
|
|
7
8
|
init(): void;
|
|
8
9
|
createRequest<Binder extends ApiTypeBinder<any, any, any, any>>(method: HttpMethod, key: string, data?: string): AxiosHttpRequest<DeriveRealBinder<Binder>>;
|
|
9
10
|
setRequestOption(requestOption: Axios_RequestConfig): this;
|
|
@@ -38,8 +38,8 @@ const BaseHttpRequest_1 = require("../../../shared/BaseHttpRequest");
|
|
|
38
38
|
const BaseHttpModule_1 = require("../../../shared/BaseHttpModule");
|
|
39
39
|
const fs = require("fs");
|
|
40
40
|
class AxiosHttpModule_Class extends BaseHttpModule_1.BaseHttpModule_Class {
|
|
41
|
-
constructor() {
|
|
42
|
-
super(
|
|
41
|
+
constructor(name) {
|
|
42
|
+
super(name || "AxiosHttpModule");
|
|
43
43
|
this.requestOption = {};
|
|
44
44
|
}
|
|
45
45
|
init() {
|
|
@@ -126,8 +126,10 @@ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
|
|
|
126
126
|
// TODO set progress listener
|
|
127
127
|
// this.xhr.upload.onprogress = this.onProgressListener;
|
|
128
128
|
const body = this.body;
|
|
129
|
-
if (body)
|
|
130
|
-
|
|
129
|
+
if (body) {
|
|
130
|
+
const length = typeof body === 'string' ? body.length : JSON.stringify(body).length;
|
|
131
|
+
this.addHeader("Content-Length", `${length}`);
|
|
132
|
+
}
|
|
131
133
|
// TODO add zipping of body
|
|
132
134
|
// if (typeof body === "string" && this.compress)
|
|
133
135
|
// return gzip(body, (error: Error | null, result: Buffer) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosHttpModule.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/http/AxiosHttpModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2CAA2C;AA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IAAI,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;gBAC3C,OAAO,OAAO,EAAE,CAAC;aACpB;YAAC,OAAO,CAAC,EAAE;gBACR,2BAA2B;gBAC3B,wBAAwB;gBACxB,mDAAmD;gBACnD,8CAA8C;gBAC9C,YAAY;gBACZ,KAAK;gBAEL,IAAI,eAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACnB,+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"}
|
|
@@ -15,10 +15,13 @@ export declare type RemoteProxyConfig = {
|
|
|
15
15
|
proxyHeaderName?: string;
|
|
16
16
|
};
|
|
17
17
|
export declare class RemoteProxy_Class<Config extends RemoteProxyConfig> extends Module<Config> implements QueryRequestInfo {
|
|
18
|
+
constructor();
|
|
18
19
|
__queryRequestInfo(request: ExpressRequest): Promise<{
|
|
19
20
|
key: string;
|
|
20
21
|
data: any;
|
|
21
22
|
}>;
|
|
23
|
+
getProxyHeader(request: ExpressRequest): string;
|
|
24
|
+
private getSecretHeader;
|
|
22
25
|
readonly Middleware: ServerApi_Middleware;
|
|
23
26
|
private secretHeader;
|
|
24
27
|
private proxyHeader;
|
|
@@ -35,16 +35,17 @@ const HttpServer_1 = require("../server/HttpServer");
|
|
|
35
35
|
const exceptions_1 = require("../../exceptions");
|
|
36
36
|
class RemoteProxy_Class extends ts_common_1.Module {
|
|
37
37
|
constructor() {
|
|
38
|
-
super(
|
|
38
|
+
super("RemoteProxy");
|
|
39
39
|
this.Middleware = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
|
|
40
|
+
const extras = this.assertSecret(request);
|
|
41
|
+
return { extras, proxyId: this.getProxyHeader(request) };
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
__queryRequestInfo(request) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
46
|
let data;
|
|
46
47
|
try {
|
|
47
|
-
data = this.
|
|
48
|
+
data = this.getProxyHeader(request);
|
|
48
49
|
}
|
|
49
50
|
catch (e) {
|
|
50
51
|
}
|
|
@@ -54,6 +55,12 @@ class RemoteProxy_Class extends ts_common_1.Module {
|
|
|
54
55
|
};
|
|
55
56
|
});
|
|
56
57
|
}
|
|
58
|
+
getProxyHeader(request) {
|
|
59
|
+
return this.proxyHeader.get(request);
|
|
60
|
+
}
|
|
61
|
+
getSecretHeader(request) {
|
|
62
|
+
return this.secretHeader.get(request);
|
|
63
|
+
}
|
|
57
64
|
init() {
|
|
58
65
|
if (!this.config)
|
|
59
66
|
throw new ts_common_1.ImplementationMissingException("MUST specify config for this module!!");
|
|
@@ -67,8 +74,8 @@ class RemoteProxy_Class extends ts_common_1.Module {
|
|
|
67
74
|
assertSecret(request) {
|
|
68
75
|
if (!this.secretHeader || !this.proxyHeader)
|
|
69
76
|
throw new ts_common_1.ImplementationMissingException("MUST add RemoteProxy to your module list!!!");
|
|
70
|
-
const secret = this.
|
|
71
|
-
const proxyId = this.
|
|
77
|
+
const secret = this.getSecretHeader(request);
|
|
78
|
+
const proxyId = this.getProxyHeader(request);
|
|
72
79
|
const expectedSecret = this.config.remotes[proxyId];
|
|
73
80
|
if (!proxyId)
|
|
74
81
|
throw new exceptions_1.ApiException(403, `Missing proxy declaration in config for ${proxyId} !!`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteProxy.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,
|
|
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;gBACA,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aACvC;YAAC,OAAO,CAAC,EAAE;aACX;YACD,OAAO;gBACH,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE;gBACnB,IAAI;aACP,CAAC;QACN,CAAC;KAAA;IAED,cAAc,CAAC,OAAuB;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,eAAe,CAAC,OAAuB;QAC3C,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAA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,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"}
|
|
@@ -8,7 +8,8 @@ export declare type RemoteServerConfig = {
|
|
|
8
8
|
secret: string;
|
|
9
9
|
url: string;
|
|
10
10
|
};
|
|
11
|
-
export declare class RemoteProxyCaller<Config extends RemoteServerConfig> extends Module<Config> {
|
|
11
|
+
export declare abstract class RemoteProxyCaller<Config extends RemoteServerConfig> extends Module<Config> {
|
|
12
|
+
constructor(name: string);
|
|
12
13
|
protected init(): void;
|
|
13
14
|
protected executeGetRequest: <Binder extends import("../../../shared/types").ApiTypeBinder<U, R, void, P, any>, U extends string = DeriveUrlType<Binder>, R = DeriveResponseType<Binder>, P extends QueryParams = DeriveQueryType<Binder>>(url: U, _params: P, _headers?: {
|
|
14
15
|
[key: string]: string;
|
|
@@ -34,8 +34,9 @@ const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
|
34
34
|
const promisify_request_1 = require("../../utils/promisify-request");
|
|
35
35
|
const exceptions_1 = require("../../exceptions");
|
|
36
36
|
class RemoteProxyCaller extends ts_common_1.Module {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
|
|
38
|
+
constructor(name) {
|
|
39
|
+
super(name);
|
|
39
40
|
this.executeGetRequest = (url, _params, _headers) => __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
const resp = yield this.executeGetRequestImpl(url, _params, _headers);
|
|
41
42
|
return resp.data;
|
|
@@ -71,8 +72,10 @@ class RemoteProxyCaller extends ts_common_1.Module {
|
|
|
71
72
|
});
|
|
72
73
|
this.executeRequest = (proxyRequest) => __awaiter(this, void 0, void 0, function* () {
|
|
73
74
|
const response = yield promisify_request_1.promisifyRequest(proxyRequest);
|
|
74
|
-
if (proxyRequest.headers)
|
|
75
|
+
if (proxyRequest.headers) {
|
|
75
76
|
delete proxyRequest.headers[this.config.secretHeaderName];
|
|
77
|
+
delete proxyRequest.headers["Authorization"];
|
|
78
|
+
}
|
|
76
79
|
const statusCode = response.status;
|
|
77
80
|
// TODO: need to handle 1XX and 3XX
|
|
78
81
|
if (statusCode < 200 || statusCode >= 300) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteProxyCaller.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxyCaller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,
|
|
1
|
+
{"version":3,"file":"RemoteProxyCaller.js","sourceRoot":"","sources":["../../../../src/main/app-backend/modules/proxy/RemoteProxyCaller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAiG;AAWjG,qEAA+D;AAC/D,iDAA8C;AAW9C,MAAsB,iBAClB,SAAQ,kBAAc;IAEtB,oEAAoE;IACpE,YAAY,IAAY;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;QAuBN,sBAAiB,GAAG,CAAwK,GAAM,EAAE,OAAU,EAAE,QAEzN,EAAc,EAAE;YACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO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AAQ,CAAC,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;gBACvG,MAAM,CAAC,GAAG,IAAI,yBAAY,CACtB,QAAQ,CAAC,MAAM,EACf,yBAAyB,YAAY,sBAAsB,uBAAW,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClG,IAAI,aAAa,CAAC,KAAK;oBACnB,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAExC,MAAM,CAAC,CAAC;aACX;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC,CAAA,CAAC;IAzGF,CAAC;IAES,IAAI;QACV,IAAI,CAAC,IAAI,CAAC,MAAM;YACZ,MAAM,IAAI,0CAA8B,CAAC,uCAAuC,CAAC,CAAC;QAEtF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;YACpB,MAAM,IAAI,0CAA8B,CAAC,iDAAiD,CAAC,CAAC;QAEhG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YAChB,MAAM,IAAI,0CAA8B,CAAC,8CAA8C,CAAC,CAAC;QAE7F,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;YACnB,MAAM,IAAI,0CAA8B,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,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { Module, ObjectTS } from "@intuitionrobotics/ts-common";
|
|
3
3
|
import { ApiResponse, HttpRequestData, ServerApi } from "./server-api";
|
|
4
4
|
import { ApiException } from "../../exceptions";
|
|
5
|
-
import * as express from "express";
|
|
6
5
|
import { Express, ExpressRequest, ExpressRequestHandler } from "../../utils/types";
|
|
7
6
|
declare type ConfigType = {
|
|
8
7
|
port: number;
|
|
@@ -20,7 +19,7 @@ declare type ConfigType = {
|
|
|
20
19
|
bodyParserLimit: number | string;
|
|
21
20
|
};
|
|
22
21
|
export declare type HttpErrorHandler = (requestData: HttpRequestData, error: ApiException) => Promise<string>;
|
|
23
|
-
export declare type ServerApi_Middleware = (request: ExpressRequest, data: HttpRequestData, response: ApiResponse) => Promise<void>;
|
|
22
|
+
export declare type ServerApi_Middleware = (request: ExpressRequest, data: HttpRequestData, response: ApiResponse) => Promise<ObjectTS | void>;
|
|
24
23
|
declare type HttpRoute = {
|
|
25
24
|
methods: string[];
|
|
26
25
|
path: string;
|
|
@@ -37,19 +36,18 @@ export declare class HttpServer_Class extends Module<ConfigType> {
|
|
|
37
36
|
getBaseUrl(): string;
|
|
38
37
|
protected init(): Promise<void>;
|
|
39
38
|
printRoutes(prefix: string): void;
|
|
40
|
-
resolveApi(routeResolver: RouteResolver, urlPrefix: string): void;
|
|
39
|
+
resolveApi(routeResolver: RouteResolver, urlPrefix: string, apis: ServerApi<any>[]): void;
|
|
41
40
|
}
|
|
42
41
|
export declare class RouteResolver {
|
|
43
|
-
private express;
|
|
44
42
|
readonly require: NodeRequire;
|
|
45
43
|
readonly rootDir: string;
|
|
46
44
|
readonly apiFolder: string;
|
|
47
45
|
private middlewares;
|
|
48
46
|
constructor(require: NodeRequire, rootDir: string, apiFolder?: string);
|
|
49
47
|
setMiddlewares(...middlewares: ServerApi_Middleware[]): this;
|
|
50
|
-
resolveApi(urlPrefix: string, _exp:
|
|
48
|
+
resolveApi(urlPrefix: string, baseUrl: string, _exp: Express): void;
|
|
51
49
|
private resolveApiImpl;
|
|
52
|
-
routeApis(apis: ServerApi<any>[], urlPrefix: string): void;
|
|
50
|
+
routeApis(apis: ServerApi<any>[], urlPrefix: string, baseUrl: string, _exp: Express): void;
|
|
53
51
|
}
|
|
54
52
|
export declare class HeaderKey {
|
|
55
53
|
private readonly key;
|
|
@@ -61,7 +61,7 @@ const ExposedHeaders = [
|
|
|
61
61
|
];
|
|
62
62
|
class HttpServer_Class extends ts_common_1.Module {
|
|
63
63
|
constructor(_express) {
|
|
64
|
-
super("
|
|
64
|
+
super("HttpServer");
|
|
65
65
|
this.errorMessageComposer = server_errors_1.DefaultApiErrorMessageComposer();
|
|
66
66
|
this.express = _express;
|
|
67
67
|
}
|
|
@@ -147,9 +147,13 @@ class HttpServer_Class extends ts_common_1.Module {
|
|
|
147
147
|
this.routes.forEach(route => this.logInfo(`${JSON.stringify(route.methods)} ${prefix}${route.path}`));
|
|
148
148
|
console.timeEnd(label);
|
|
149
149
|
}
|
|
150
|
-
resolveApi(routeResolver, urlPrefix) {
|
|
150
|
+
resolveApi(routeResolver, urlPrefix, apis) {
|
|
151
151
|
console.time('Resolving Apis');
|
|
152
|
-
|
|
152
|
+
const baseUrl = this.getBaseUrl();
|
|
153
|
+
// Load from those passed by init
|
|
154
|
+
routeResolver.routeApis(apis, urlPrefix, baseUrl, this.express);
|
|
155
|
+
// Load from folder structure recursively
|
|
156
|
+
routeResolver.resolveApi(urlPrefix, baseUrl, this.express);
|
|
153
157
|
const resolveRoutes = (stack) => {
|
|
154
158
|
return stack.map((layer) => {
|
|
155
159
|
if (layer.route && typeof layer.route.path === "string") {
|
|
@@ -184,14 +188,13 @@ class RouteResolver {
|
|
|
184
188
|
this.middlewares = middlewares;
|
|
185
189
|
return this;
|
|
186
190
|
}
|
|
187
|
-
resolveApi(urlPrefix, _exp) {
|
|
188
|
-
this.
|
|
189
|
-
this.resolveApiImpl(urlPrefix, this.rootDir + "/" + this.apiFolder);
|
|
191
|
+
resolveApi(urlPrefix, baseUrl, _exp) {
|
|
192
|
+
this.resolveApiImpl(urlPrefix, this.rootDir + "/" + this.apiFolder, baseUrl, _exp);
|
|
190
193
|
}
|
|
191
|
-
resolveApiImpl(urlPrefix, workingDir) {
|
|
194
|
+
resolveApiImpl(urlPrefix, workingDir, baseUrl, _exp) {
|
|
192
195
|
fs.readdirSync(workingDir).forEach((file) => {
|
|
193
196
|
if (fs.statSync(`${workingDir}/${file}`).isDirectory()) {
|
|
194
|
-
this.resolveApiImpl(`${urlPrefix}/${file}`, `${workingDir}/${file}
|
|
197
|
+
this.resolveApiImpl(`${urlPrefix}/${file}`, `${workingDir}/${file}`, baseUrl, _exp);
|
|
195
198
|
return;
|
|
196
199
|
}
|
|
197
200
|
if (file.endsWith(".d.ts"))
|
|
@@ -210,7 +213,7 @@ class RouteResolver {
|
|
|
210
213
|
console.log(`could not reference RouteResolver for: ${workingDir}/${relativePathToFile}`, e);
|
|
211
214
|
throw e;
|
|
212
215
|
}
|
|
213
|
-
routeResolver.resolveApi(urlPrefix,
|
|
216
|
+
routeResolver.resolveApi(urlPrefix, baseUrl, _exp);
|
|
214
217
|
return;
|
|
215
218
|
}
|
|
216
219
|
let content;
|
|
@@ -223,13 +226,13 @@ class RouteResolver {
|
|
|
223
226
|
}
|
|
224
227
|
if (!Array.isArray(content))
|
|
225
228
|
content = [content];
|
|
226
|
-
this.routeApis(content, urlPrefix);
|
|
229
|
+
this.routeApis(content, urlPrefix, baseUrl, _exp);
|
|
227
230
|
});
|
|
228
231
|
}
|
|
229
|
-
routeApis(apis, urlPrefix) {
|
|
232
|
+
routeApis(apis, urlPrefix, baseUrl, _exp) {
|
|
230
233
|
apis.forEach(api => {
|
|
231
234
|
api.addMiddlewares(...this.middlewares);
|
|
232
|
-
api.route(
|
|
235
|
+
api.route(_exp, urlPrefix, baseUrl);
|
|
233
236
|
});
|
|
234
237
|
}
|
|
235
238
|
}
|