@ruiapp/rapid-core 0.1.4 → 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/actionHandler.d.ts +17 -0
- package/dist/core/pluginManager.d.ts +31 -26
- package/dist/core/server.d.ts +24 -24
- package/dist/helpers/runCollectionEntityActionHandler.d.ts +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3335 -3279
- 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 +25 -0
- package/dist/plugins/{authManager → auth}/routes/getMyProfile.d.ts +1 -1
- package/dist/plugins/{authManager → auth}/routes/signin.d.ts +1 -1
- package/dist/plugins/{authManager → 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 +27 -0
- 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 +25 -0
- 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 +25 -0
- package/dist/plugins/routeManage/actionHandlers/httpProxy.d.ts +5 -0
- package/dist/plugins/routeManage/mod.d.ts +25 -0
- package/dist/plugins/webhooks/mod.d.ts +25 -11
- package/dist/server.d.ts +7 -6
- package/dist/types.d.ts +10 -12
- package/package.json +1 -1
- package/src/bootstrapApplicationConfig.ts +6 -6
- package/src/core/actionHandler.ts +23 -0
- package/src/core/pluginManager.ts +107 -108
- package/src/core/routesBuilder.ts +4 -4
- package/src/core/server.ts +26 -44
- package/src/dataAccess/dataAccessor.ts +1 -1
- package/src/helpers/{runCollectionEntityHttpHandler.ts → runCollectionEntityActionHandler.ts} +5 -5
- package/src/index.ts +9 -0
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/createSession.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/deleteSession.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/getMyProfile.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.ts +2 -2
- package/src/plugins/auth/mod.ts +80 -0
- package/src/plugins/{authManager → auth}/routes/getMyProfile.ts +1 -1
- package/src/plugins/{authManager → auth}/routes/signin.ts +1 -1
- package/src/plugins/{authManager → auth}/routes/signout.ts +1 -1
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/addEntityRelations.ts +6 -5
- package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +23 -0
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntitiesBatch.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntity.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/deleteCollectionEntityById.ts +8 -7
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntities.ts +8 -7
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntityById.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/queryDatabase.ts +5 -4
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/removeEntityRelations.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/updateCollectionEntityById.ts +6 -5
- package/src/plugins/dataManage/mod.ts +187 -0
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadDocument.ts +4 -4
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadFile.ts +4 -4
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/uploadFile.ts +5 -5
- package/src/plugins/fileManage/mod.ts +77 -0
- package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/getMetaModelDetail.ts +4 -4
- package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/listMetaModels.ts +4 -4
- package/src/plugins/{routeManager/httpHandlers → metaManage/actionHandlers}/listMetaRoutes.ts +4 -4
- package/src/plugins/{metaManager → metaManage}/mod.ts +88 -55
- package/src/plugins/{routeManager/httpHandlers → routeManage/actionHandlers}/httpProxy.ts +5 -4
- package/src/plugins/routeManage/mod.ts +92 -0
- package/src/plugins/webhooks/mod.ts +134 -94
- package/src/server.ts +28 -21
- package/src/types.ts +11 -14
- package/dist/core/httpHandler.d.ts +0 -18
- package/dist/core/plugin.d.ts +0 -6
- package/dist/helpers/runCollectionEntityHttpHandler.d.ts +0 -5
- package/dist/plugins/authManager/httpHandlers/createSession.d.ts +0 -8
- package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +0 -4
- package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +0 -4
- package/dist/plugins/authManager/mod.d.ts +0 -16
- package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/mod.d.ts +0 -16
- package/dist/plugins/fileManager/httpHandlers/downloadDocument.d.ts +0 -4
- package/dist/plugins/fileManager/httpHandlers/downloadFile.d.ts +0 -4
- package/dist/plugins/fileManager/httpHandlers/uploadFile.d.ts +0 -4
- package/dist/plugins/fileManager/mod.d.ts +0 -15
- package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +0 -4
- package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +0 -4
- package/dist/plugins/metaManager/mod.d.ts +0 -15
- package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +0 -4
- package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +0 -4
- package/dist/plugins/routeManager/mod.d.ts +0 -15
- package/src/core/httpHandler.ts +0 -29
- package/src/core/plugin.ts +0 -13
- package/src/plugins/authManager/mod.ts +0 -56
- package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +0 -22
- package/src/plugins/dataManager/mod.ts +0 -154
- package/src/plugins/fileManager/mod.ts +0 -48
- package/src/plugins/routeManager/mod.ts +0 -97
- /package/dist/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/models/AccessToken.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/models/index.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/routes/index.d.ts +0 -0
- /package/src/plugins/{authManager → auth}/models/AccessToken.ts +0 -0
- /package/src/plugins/{authManager → auth}/models/index.ts +0 -0
- /package/src/plugins/{authManager → auth}/routes/index.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RpdApplicationConfig } from "~/types";
|
|
2
|
+
import { IRpdServer, RapidPlugin } from "./server";
|
|
3
|
+
import { Next, RouteContext } from "./routeContext";
|
|
4
|
+
export interface ActionHandlerContext {
|
|
5
|
+
routerContext: RouteContext;
|
|
6
|
+
next: Next;
|
|
7
|
+
server: IRpdServer;
|
|
8
|
+
applicationConfig: RpdApplicationConfig;
|
|
9
|
+
input?: any;
|
|
10
|
+
output?: any;
|
|
11
|
+
status?: Response["status"];
|
|
12
|
+
}
|
|
13
|
+
export type ActionHandler = (ctx: ActionHandlerContext, options: any) => void | Promise<void>;
|
|
14
|
+
export interface IPluginActionHandler {
|
|
15
|
+
code: string;
|
|
16
|
+
handler: (plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) => void | Promise<void>;
|
|
17
|
+
}
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import { RpdApplicationConfig } from "~/types";
|
|
2
|
-
import { IRpdServer } from "./server";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
import { IRpdServer, RapidPlugin } from "./server";
|
|
3
|
+
declare class PluginManager {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(server: IRpdServer);
|
|
6
|
+
loadPlugins(plugins: RapidPlugin[]): Promise<void>;
|
|
7
|
+
/** 初始化插件时调用。 */
|
|
8
|
+
initPlugins(): Promise<void>;
|
|
9
|
+
/** 注册中间件 */
|
|
10
|
+
registerMiddlewares(): Promise<void>;
|
|
11
|
+
/** 注册接口动作处理程序 */
|
|
12
|
+
registerActionHandlers(): Promise<void>;
|
|
13
|
+
/** 注册事件处理程序 */
|
|
14
|
+
registerEventHandlers(): Promise<void>;
|
|
15
|
+
/** 注册消息处理程序 */
|
|
16
|
+
registerMessageHandlers(): Promise<void>;
|
|
17
|
+
/** 注册任务处理程序 */
|
|
18
|
+
registerTaskProcessors(): Promise<void>;
|
|
19
|
+
/** 在加载应用前调用。 */
|
|
20
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
21
|
+
/** 配置数据模型 */
|
|
22
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
23
|
+
/** 配置模型属性 */
|
|
24
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
25
|
+
/** 配置路由 */
|
|
26
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
27
|
+
/** 在应用配置加载完成后调用。此时插件可以进行一些数据的初始化工作。 */
|
|
28
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
29
|
+
/** 在应用准备完成后调用。此时服务器已经可以处理网络请求。 */
|
|
30
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export default PluginManager;
|
package/dist/core/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig,
|
|
2
|
-
import {
|
|
1
|
+
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes } from "~/types";
|
|
2
|
+
import { IPluginActionHandler, ActionHandler } from "./actionHandler";
|
|
3
3
|
import { Next } from "./routeContext";
|
|
4
4
|
export interface IRpdServer {
|
|
5
5
|
config: RapidServerConfig;
|
|
@@ -8,14 +8,14 @@ export interface IRpdServer {
|
|
|
8
8
|
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
9
9
|
tryQueryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
10
10
|
registerMiddleware(middleware: any): void;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
registerActionHandler(plugin: RapidPlugin, options: IPluginActionHandler): void;
|
|
12
|
+
getActionHandlerByCode(code: string): ActionHandler | undefined;
|
|
13
13
|
getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
|
|
14
14
|
getApplicationConfig(): RpdApplicationConfig;
|
|
15
15
|
appendApplicationConfig(config: Partial<RpdApplicationConfig>): any;
|
|
16
16
|
getModel(options: GetModelOptions): RpdDataModel | undefined;
|
|
17
17
|
registerEventHandler<K extends keyof RpdServerEventTypes>(eventName: K, listener: (...args: RpdServerEventTypes[K]) => void): this;
|
|
18
|
-
emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender:
|
|
18
|
+
emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender: RapidPlugin, payload: RpdServerEventTypes[K][1]): void;
|
|
19
19
|
handleRequest(request: Request, next: Next): Promise<Response>;
|
|
20
20
|
}
|
|
21
21
|
export type RpdConfigurationItemTypes = "integer" | "text" | "boolean" | "date" | "datetime" | "json";
|
|
@@ -41,44 +41,44 @@ export interface RpdConfigurationItemOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
defaultValue?: string;
|
|
43
43
|
}
|
|
44
|
-
export type RpdServerPluginExtendingAbilities = /** 是指提供处理网络请求的middleware的能力。 */ "extendMiddleware" | /** 是指增加系统中的集合的能力。 */ "extendModel" | /** 是指可以对模型增加属性的能力。 */ "extendProperty" | /** 是指增加接口动作的能力。 */ "
|
|
44
|
+
export type RpdServerPluginExtendingAbilities = /** 是指提供处理网络请求的middleware的能力。 */ "extendMiddleware" | /** 是指增加系统中的集合的能力。 */ "extendModel" | /** 是指可以对模型增加属性的能力。 */ "extendProperty" | /** 是指增加接口动作的能力。 */ "extendActionHandler" | /** 是指增加或者修改接口定义的能力。 */ "extendRoute" | /** 是指对实体数据进行标准化的能力。 */ "normalizeEntity" | /** 处理事件总线发送过来的事件的能力。 */ "handleEvent" | /** 处理消息队列发送过来的消息的能力。 */ "handleMessage" | /** 对特定任务进行处理的能力。 */ "processTask";
|
|
45
45
|
export interface RpdServerPluginConfigurableTargetOptions {
|
|
46
46
|
targetCode: string;
|
|
47
47
|
configurations: RpdConfigurationItemOptions[];
|
|
48
48
|
}
|
|
49
|
-
export interface
|
|
49
|
+
export interface RapidPlugin {
|
|
50
50
|
/** 插件代码 */
|
|
51
|
-
code: string;
|
|
51
|
+
get code(): string;
|
|
52
52
|
/** 插件描述 */
|
|
53
|
-
description: string;
|
|
53
|
+
get description(): string;
|
|
54
54
|
/** 插件可以提供哪些扩展能力 */
|
|
55
|
-
extendingAbilities: RpdServerPluginExtendingAbilities[];
|
|
55
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
56
56
|
/** 插件可以配置的目标实体,以及和配置目标相关的配置项 */
|
|
57
|
-
configurableTargets
|
|
57
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
58
58
|
/** 插件的全局配置项 */
|
|
59
|
-
configurations
|
|
59
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
60
60
|
/** 初始化插件时调用。插件可以在此时进行一些内部对象的初始化工作。 */
|
|
61
|
-
initPlugin
|
|
61
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
62
62
|
/** 注册中间件 */
|
|
63
|
-
registerMiddlewares
|
|
63
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
64
64
|
/** 注册接口动作处理程序 */
|
|
65
|
-
|
|
65
|
+
registerActionHandlers(server: IRpdServer): Promise<any>;
|
|
66
66
|
/** 注册事件处理程序 */
|
|
67
|
-
registerEventHandlers
|
|
67
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
68
68
|
/** 注册消息处理程序 */
|
|
69
|
-
registerMessageHandlers
|
|
69
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
70
70
|
/** 注册任务处理程序 */
|
|
71
|
-
registerTaskProcessors
|
|
71
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
72
72
|
/** 在加载应用前调用。 */
|
|
73
|
-
onLoadingApplication
|
|
73
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
74
74
|
/** 配置数据集合 */
|
|
75
|
-
configureModels
|
|
75
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
76
76
|
/** 配置模型属性 */
|
|
77
|
-
configureModelProperties
|
|
77
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
78
78
|
/** 配置路由 */
|
|
79
|
-
configureRoutes
|
|
79
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
80
80
|
/** 在应用配置加载完成后调用。此时插件可以进行一些数据的初始化工作。 */
|
|
81
|
-
onApplicationLoaded
|
|
81
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
82
82
|
/** 在应用准备完成后调用。此时服务器已经可以处理网络请求,可以对外广播消息。 */
|
|
83
|
-
onApplicationReady
|
|
83
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
84
84
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IRpdDataAccessor, RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
|
+
type DataAccessHandler = (dataAccessor: IRpdDataAccessor, input: any) => Promise<any>;
|
|
4
|
+
export default function runCollectionEntityActionHandler(ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions, code: string, handleDataAccess: DataAccessHandler): Promise<void>;
|
|
5
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,13 @@ export * from "./server";
|
|
|
3
3
|
export * from "./core/request";
|
|
4
4
|
export * from "./core/routeContext";
|
|
5
5
|
export * from "./core/server";
|
|
6
|
+
export * from "./core/http-types";
|
|
7
|
+
export * from "./core/actionHandler";
|
|
6
8
|
export * from "./utilities/jwtUtility";
|
|
7
9
|
export * as bootstrapApplicationConfig from "./bootstrapApplicationConfig";
|
|
10
|
+
export { default as MetaManagePlugin } from "./plugins/metaManage/mod";
|
|
11
|
+
export { default as DataManagePlugin } from "./plugins/dataManage/mod";
|
|
12
|
+
export { default as RouteManagePlugin } from "./plugins/routeManage/mod";
|
|
13
|
+
export { default as WebhooksPlugin } from "./plugins/webhooks/mod";
|
|
14
|
+
export { default as AuthPlugin } from "./plugins/auth/mod";
|
|
15
|
+
export { default as FileManagePlugin } from "./plugins/fileManage/mod";
|