@ruiapp/rapid-core 0.1.4 → 0.1.5
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/core/httpHandler.d.ts +3 -3
- package/dist/core/pluginManager.d.ts +31 -26
- package/dist/core/server.d.ts +21 -21
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3367 -3311
- package/dist/plugins/{authManager → auth}/httpHandlers/createSession.d.ts +2 -2
- package/dist/plugins/auth/httpHandlers/deleteSession.d.ts +4 -0
- package/dist/plugins/auth/httpHandlers/getMyProfile.d.ts +4 -0
- package/dist/plugins/auth/mod.d.ts +25 -0
- package/dist/plugins/dataManage/httpHandlers/addEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/countCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/createCollectionEntitiesBatch.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/createCollectionEntity.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/deleteCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/findCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/findCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/queryDatabase.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/removeEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/httpHandlers/updateCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/mod.d.ts +27 -0
- package/dist/plugins/fileManage/httpHandlers/downloadDocument.d.ts +4 -0
- package/dist/plugins/fileManage/httpHandlers/downloadFile.d.ts +4 -0
- package/dist/plugins/fileManage/httpHandlers/uploadFile.d.ts +4 -0
- package/dist/plugins/fileManage/mod.d.ts +25 -0
- package/dist/plugins/metaManage/httpHandlers/getMetaModelDetail.d.ts +4 -0
- package/dist/plugins/metaManage/httpHandlers/listMetaModels.d.ts +4 -0
- package/dist/plugins/metaManage/httpHandlers/listMetaRoutes.d.ts +4 -0
- package/dist/plugins/metaManage/mod.d.ts +25 -0
- package/dist/plugins/routeManage/httpHandlers/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 +5 -4
- package/dist/types.d.ts +7 -9
- package/package.json +1 -1
- package/src/core/httpHandler.ts +3 -3
- package/src/core/pluginManager.ts +107 -108
- package/src/core/server.ts +21 -39
- package/src/dataAccess/dataAccessor.ts +1 -1
- package/src/index.ts +7 -0
- package/src/plugins/{authManager → auth}/httpHandlers/createSession.ts +2 -2
- package/src/plugins/{authManager → auth}/httpHandlers/deleteSession.ts +2 -2
- package/src/plugins/{authManager → auth}/httpHandlers/getMyProfile.ts +2 -2
- package/src/plugins/auth/mod.ts +80 -0
- package/src/plugins/{dataManager → dataManage}/httpHandlers/addEntityRelations.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/countCollectionEntities.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/createCollectionEntitiesBatch.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/createCollectionEntity.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/deleteCollectionEntityById.ts +5 -4
- package/src/plugins/{dataManager → dataManage}/httpHandlers/findCollectionEntities.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/findCollectionEntityById.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/queryDatabase.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/removeEntityRelations.ts +3 -2
- package/src/plugins/{dataManager → dataManage}/httpHandlers/updateCollectionEntityById.ts +3 -2
- package/src/plugins/dataManage/mod.ts +187 -0
- package/src/plugins/{fileManager → fileManage}/httpHandlers/downloadDocument.ts +2 -2
- package/src/plugins/{fileManager → fileManage}/httpHandlers/downloadFile.ts +2 -2
- package/src/plugins/{fileManager → fileManage}/httpHandlers/uploadFile.ts +3 -3
- package/src/plugins/fileManage/mod.ts +77 -0
- package/src/plugins/{metaManager → metaManage}/httpHandlers/getMetaModelDetail.ts +2 -2
- package/src/plugins/{metaManager → metaManage}/httpHandlers/listMetaModels.ts +2 -2
- package/src/plugins/{routeManager → metaManage}/httpHandlers/listMetaRoutes.ts +2 -2
- package/src/plugins/{metaManager → metaManage}/mod.ts +86 -53
- package/src/plugins/{routeManager → routeManage}/httpHandlers/httpProxy.ts +3 -2
- package/src/plugins/routeManage/mod.ts +92 -0
- package/src/plugins/webhooks/mod.ts +134 -94
- package/src/server.ts +19 -12
- package/src/types.ts +8 -11
- package/dist/core/plugin.d.ts +0 -6
- 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/plugin.ts +0 -13
- package/src/plugins/authManager/mod.ts +0 -56
- 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 → auth}/httpHandlers/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/getMyProfile.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/routes/index.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/routes/signin.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/routes/signout.d.ts +0 -0
- /package/src/plugins/{authManager → auth}/httpHandlers/index.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/getMyProfile.ts +0 -0
- /package/src/plugins/{authManager → auth}/routes/index.ts +0 -0
- /package/src/plugins/{authManager → auth}/routes/signin.ts +0 -0
- /package/src/plugins/{authManager → auth}/routes/signout.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IRpdServer } from "./server";
|
|
1
|
+
import { RpdApplicationConfig } from "~/types";
|
|
2
|
+
import { IRpdServer, RapidPlugin } from "./server";
|
|
3
3
|
import { Next, RouteContext } from "./routeContext";
|
|
4
4
|
export interface HttpHandlerContext {
|
|
5
5
|
routerContext: RouteContext;
|
|
@@ -10,7 +10,7 @@ export interface HttpHandlerContext {
|
|
|
10
10
|
output?: any;
|
|
11
11
|
status?: Response["status"];
|
|
12
12
|
}
|
|
13
|
-
export type PluginHttpHandler = (plugin:
|
|
13
|
+
export type PluginHttpHandler = (plugin: RapidPlugin, ctx: HttpHandlerContext, options: any) => void | Promise<void>;
|
|
14
14
|
export type HttpRequestHandler = (ctx: HttpHandlerContext, options: any) => void | Promise<void>;
|
|
15
15
|
export interface IPluginHttpHandler {
|
|
16
16
|
code: string;
|
|
@@ -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
|
+
registerHttpHandlers(): 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,4 +1,4 @@
|
|
|
1
|
-
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig,
|
|
1
|
+
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes } from "~/types";
|
|
2
2
|
import { IPluginHttpHandler, HttpRequestHandler } from "./httpHandler";
|
|
3
3
|
import { Next } from "./routeContext";
|
|
4
4
|
export interface IRpdServer {
|
|
@@ -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
|
-
registerHttpHandler(plugin:
|
|
11
|
+
registerHttpHandler(plugin: RapidPlugin, options: IPluginHttpHandler): void;
|
|
12
12
|
getHttpHandlerByCode(code: string): HttpRequestHandler | 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";
|
|
@@ -46,39 +46,39 @@ 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
|
-
registerHttpHandlers
|
|
65
|
+
registerHttpHandlers(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
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,3 +5,9 @@ export * from "./core/routeContext";
|
|
|
5
5
|
export * from "./core/server";
|
|
6
6
|
export * from "./utilities/jwtUtility";
|
|
7
7
|
export * as bootstrapApplicationConfig from "./bootstrapApplicationConfig";
|
|
8
|
+
export { default as MetaManagePlugin } from "./plugins/metaManage/mod";
|
|
9
|
+
export { default as DataManagePlugin } from "./plugins/dataManage/mod";
|
|
10
|
+
export { default as RouteManagePlugin } from "./plugins/routeManage/mod";
|
|
11
|
+
export { default as WebhooksPlugin } from "./plugins/webhooks/mod";
|
|
12
|
+
export { default as AuthPlugin } from "./plugins/auth/mod";
|
|
13
|
+
export { default as FileManagePlugin } from "./plugins/fileManage/mod";
|