@ruiapp/rapid-core 0.1.5 → 0.1.6
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/dist/bootstrapApplicationConfig.d.ts +1 -1
- package/dist/core/{httpHandler.d.ts → actionHandler.d.ts} +4 -5
- package/dist/core/pluginManager.d.ts +1 -1
- package/dist/core/server.d.ts +5 -5
- package/dist/helpers/runCollectionEntityActionHandler.d.ts +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +56 -56
- package/dist/plugins/auth/actionHandlers/createSession.d.ts +8 -0
- package/dist/plugins/auth/actionHandlers/deleteSession.d.ts +4 -0
- package/dist/plugins/auth/actionHandlers/getMyProfile.d.ts +4 -0
- package/dist/plugins/auth/mod.d.ts +1 -1
- package/dist/plugins/auth/routes/getMyProfile.d.ts +1 -1
- package/dist/plugins/auth/routes/signin.d.ts +1 -1
- package/dist/plugins/auth/routes/signout.d.ts +1 -1
- package/dist/plugins/dataManage/actionHandlers/addEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/countCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/createCollectionEntity.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/deleteCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/findCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/findCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/queryDatabase.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/removeEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/updateCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/mod.d.ts +1 -1
- package/dist/plugins/fileManage/actionHandlers/downloadDocument.d.ts +4 -0
- package/dist/plugins/fileManage/actionHandlers/downloadFile.d.ts +4 -0
- package/dist/plugins/fileManage/actionHandlers/uploadFile.d.ts +4 -0
- package/dist/plugins/fileManage/mod.d.ts +1 -1
- package/dist/plugins/metaManage/actionHandlers/getMetaModelDetail.d.ts +4 -0
- package/dist/plugins/metaManage/actionHandlers/listMetaModels.d.ts +4 -0
- package/dist/plugins/metaManage/actionHandlers/listMetaRoutes.d.ts +4 -0
- package/dist/plugins/metaManage/mod.d.ts +1 -1
- package/dist/plugins/routeManage/actionHandlers/httpProxy.d.ts +5 -0
- package/dist/plugins/routeManage/mod.d.ts +1 -1
- package/dist/plugins/webhooks/mod.d.ts +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
- package/src/bootstrapApplicationConfig.ts +6 -6
- package/src/core/{httpHandler.ts → actionHandler.ts} +5 -11
- package/src/core/pluginManager.ts +3 -3
- package/src/core/routesBuilder.ts +4 -4
- package/src/core/server.ts +6 -6
- package/src/helpers/{runCollectionEntityHttpHandler.ts → runCollectionEntityActionHandler.ts} +5 -5
- package/src/index.ts +2 -0
- package/src/plugins/auth/{httpHandlers → actionHandlers}/createSession.ts +2 -2
- package/src/plugins/auth/{httpHandlers → actionHandlers}/deleteSession.ts +2 -2
- package/src/plugins/auth/{httpHandlers → actionHandlers}/getMyProfile.ts +2 -2
- package/src/plugins/auth/{httpHandlers → actionHandlers}/index.ts +2 -2
- package/src/plugins/auth/mod.ts +4 -4
- package/src/plugins/auth/routes/getMyProfile.ts +1 -1
- package/src/plugins/auth/routes/signin.ts +1 -1
- package/src/plugins/auth/routes/signout.ts +1 -1
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/addEntityRelations.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/countCollectionEntities.ts +6 -6
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/createCollectionEntitiesBatch.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/createCollectionEntity.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/deleteCollectionEntityById.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/findCollectionEntities.ts +6 -6
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/findCollectionEntityById.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/queryDatabase.ts +2 -2
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/removeEntityRelations.ts +4 -4
- package/src/plugins/dataManage/{httpHandlers → actionHandlers}/updateCollectionEntityById.ts +4 -4
- package/src/plugins/dataManage/mod.ts +24 -24
- package/src/plugins/fileManage/{httpHandlers → actionHandlers}/downloadDocument.ts +2 -2
- package/src/plugins/fileManage/{httpHandlers → actionHandlers}/downloadFile.ts +2 -2
- package/src/plugins/fileManage/{httpHandlers → actionHandlers}/uploadFile.ts +2 -2
- package/src/plugins/fileManage/mod.ts +7 -7
- package/src/plugins/metaManage/{httpHandlers → actionHandlers}/getMetaModelDetail.ts +2 -2
- package/src/plugins/metaManage/{httpHandlers → actionHandlers}/listMetaModels.ts +2 -2
- package/src/plugins/metaManage/{httpHandlers → actionHandlers}/listMetaRoutes.ts +2 -2
- package/src/plugins/metaManage/mod.ts +7 -7
- package/src/plugins/routeManage/{httpHandlers → actionHandlers}/httpProxy.ts +2 -2
- package/src/plugins/routeManage/mod.ts +3 -3
- package/src/plugins/webhooks/mod.ts +1 -1
- package/src/server.ts +10 -10
- package/src/types.ts +3 -3
- package/dist/helpers/runCollectionEntityHttpHandler.d.ts +0 -5
- package/dist/plugins/auth/httpHandlers/createSession.d.ts +0 -8
- package/dist/plugins/auth/httpHandlers/deleteSession.d.ts +0 -4
- package/dist/plugins/auth/httpHandlers/getMyProfile.d.ts +0 -4
- package/dist/plugins/dataManage/httpHandlers/addEntityRelations.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/countCollectionEntities.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/createCollectionEntitiesBatch.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/createCollectionEntity.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/deleteCollectionEntityById.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/findCollectionEntities.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/findCollectionEntityById.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/queryDatabase.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/removeEntityRelations.d.ts +0 -5
- package/dist/plugins/dataManage/httpHandlers/updateCollectionEntityById.d.ts +0 -5
- package/dist/plugins/fileManage/httpHandlers/downloadDocument.d.ts +0 -4
- package/dist/plugins/fileManage/httpHandlers/downloadFile.d.ts +0 -4
- package/dist/plugins/fileManage/httpHandlers/uploadFile.d.ts +0 -4
- package/dist/plugins/metaManage/httpHandlers/getMetaModelDetail.d.ts +0 -4
- package/dist/plugins/metaManage/httpHandlers/listMetaModels.d.ts +0 -4
- package/dist/plugins/metaManage/httpHandlers/listMetaRoutes.d.ts +0 -4
- package/dist/plugins/routeManage/httpHandlers/httpProxy.d.ts +0 -5
- /package/dist/plugins/auth/{httpHandlers → actionHandlers}/index.d.ts +0 -0
|
@@ -9,19 +9,19 @@ import {
|
|
|
9
9
|
RpdApplicationConfig,
|
|
10
10
|
RpdHttpMethod,
|
|
11
11
|
RpdRoute,
|
|
12
|
-
|
|
12
|
+
RunEntityActionHandlerOptions,
|
|
13
13
|
} from "~/types";
|
|
14
14
|
|
|
15
|
-
import * as
|
|
16
|
-
import * as findCollectionEntityById from "./
|
|
17
|
-
import * as countCollectionEntities from "./
|
|
18
|
-
import * as createCollectionEntity from "./
|
|
19
|
-
import * as createCollectionEntitiesBatch from "./
|
|
20
|
-
import * as updateCollectionEntityById from "./
|
|
21
|
-
import * as deleteCollectionEntityById from "./
|
|
22
|
-
import * as addEntityRelations from "./
|
|
23
|
-
import * as removeEntityRelations from "./
|
|
24
|
-
import * as queryDatabase from "./
|
|
15
|
+
import * as findCollectionEntities from "./actionHandlers/findCollectionEntities";
|
|
16
|
+
import * as findCollectionEntityById from "./actionHandlers/findCollectionEntityById";
|
|
17
|
+
import * as countCollectionEntities from "./actionHandlers/countCollectionEntities";
|
|
18
|
+
import * as createCollectionEntity from "./actionHandlers/createCollectionEntity";
|
|
19
|
+
import * as createCollectionEntitiesBatch from "./actionHandlers/createCollectionEntitiesBatch";
|
|
20
|
+
import * as updateCollectionEntityById from "./actionHandlers/updateCollectionEntityById";
|
|
21
|
+
import * as deleteCollectionEntityById from "./actionHandlers/deleteCollectionEntityById";
|
|
22
|
+
import * as addEntityRelations from "./actionHandlers/addEntityRelations";
|
|
23
|
+
import * as removeEntityRelations from "./actionHandlers/removeEntityRelations";
|
|
24
|
+
import * as queryDatabase from "./actionHandlers/queryDatabase";
|
|
25
25
|
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
|
|
26
26
|
|
|
27
27
|
|
|
@@ -114,17 +114,17 @@ class DataManager implements RapidPlugin {
|
|
|
114
114
|
async registerMiddlewares(server: IRpdServer): Promise<any> {
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
async
|
|
118
|
-
server.
|
|
119
|
-
server.
|
|
120
|
-
server.
|
|
121
|
-
server.
|
|
122
|
-
server.
|
|
123
|
-
server.
|
|
124
|
-
server.
|
|
125
|
-
server.
|
|
126
|
-
server.
|
|
127
|
-
server.
|
|
117
|
+
async registerActionHandlers(server: IRpdServer): Promise<any> {
|
|
118
|
+
server.registerActionHandler(this, findCollectionEntities);
|
|
119
|
+
server.registerActionHandler(this, findCollectionEntityById);
|
|
120
|
+
server.registerActionHandler(this, countCollectionEntities);
|
|
121
|
+
server.registerActionHandler(this, createCollectionEntity);
|
|
122
|
+
server.registerActionHandler(this, createCollectionEntitiesBatch);
|
|
123
|
+
server.registerActionHandler(this, updateCollectionEntityById);
|
|
124
|
+
server.registerActionHandler(this, addEntityRelations);
|
|
125
|
+
server.registerActionHandler(this, removeEntityRelations);
|
|
126
|
+
server.registerActionHandler(this, deleteCollectionEntityById);
|
|
127
|
+
server.registerActionHandler(this, queryDatabase);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
async registerEventHandlers(server: IRpdServer): Promise<any> {
|
|
@@ -160,13 +160,13 @@ class DataManager implements RapidPlugin {
|
|
|
160
160
|
type: "RESTful",
|
|
161
161
|
method: routeConfig.method,
|
|
162
162
|
endpoint: `/${namespace}/${pluralCode}${routeConfig.endpoint}`,
|
|
163
|
-
|
|
163
|
+
actions: [
|
|
164
164
|
{
|
|
165
165
|
code: routeConfig.handlerCode,
|
|
166
166
|
config: {
|
|
167
167
|
namespace,
|
|
168
168
|
singularCode,
|
|
169
|
-
} as
|
|
169
|
+
} as RunEntityActionHandlerOptions,
|
|
170
170
|
},
|
|
171
171
|
],
|
|
172
172
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
3
|
import { RapidPlugin } from "~/core/server";
|
|
4
4
|
import { readFile } from "~/utilities/fsUtility";
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ export const code = "downloadDocument";
|
|
|
7
7
|
|
|
8
8
|
export async function handler(
|
|
9
9
|
plugin: RapidPlugin,
|
|
10
|
-
ctx:
|
|
10
|
+
ctx: ActionHandlerContext,
|
|
11
11
|
options: any,
|
|
12
12
|
) {
|
|
13
13
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { readFile } from "~/utilities/fsUtility";
|
|
3
|
-
import {
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
4
|
import { RapidPlugin } from "~/core/server";
|
|
5
5
|
|
|
6
6
|
export const code = "downloadFile";
|
|
7
7
|
|
|
8
8
|
export async function handler(
|
|
9
9
|
plugin: RapidPlugin,
|
|
10
|
-
ctx:
|
|
10
|
+
ctx: ActionHandlerContext,
|
|
11
11
|
options: any,
|
|
12
12
|
) {
|
|
13
13
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v1 as uuidv1 } from "uuid";
|
|
2
2
|
import { appendFile } from "~/utilities/fsUtility";
|
|
3
|
-
import {
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { isArray } from "lodash";
|
|
6
6
|
import { RapidPlugin } from "~/core/server";
|
|
@@ -9,7 +9,7 @@ export const code = "uploadFile";
|
|
|
9
9
|
|
|
10
10
|
export async function handler(
|
|
11
11
|
plugin: RapidPlugin,
|
|
12
|
-
ctx:
|
|
12
|
+
ctx: ActionHandlerContext,
|
|
13
13
|
options: any,
|
|
14
14
|
) {
|
|
15
15
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
RpdApplicationConfig,
|
|
7
7
|
} from "~/types";
|
|
8
8
|
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
9
|
+
import * as downloadDocumentActionHandler from "./actionHandlers/downloadDocument";
|
|
10
|
+
import * as downloadFileActionHandler from "./actionHandlers/downloadFile";
|
|
11
|
+
import * as uploadFileActionHandler from "./actionHandlers/uploadFile";
|
|
12
12
|
import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
|
|
13
13
|
|
|
14
14
|
|
|
@@ -39,10 +39,10 @@ class FileManager implements RapidPlugin {
|
|
|
39
39
|
async registerMiddlewares(server: IRpdServer): Promise<any> {
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async
|
|
43
|
-
server.
|
|
44
|
-
server.
|
|
45
|
-
server.
|
|
42
|
+
async registerActionHandlers(server: IRpdServer): Promise<any> {
|
|
43
|
+
server.registerActionHandler(this, downloadDocumentActionHandler);
|
|
44
|
+
server.registerActionHandler(this, downloadFileActionHandler);
|
|
45
|
+
server.registerActionHandler(this, uploadFileActionHandler);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
async registerEventHandlers(server: IRpdServer): Promise<any> {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
2
|
import { RapidPlugin } from "~/core/server";
|
|
3
3
|
|
|
4
4
|
export const code = "getMetaModelDetail";
|
|
5
5
|
|
|
6
6
|
export async function handler(
|
|
7
7
|
plugin: RapidPlugin,
|
|
8
|
-
ctx:
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { server, input } = ctx;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
2
|
import { RapidPlugin } from "~/core/server";
|
|
3
3
|
|
|
4
4
|
export const code = "listMetaModels";
|
|
5
5
|
|
|
6
6
|
export async function handler(
|
|
7
7
|
plugin: RapidPlugin,
|
|
8
|
-
ctx:
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { applicationConfig } = ctx;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
2
|
import { RapidPlugin } from "~/core/server";
|
|
3
3
|
|
|
4
4
|
export const code = "listMetaRoutes";
|
|
5
5
|
|
|
6
6
|
export async function handler(
|
|
7
7
|
plugin: RapidPlugin,
|
|
8
|
-
ctx:
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { applicationConfig } = ctx;
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
} from "~/types";
|
|
18
18
|
import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
|
|
19
19
|
|
|
20
|
-
import * as listMetaModels from "./
|
|
21
|
-
import * as listMetaRoutes from "./
|
|
22
|
-
import * as getMetaModelDetail from "./
|
|
20
|
+
import * as listMetaModels from "./actionHandlers/listMetaModels";
|
|
21
|
+
import * as listMetaRoutes from "./actionHandlers/listMetaRoutes";
|
|
22
|
+
import * as getMetaModelDetail from "./actionHandlers/getMetaModelDetail";
|
|
23
23
|
import { isRelationProperty } from "~/utilities/rapidUtility";
|
|
24
24
|
|
|
25
25
|
class MetaManager implements RapidPlugin {
|
|
@@ -49,10 +49,10 @@ class MetaManager implements RapidPlugin {
|
|
|
49
49
|
async registerMiddlewares(server: IRpdServer): Promise<any> {
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async
|
|
53
|
-
server.
|
|
54
|
-
server.
|
|
55
|
-
server.
|
|
52
|
+
async registerActionHandlers(server: IRpdServer): Promise<any> {
|
|
53
|
+
server.registerActionHandler(this, listMetaModels);
|
|
54
|
+
server.registerActionHandler(this, listMetaRoutes);
|
|
55
|
+
server.registerActionHandler(this, getMetaModelDetail);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
async registerEventHandlers(server: IRpdServer): Promise<any> {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RunProxyHandlerOptions } from "~/types";
|
|
2
2
|
import { doProxy } from "~/proxy/mod";
|
|
3
|
-
import {
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
4
|
import { RapidPlugin } from "~/core/server";
|
|
5
5
|
|
|
6
6
|
export const code = "httpProxy";
|
|
7
7
|
|
|
8
8
|
export async function handler(
|
|
9
9
|
plugin: RapidPlugin,
|
|
10
|
-
ctx:
|
|
10
|
+
ctx: ActionHandlerContext,
|
|
11
11
|
options: RunProxyHandlerOptions,
|
|
12
12
|
) {
|
|
13
13
|
console.debug(`Running ${code} handler...`);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "~/types";
|
|
8
8
|
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
|
|
9
9
|
import { findEntities } from "../../dataAccess/entityManager";
|
|
10
|
-
import * as httpProxy from "./
|
|
10
|
+
import * as httpProxy from "./actionHandlers/httpProxy";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class RouteManager implements RapidPlugin {
|
|
@@ -37,8 +37,8 @@ class RouteManager implements RapidPlugin {
|
|
|
37
37
|
async registerMiddlewares(server: IRpdServer): Promise<any> {
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async
|
|
41
|
-
server.
|
|
40
|
+
async registerActionHandlers(server: IRpdServer): Promise<any> {
|
|
41
|
+
server.registerActionHandler(this, httpProxy);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async registerEventHandlers(server: IRpdServer): Promise<any> {
|
|
@@ -81,7 +81,7 @@ class WebhooksPlugin implements RapidPlugin {
|
|
|
81
81
|
async registerMiddlewares(server: IRpdServer): Promise<any> {
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
async
|
|
84
|
+
async registerActionHandlers(server: IRpdServer): Promise<any> {
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async registerEventHandlers(server: IRpdServer): Promise<any> {
|
package/src/server.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import QueryBuilder from "./queryBuilder/queryBuilder";
|
|
17
17
|
import PluginManager from "./core/pluginManager";
|
|
18
18
|
import EventManager from "./core/eventManager";
|
|
19
|
-
import {
|
|
19
|
+
import { ActionHandler, IPluginActionHandler } from "./core/actionHandler";
|
|
20
20
|
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
21
21
|
import { buildRoutes } from "./core/routesBuilder";
|
|
22
22
|
import { Next, RouteContext } from "./core/routeContext";
|
|
@@ -38,7 +38,7 @@ export class RapidServer implements IRpdServer {
|
|
|
38
38
|
#middlewares: any[];
|
|
39
39
|
#bootstrapApplicationConfig: RpdApplicationConfig;
|
|
40
40
|
#applicationConfig: RpdApplicationConfig;
|
|
41
|
-
#
|
|
41
|
+
#actionHandlersMapByCode: Map<string, ActionHandler>;
|
|
42
42
|
#databaseAccessor: IDatabaseAccessor;
|
|
43
43
|
queryBuilder: IQueryBuilder;
|
|
44
44
|
config: RapidServerConfig;
|
|
@@ -52,7 +52,7 @@ export class RapidServer implements IRpdServer {
|
|
|
52
52
|
this.#bootstrapApplicationConfig = options.applicationConfig || bootstrapApplicationConfig;
|
|
53
53
|
|
|
54
54
|
this.#applicationConfig = {} as RpdApplicationConfig;
|
|
55
|
-
this.#
|
|
55
|
+
this.#actionHandlersMapByCode = new Map();
|
|
56
56
|
this.#databaseAccessor = options.databaseAccessor;
|
|
57
57
|
|
|
58
58
|
this.queryBuilder = new QueryBuilder({
|
|
@@ -95,7 +95,7 @@ export class RapidServer implements IRpdServer {
|
|
|
95
95
|
const originalRoute = _.find(this.#applicationConfig.routes, (item) => item.code == route.code);
|
|
96
96
|
if (originalRoute) {
|
|
97
97
|
originalRoute.name = route.name;
|
|
98
|
-
originalRoute.
|
|
98
|
+
originalRoute.actions = route.actions;
|
|
99
99
|
} else {
|
|
100
100
|
this.#applicationConfig.routes.push(route);
|
|
101
101
|
}
|
|
@@ -103,16 +103,16 @@ export class RapidServer implements IRpdServer {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
registerActionHandler(
|
|
107
107
|
plugin: RapidPlugin,
|
|
108
|
-
options:
|
|
108
|
+
options: IPluginActionHandler,
|
|
109
109
|
) {
|
|
110
110
|
const handler = _.bind(options.handler, null, plugin);
|
|
111
|
-
this.#
|
|
111
|
+
this.#actionHandlersMapByCode.set(options.code, handler);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
return this.#
|
|
114
|
+
getActionHandlerByCode(code: string) {
|
|
115
|
+
return this.#actionHandlersMapByCode.get(code);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
registerMiddleware(middleware: any) {
|
|
@@ -178,7 +178,7 @@ export class RapidServer implements IRpdServer {
|
|
|
178
178
|
await pluginManager.initPlugins();
|
|
179
179
|
|
|
180
180
|
await pluginManager.registerMiddlewares();
|
|
181
|
-
await pluginManager.
|
|
181
|
+
await pluginManager.registerActionHandlers();
|
|
182
182
|
await pluginManager.registerEventHandlers();
|
|
183
183
|
await pluginManager.registerMessageHandlers();
|
|
184
184
|
await pluginManager.registerTaskProcessors();
|
package/src/types.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface IDatabaseAccessor {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
export interface
|
|
25
|
+
export interface RunEntityActionHandlerOptions {
|
|
26
26
|
/** 模型所在的命名空间 */
|
|
27
27
|
namespace: string;
|
|
28
28
|
/** 模型Code的单数表示 */
|
|
@@ -298,12 +298,12 @@ export interface RpdRoute {
|
|
|
298
298
|
type: "RESTful";
|
|
299
299
|
method: RpdHttpMethod;
|
|
300
300
|
endpoint: string;
|
|
301
|
-
|
|
301
|
+
actions: RpdRouteActionConfig[];
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
export type RpdHttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
305
305
|
|
|
306
|
-
export interface
|
|
306
|
+
export interface RpdRouteActionConfig {
|
|
307
307
|
code: string;
|
|
308
308
|
config?: any;
|
|
309
309
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { IRpdDataAccessor, RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
type DataAccessHandler = (dataAccessor: IRpdDataAccessor, input: any) => Promise<any>;
|
|
4
|
-
export default function runCollectionEntityHttpHandler(ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions, code: string, handleDataAccess: DataAccessHandler): Promise<void>;
|
|
5
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
2
|
-
import { RapidPlugin } from "~/core/server";
|
|
3
|
-
export interface UserAccessToken {
|
|
4
|
-
sub: "userAccessToken";
|
|
5
|
-
aud: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const code = "createSession";
|
|
8
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: any): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "addEntityRelations";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "countCollectionEntities";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "createCollectionEntitiesBatch";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "createCollectionEntity";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "deleteCollectionEntityById";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "findCollectionEntities";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "findCollectionEntityById";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunQueryDatabaseHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "queryDatabase";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunQueryDatabaseHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "removeEntityRelations";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "updateCollectionEntityById";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RunProxyHandlerOptions } from "~/types";
|
|
2
|
-
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
export declare const code = "httpProxy";
|
|
5
|
-
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: RunProxyHandlerOptions): Promise<void>;
|
|
File without changes
|