@ruiapp/rapid-core 0.1.3 → 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/http/formDataParser.d.ts +22 -0
- package/dist/core/httpHandler.d.ts +3 -3
- package/dist/core/pluginManager.d.ts +31 -26
- package/dist/core/providers/runtimeProvider.d.ts +4 -0
- package/dist/core/routeContext.d.ts +0 -1
- package/dist/core/server.d.ts +21 -21
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3365 -3113
- 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/dist/utilities/fsUtility.d.ts +6 -0
- package/package.json +3 -2
- package/src/core/http/formDataParser.ts +101 -0
- package/src/core/httpHandler.ts +3 -3
- package/src/core/pluginManager.ts +107 -106
- package/src/core/providers/runtimeProvider.ts +5 -0
- package/src/core/request.ts +2 -1
- package/src/core/routeContext.ts +0 -1
- package/src/core/routesBuilder.ts +2 -14
- 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/fileManage/httpHandlers/downloadDocument.ts +40 -0
- package/src/plugins/fileManage/httpHandlers/downloadFile.ts +32 -0
- package/src/plugins/fileManage/httpHandlers/uploadFile.ts +37 -0
- 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/src/utilities/fsUtility.ts +62 -0
- 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/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/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,8 +1,8 @@
|
|
|
1
|
-
import { IPluginInstance } from "~/types";
|
|
2
1
|
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
3
|
export interface UserAccessToken {
|
|
4
4
|
sub: "userAccessToken";
|
|
5
5
|
aud: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const code = "createSession";
|
|
8
|
-
export declare function handler(plugin:
|
|
8
|
+
export declare function handler(plugin: RapidPlugin, ctx: HttpHandlerContext, options: any): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth manager plugin
|
|
3
|
+
*/
|
|
4
|
+
import { RpdApplicationConfig } from "~/types";
|
|
5
|
+
import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
|
|
6
|
+
declare class AuthManager implements RapidPlugin {
|
|
7
|
+
get code(): string;
|
|
8
|
+
get description(): string;
|
|
9
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
10
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
11
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
12
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
13
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
14
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
15
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
16
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
17
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
18
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
19
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
20
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
21
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
22
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
23
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export default AuthManager;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Support manage data in database.
|
|
3
|
+
* This plugin provide:
|
|
4
|
+
* - routes for manage data in database.
|
|
5
|
+
*/
|
|
6
|
+
import { RpdApplicationConfig } from "~/types";
|
|
7
|
+
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
|
|
8
|
+
declare class DataManager implements RapidPlugin {
|
|
9
|
+
get code(): string;
|
|
10
|
+
get description(): string;
|
|
11
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
12
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
13
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
14
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
15
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
16
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
17
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
18
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
19
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
20
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
21
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
22
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
23
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
24
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
25
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
26
|
+
}
|
|
27
|
+
export default DataManager;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File manager plugin
|
|
3
|
+
*/
|
|
4
|
+
import { RpdApplicationConfig } from "~/types";
|
|
5
|
+
import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
|
|
6
|
+
declare class FileManager implements RapidPlugin {
|
|
7
|
+
get code(): string;
|
|
8
|
+
get description(): string;
|
|
9
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
10
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
11
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
12
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
13
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
14
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
15
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
16
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
17
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
18
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
19
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
20
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
21
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
22
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
23
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export default FileManager;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta manager plugin
|
|
3
|
+
*/
|
|
4
|
+
import { RpdApplicationConfig } from "~/types";
|
|
5
|
+
import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
|
|
6
|
+
declare class MetaManager implements RapidPlugin {
|
|
7
|
+
get code(): string;
|
|
8
|
+
get description(): string;
|
|
9
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
10
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
11
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
12
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
13
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
14
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
15
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
16
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
17
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
18
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
19
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
20
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
21
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
22
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
23
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export default MetaManager;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route manager plugin
|
|
3
|
+
*/
|
|
4
|
+
import { RpdApplicationConfig } from "~/types";
|
|
5
|
+
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
|
|
6
|
+
declare class RouteManager implements RapidPlugin {
|
|
7
|
+
get code(): string;
|
|
8
|
+
get description(): string;
|
|
9
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
10
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
11
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
12
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
13
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
14
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
15
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
16
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
17
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
18
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
19
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
20
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
21
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
22
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
23
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export default RouteManager;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Webhooks plugin
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer } from "~/core/server";
|
|
6
|
-
export declare const code = "webhooks";
|
|
7
|
-
export declare const description = "webhooks";
|
|
8
|
-
export declare const extendingAbilities: RpdServerPluginExtendingAbilities[];
|
|
9
|
-
export declare const configurableTargets: RpdServerPluginConfigurableTargetOptions[];
|
|
10
|
-
export declare const configurations: RpdConfigurationItemOptions[];
|
|
4
|
+
import { RpdApplicationConfig, RpdEntityCreateEventPayload, RpdEntityDeleteEventPayload, RpdEntityUpdateEventPayload, RpdServerEventTypes } from "~/types";
|
|
5
|
+
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
|
|
11
6
|
export interface Webhook {
|
|
12
7
|
name: string;
|
|
13
8
|
url: string;
|
|
@@ -18,7 +13,26 @@ export interface Webhook {
|
|
|
18
13
|
properties: string[];
|
|
19
14
|
enabled: boolean;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
declare class WebhooksPlugin implements RapidPlugin {
|
|
17
|
+
#private;
|
|
18
|
+
constructor();
|
|
19
|
+
get code(): string;
|
|
20
|
+
get description(): string;
|
|
21
|
+
get extendingAbilities(): RpdServerPluginExtendingAbilities[];
|
|
22
|
+
get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
|
|
23
|
+
get configurations(): RpdConfigurationItemOptions[];
|
|
24
|
+
initPlugin(server: IRpdServer): Promise<any>;
|
|
25
|
+
registerMiddlewares(server: IRpdServer): Promise<any>;
|
|
26
|
+
registerHttpHandlers(server: IRpdServer): Promise<any>;
|
|
27
|
+
registerEventHandlers(server: IRpdServer): Promise<any>;
|
|
28
|
+
registerMessageHandlers(server: IRpdServer): Promise<any>;
|
|
29
|
+
registerTaskProcessors(server: IRpdServer): Promise<any>;
|
|
30
|
+
onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
31
|
+
configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
32
|
+
configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
33
|
+
configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
34
|
+
onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
35
|
+
onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
|
|
36
|
+
handleEntityEvent(server: IRpdServer, event: keyof RpdServerEventTypes, sender: RapidPlugin, payload: RpdEntityCreateEventPayload | RpdEntityUpdateEventPayload | RpdEntityDeleteEventPayload): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export default WebhooksPlugin;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { GetDataAccessorOptions, GetModelOptions, IDatabaseAccessor, IDatabaseConfig,
|
|
1
|
+
import { GetDataAccessorOptions, GetModelOptions, IDatabaseAccessor, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes, RapidServerConfig } from "./types";
|
|
2
2
|
import { HttpRequestHandler, IPluginHttpHandler } from "./core/httpHandler";
|
|
3
|
-
import { IRpdServer } from "./core/server";
|
|
3
|
+
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
4
4
|
import { Next } from "./core/routeContext";
|
|
5
5
|
export interface InitServerOptions {
|
|
6
6
|
databaseAccessor: IDatabaseAccessor;
|
|
7
7
|
databaseConfig: IDatabaseConfig;
|
|
8
8
|
serverConfig: RapidServerConfig;
|
|
9
9
|
applicationConfig?: RpdApplicationConfig;
|
|
10
|
+
plugins?: RapidPlugin[];
|
|
10
11
|
}
|
|
11
12
|
export declare class RapidServer implements IRpdServer {
|
|
12
13
|
#private;
|
|
@@ -16,13 +17,13 @@ export declare class RapidServer implements IRpdServer {
|
|
|
16
17
|
constructor(options: InitServerOptions);
|
|
17
18
|
getApplicationConfig(): RpdApplicationConfig;
|
|
18
19
|
appendApplicationConfig(config: Partial<RpdApplicationConfig>): void;
|
|
19
|
-
registerHttpHandler(plugin:
|
|
20
|
+
registerHttpHandler(plugin: RapidPlugin, options: IPluginHttpHandler): void;
|
|
20
21
|
getHttpHandlerByCode(code: string): HttpRequestHandler;
|
|
21
22
|
registerMiddleware(middleware: any): void;
|
|
22
23
|
getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
|
|
23
24
|
getModel(options: GetModelOptions): RpdDataModel | undefined;
|
|
24
25
|
registerEventHandler<K extends keyof RpdServerEventTypes>(eventName: K, listener: (...args: RpdServerEventTypes[K]) => void): this;
|
|
25
|
-
emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender:
|
|
26
|
+
emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender: RapidPlugin, payload: RpdServerEventTypes[K][1]): Promise<void>;
|
|
26
27
|
start(): Promise<void>;
|
|
27
28
|
configureApplication(): Promise<void>;
|
|
28
29
|
queryDatabaseObject(sql: string, params?: unknown[] | Record<string, unknown>): Promise<any[]>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RapidPlugin } from "./core/server";
|
|
1
2
|
export type RapidServerConfig = {
|
|
2
3
|
baseUrl?: string;
|
|
3
4
|
sessionCookieName: string;
|
|
@@ -49,11 +50,11 @@ export interface GetModelOptions {
|
|
|
49
50
|
singularCode: string;
|
|
50
51
|
}
|
|
51
52
|
export type RpdServerEventTypes = {
|
|
52
|
-
"entity.create": [
|
|
53
|
-
"entity.update": [
|
|
54
|
-
"entity.delete": [
|
|
55
|
-
"entity.addRelations": [
|
|
56
|
-
"entity.removeRelations": [
|
|
53
|
+
"entity.create": [RapidPlugin, RpdEntityCreateEventPayload];
|
|
54
|
+
"entity.update": [RapidPlugin, RpdEntityUpdateEventPayload];
|
|
55
|
+
"entity.delete": [RapidPlugin, RpdEntityDeleteEventPayload];
|
|
56
|
+
"entity.addRelations": [RapidPlugin, RpdEntityAddRelationsEventPayload];
|
|
57
|
+
"entity.removeRelations": [RapidPlugin, RpdEntityRemoveRelationsEventPayload];
|
|
57
58
|
};
|
|
58
59
|
export interface RpdEntityCreateEventPayload {
|
|
59
60
|
namespace: string;
|
|
@@ -234,10 +235,7 @@ export interface RpdDataModelExtension {
|
|
|
234
235
|
code: string;
|
|
235
236
|
config: any;
|
|
236
237
|
}
|
|
237
|
-
export
|
|
238
|
-
getName(): string;
|
|
239
|
-
}
|
|
240
|
-
export type EventHandler<T = any> = (sender: IPluginInstance, payload: T) => void;
|
|
238
|
+
export type EventHandler<T = any> = (sender: RapidPlugin, payload: T) => void;
|
|
241
239
|
export interface RpdRoute {
|
|
242
240
|
name: string;
|
|
243
241
|
namespace: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function readFile(path: string): Promise<Buffer>;
|
|
3
|
+
export declare function copyFile(fromPath: string, toPath: string): Promise<void>;
|
|
4
|
+
export declare function removeFile(path: string): Promise<void>;
|
|
5
|
+
export declare function moveFile(fromPath: string, toPath: string): Promise<void>;
|
|
6
|
+
export declare function appendFile(path: string, data: ArrayBuffer): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruiapp/rapid-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"jsonwebtoken": "^9.0.2",
|
|
21
21
|
"koa-tree-router": "^0.12.1",
|
|
22
22
|
"lodash": "^4.17.21",
|
|
23
|
-
"qs": "^6.11.0"
|
|
23
|
+
"qs": "^6.11.0",
|
|
24
|
+
"uuid": "^9.0.1"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "rimraf dist && rollup --config",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { RapidRequest } from '../request'
|
|
2
|
+
|
|
3
|
+
export type BodyData = Record<string, string | File | (string | File)[]>
|
|
4
|
+
export type ParseBodyOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Parse all fields with multiple values should be parsed as an array.
|
|
7
|
+
* @default false
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const data = new FormData()
|
|
11
|
+
* data.append('file', 'aaa')
|
|
12
|
+
* data.append('file', 'bbb')
|
|
13
|
+
* data.append('message', 'hello')
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* If `all` is `false`:
|
|
17
|
+
* parseBody should return `{ file: 'bbb', message: 'hello' }`
|
|
18
|
+
*
|
|
19
|
+
* If `all` is `true`:
|
|
20
|
+
* parseBody should return `{ file: ['aaa', 'bbb'], message: 'hello' }`
|
|
21
|
+
*/
|
|
22
|
+
all?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const parseFormDataBody = async <T extends BodyData = BodyData>(
|
|
26
|
+
request: Request,
|
|
27
|
+
options: ParseBodyOptions = { all: false }
|
|
28
|
+
): Promise<T> => {
|
|
29
|
+
const contentType = request.headers.get('Content-Type')
|
|
30
|
+
|
|
31
|
+
if (isFormDataContent(contentType)) {
|
|
32
|
+
return parseFormData<T>(request, options)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {} as T
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isFormDataContent(contentType: string | null): boolean {
|
|
39
|
+
if (contentType === null) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
contentType.startsWith('multipart/form-data') ||
|
|
45
|
+
contentType.startsWith('application/x-www-form-urlencoded')
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function parseFormData<T extends BodyData = BodyData>(
|
|
50
|
+
request: Request,
|
|
51
|
+
options: ParseBodyOptions
|
|
52
|
+
): Promise<T> {
|
|
53
|
+
const formData = await (request as Request).formData()
|
|
54
|
+
|
|
55
|
+
if (formData) {
|
|
56
|
+
return convertFormDataToBodyData<T>(formData, options)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {} as T
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function convertFormDataToBodyData<T extends BodyData = BodyData>(
|
|
63
|
+
formData: FormData,
|
|
64
|
+
options: ParseBodyOptions
|
|
65
|
+
): T {
|
|
66
|
+
const form: BodyData = {}
|
|
67
|
+
|
|
68
|
+
formData.forEach((value, key) => {
|
|
69
|
+
const shouldParseAllValues = options.all || key.endsWith('[]')
|
|
70
|
+
|
|
71
|
+
if (!shouldParseAllValues) {
|
|
72
|
+
form[key] = value
|
|
73
|
+
} else {
|
|
74
|
+
handleParsingAllValues(form, key, value)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return form as T
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleParsingAllValues = (form: BodyData, key: string, value: FormDataEntryValue): void => {
|
|
82
|
+
if (form[key] && isArrayField(form[key])) {
|
|
83
|
+
appendToExistingArray(form[key] as (string | File)[], value)
|
|
84
|
+
} else if (form[key]) {
|
|
85
|
+
convertToNewArray(form, key, value)
|
|
86
|
+
} else {
|
|
87
|
+
form[key] = value
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function isArrayField(field: unknown): field is (string | File)[] {
|
|
92
|
+
return Array.isArray(field)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const appendToExistingArray = (arr: (string | File)[], value: FormDataEntryValue): void => {
|
|
96
|
+
arr.push(value)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const convertToNewArray = (form: BodyData, key: string, value: FormDataEntryValue): void => {
|
|
100
|
+
form[key] = [form[key] as string | File, value]
|
|
101
|
+
}
|
package/src/core/httpHandler.ts
CHANGED
|
@@ -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
|
|
|
5
5
|
export interface HttpHandlerContext {
|
|
@@ -13,7 +13,7 @@ export interface HttpHandlerContext {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type PluginHttpHandler = (
|
|
16
|
-
plugin:
|
|
16
|
+
plugin: RapidPlugin,
|
|
17
17
|
ctx: HttpHandlerContext,
|
|
18
18
|
options: any,
|
|
19
19
|
) => void | Promise<void>;
|