@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.
Files changed (121) hide show
  1. package/dist/bootstrapApplicationConfig.d.ts +1 -1
  2. package/dist/core/actionHandler.d.ts +17 -0
  3. package/dist/core/pluginManager.d.ts +31 -26
  4. package/dist/core/server.d.ts +24 -24
  5. package/dist/helpers/runCollectionEntityActionHandler.d.ts +5 -0
  6. package/dist/index.d.ts +8 -0
  7. package/dist/index.js +3335 -3279
  8. package/dist/plugins/auth/actionHandlers/createSession.d.ts +8 -0
  9. package/dist/plugins/auth/actionHandlers/deleteSession.d.ts +4 -0
  10. package/dist/plugins/auth/actionHandlers/getMyProfile.d.ts +4 -0
  11. package/dist/plugins/auth/mod.d.ts +25 -0
  12. package/dist/plugins/{authManager → auth}/routes/getMyProfile.d.ts +1 -1
  13. package/dist/plugins/{authManager → auth}/routes/signin.d.ts +1 -1
  14. package/dist/plugins/{authManager → auth}/routes/signout.d.ts +1 -1
  15. package/dist/plugins/dataManage/actionHandlers/addEntityRelations.d.ts +5 -0
  16. package/dist/plugins/dataManage/actionHandlers/countCollectionEntities.d.ts +5 -0
  17. package/dist/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.d.ts +5 -0
  18. package/dist/plugins/dataManage/actionHandlers/createCollectionEntity.d.ts +5 -0
  19. package/dist/plugins/dataManage/actionHandlers/deleteCollectionEntityById.d.ts +5 -0
  20. package/dist/plugins/dataManage/actionHandlers/findCollectionEntities.d.ts +5 -0
  21. package/dist/plugins/dataManage/actionHandlers/findCollectionEntityById.d.ts +5 -0
  22. package/dist/plugins/dataManage/actionHandlers/queryDatabase.d.ts +5 -0
  23. package/dist/plugins/dataManage/actionHandlers/removeEntityRelations.d.ts +5 -0
  24. package/dist/plugins/dataManage/actionHandlers/updateCollectionEntityById.d.ts +5 -0
  25. package/dist/plugins/dataManage/mod.d.ts +27 -0
  26. package/dist/plugins/fileManage/actionHandlers/downloadDocument.d.ts +4 -0
  27. package/dist/plugins/fileManage/actionHandlers/downloadFile.d.ts +4 -0
  28. package/dist/plugins/fileManage/actionHandlers/uploadFile.d.ts +4 -0
  29. package/dist/plugins/fileManage/mod.d.ts +25 -0
  30. package/dist/plugins/metaManage/actionHandlers/getMetaModelDetail.d.ts +4 -0
  31. package/dist/plugins/metaManage/actionHandlers/listMetaModels.d.ts +4 -0
  32. package/dist/plugins/metaManage/actionHandlers/listMetaRoutes.d.ts +4 -0
  33. package/dist/plugins/metaManage/mod.d.ts +25 -0
  34. package/dist/plugins/routeManage/actionHandlers/httpProxy.d.ts +5 -0
  35. package/dist/plugins/routeManage/mod.d.ts +25 -0
  36. package/dist/plugins/webhooks/mod.d.ts +25 -11
  37. package/dist/server.d.ts +7 -6
  38. package/dist/types.d.ts +10 -12
  39. package/package.json +1 -1
  40. package/src/bootstrapApplicationConfig.ts +6 -6
  41. package/src/core/actionHandler.ts +23 -0
  42. package/src/core/pluginManager.ts +107 -108
  43. package/src/core/routesBuilder.ts +4 -4
  44. package/src/core/server.ts +26 -44
  45. package/src/dataAccess/dataAccessor.ts +1 -1
  46. package/src/helpers/{runCollectionEntityHttpHandler.ts → runCollectionEntityActionHandler.ts} +5 -5
  47. package/src/index.ts +9 -0
  48. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/createSession.ts +4 -4
  49. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/deleteSession.ts +4 -4
  50. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/getMyProfile.ts +4 -4
  51. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.ts +2 -2
  52. package/src/plugins/auth/mod.ts +80 -0
  53. package/src/plugins/{authManager → auth}/routes/getMyProfile.ts +1 -1
  54. package/src/plugins/{authManager → auth}/routes/signin.ts +1 -1
  55. package/src/plugins/{authManager → auth}/routes/signout.ts +1 -1
  56. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/addEntityRelations.ts +6 -5
  57. package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +23 -0
  58. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntitiesBatch.ts +6 -5
  59. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntity.ts +6 -5
  60. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/deleteCollectionEntityById.ts +8 -7
  61. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntities.ts +8 -7
  62. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntityById.ts +6 -5
  63. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/queryDatabase.ts +5 -4
  64. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/removeEntityRelations.ts +6 -5
  65. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/updateCollectionEntityById.ts +6 -5
  66. package/src/plugins/dataManage/mod.ts +187 -0
  67. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadDocument.ts +4 -4
  68. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadFile.ts +4 -4
  69. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/uploadFile.ts +5 -5
  70. package/src/plugins/fileManage/mod.ts +77 -0
  71. package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/getMetaModelDetail.ts +4 -4
  72. package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/listMetaModels.ts +4 -4
  73. package/src/plugins/{routeManager/httpHandlers → metaManage/actionHandlers}/listMetaRoutes.ts +4 -4
  74. package/src/plugins/{metaManager → metaManage}/mod.ts +88 -55
  75. package/src/plugins/{routeManager/httpHandlers → routeManage/actionHandlers}/httpProxy.ts +5 -4
  76. package/src/plugins/routeManage/mod.ts +92 -0
  77. package/src/plugins/webhooks/mod.ts +134 -94
  78. package/src/server.ts +28 -21
  79. package/src/types.ts +11 -14
  80. package/dist/core/httpHandler.d.ts +0 -18
  81. package/dist/core/plugin.d.ts +0 -6
  82. package/dist/helpers/runCollectionEntityHttpHandler.d.ts +0 -5
  83. package/dist/plugins/authManager/httpHandlers/createSession.d.ts +0 -8
  84. package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +0 -4
  85. package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +0 -4
  86. package/dist/plugins/authManager/mod.d.ts +0 -16
  87. package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +0 -4
  88. package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +0 -4
  89. package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +0 -4
  90. package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +0 -4
  91. package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +0 -4
  92. package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +0 -4
  93. package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +0 -4
  94. package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +0 -4
  95. package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +0 -4
  96. package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +0 -4
  97. package/dist/plugins/dataManager/mod.d.ts +0 -16
  98. package/dist/plugins/fileManager/httpHandlers/downloadDocument.d.ts +0 -4
  99. package/dist/plugins/fileManager/httpHandlers/downloadFile.d.ts +0 -4
  100. package/dist/plugins/fileManager/httpHandlers/uploadFile.d.ts +0 -4
  101. package/dist/plugins/fileManager/mod.d.ts +0 -15
  102. package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +0 -4
  103. package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +0 -4
  104. package/dist/plugins/metaManager/mod.d.ts +0 -15
  105. package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +0 -4
  106. package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +0 -4
  107. package/dist/plugins/routeManager/mod.d.ts +0 -15
  108. package/src/core/httpHandler.ts +0 -29
  109. package/src/core/plugin.ts +0 -13
  110. package/src/plugins/authManager/mod.ts +0 -56
  111. package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +0 -22
  112. package/src/plugins/dataManager/mod.ts +0 -154
  113. package/src/plugins/fileManager/mod.ts +0 -48
  114. package/src/plugins/routeManager/mod.ts +0 -97
  115. /package/dist/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.d.ts +0 -0
  116. /package/dist/plugins/{authManager → auth}/models/AccessToken.d.ts +0 -0
  117. /package/dist/plugins/{authManager → auth}/models/index.d.ts +0 -0
  118. /package/dist/plugins/{authManager → auth}/routes/index.d.ts +0 -0
  119. /package/src/plugins/{authManager → auth}/models/AccessToken.ts +0 -0
  120. /package/src/plugins/{authManager → auth}/models/index.ts +0 -0
  121. /package/src/plugins/{authManager → auth}/routes/index.ts +0 -0
@@ -0,0 +1,8 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
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: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "deleteSession";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "getMyProfile";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, 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
+ registerActionHandlers(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;
@@ -5,7 +5,7 @@ declare const _default: {
5
5
  type: "RESTful";
6
6
  method: "GET";
7
7
  endpoint: string;
8
- handlers: {
8
+ actions: {
9
9
  code: string;
10
10
  }[];
11
11
  };
@@ -5,7 +5,7 @@ declare const _default: {
5
5
  type: "RESTful";
6
6
  method: "POST";
7
7
  endpoint: string;
8
- handlers: {
8
+ actions: {
9
9
  code: string;
10
10
  }[];
11
11
  };
@@ -5,7 +5,7 @@ declare const _default: {
5
5
  type: "RESTful";
6
6
  method: "GET";
7
7
  endpoint: string;
8
- handlers: {
8
+ actions: {
9
9
  code: string;
10
10
  }[];
11
11
  };
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "addEntityRelations";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "countCollectionEntities";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "createCollectionEntitiesBatch";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "createCollectionEntity";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "deleteCollectionEntityById";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "findCollectionEntities";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "findCollectionEntityById";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunQueryDatabaseHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "queryDatabase";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunQueryDatabaseHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "removeEntityRelations";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "updateCollectionEntityById";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions): 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
+ registerActionHandlers(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,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "downloadDocument";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "downloadFile";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "uploadFile";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -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
+ registerActionHandlers(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,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "getMetaModelDetail";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "listMetaModels";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ export declare const code = "listMetaRoutes";
4
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any): Promise<void>;
@@ -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
+ registerActionHandlers(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 { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
+ export declare const code = "httpProxy";
5
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, 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
+ registerActionHandlers(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 { IPluginInstance, RpdApplicationConfig } from "~/types";
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
- export declare function initPlugin(plugin: IPluginInstance, server: IRpdServer): Promise<void>;
22
- export declare function configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
23
- export declare function registerEventHandlers(server: IRpdServer): Promise<void>;
24
- export declare function onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
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
+ registerActionHandlers(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, IPluginInstance, IQueryBuilder, IRpdDataAccessor, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes, RapidServerConfig } from "./types";
2
- import { HttpRequestHandler, IPluginHttpHandler } from "./core/httpHandler";
3
- import { IRpdServer } from "./core/server";
1
+ import { GetDataAccessorOptions, GetModelOptions, IDatabaseAccessor, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes, RapidServerConfig } from "./types";
2
+ import { ActionHandler, IPluginActionHandler } from "./core/actionHandler";
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: IPluginInstance, options: IPluginHttpHandler): void;
20
- getHttpHandlerByCode(code: string): HttpRequestHandler;
20
+ registerActionHandler(plugin: RapidPlugin, options: IPluginActionHandler): void;
21
+ getActionHandlerByCode(code: string): ActionHandler;
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: IPluginInstance, payload: RpdServerEventTypes[K][1]): Promise<void>;
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;
@@ -16,7 +17,7 @@ export interface IDatabaseConfig {
16
17
  export interface IDatabaseAccessor {
17
18
  queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
18
19
  }
19
- export interface RunEntityHttpHandlerOptions {
20
+ export interface RunEntityActionHandlerOptions {
20
21
  /** 模型所在的命名空间 */
21
22
  namespace: string;
22
23
  /** 模型Code的单数表示 */
@@ -49,11 +50,11 @@ export interface GetModelOptions {
49
50
  singularCode: string;
50
51
  }
51
52
  export type RpdServerEventTypes = {
52
- "entity.create": [IPluginInstance, RpdEntityCreateEventPayload];
53
- "entity.update": [IPluginInstance, RpdEntityUpdateEventPayload];
54
- "entity.delete": [IPluginInstance, RpdEntityDeleteEventPayload];
55
- "entity.addRelations": [IPluginInstance, RpdEntityAddRelationsEventPayload];
56
- "entity.removeRelations": [IPluginInstance, RpdEntityRemoveRelationsEventPayload];
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 interface IPluginInstance {
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;
@@ -245,10 +243,10 @@ export interface RpdRoute {
245
243
  type: "RESTful";
246
244
  method: RpdHttpMethod;
247
245
  endpoint: string;
248
- handlers: RpdHttpHandler[];
246
+ actions: RpdRouteActionConfig[];
249
247
  }
250
248
  export type RpdHttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
251
- export interface RpdHttpHandler {
249
+ export interface RpdRouteActionConfig {
252
250
  code: string;
253
251
  config?: any;
254
252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [],
@@ -471,9 +471,9 @@ export default {
471
471
  required: true,
472
472
  },
473
473
  {
474
- name: "handlers",
475
- code: "handlers",
476
- columnName: "handlers",
474
+ name: "actions",
475
+ code: "actions",
476
+ columnName: "actions",
477
477
  type: "json",
478
478
  required: true,
479
479
  },
@@ -488,7 +488,7 @@ export default {
488
488
  type: "RESTful",
489
489
  method: "GET",
490
490
  endpoint: "/_meta/models",
491
- handlers: [
491
+ actions: [
492
492
  {
493
493
  code: "listMetaModels",
494
494
  },
@@ -501,7 +501,7 @@ export default {
501
501
  type: "RESTful",
502
502
  method: "GET",
503
503
  endpoint: "/_meta/models/:namespace/:singularCode",
504
- handlers: [
504
+ actions: [
505
505
  {
506
506
  code: "getMetaModelDetail",
507
507
  },
@@ -514,7 +514,7 @@ export default {
514
514
  type: "RESTful",
515
515
  method: "GET",
516
516
  endpoint: "/_meta/routes",
517
- handlers: [
517
+ actions: [
518
518
  {
519
519
  code: "listMetaRoutes",
520
520
  },
@@ -0,0 +1,23 @@
1
+ import { RpdApplicationConfig } from "~/types";
2
+ import { IRpdServer, RapidPlugin } from "./server";
3
+ import { Next, RouteContext } from "./routeContext";
4
+
5
+ export interface ActionHandlerContext {
6
+ routerContext: RouteContext;
7
+ next: Next;
8
+ server: IRpdServer;
9
+ applicationConfig: RpdApplicationConfig;
10
+ input?: any;
11
+ output?: any;
12
+ status?: Response["status"];
13
+ }
14
+
15
+ export type ActionHandler = (
16
+ ctx: ActionHandlerContext,
17
+ options: any,
18
+ ) => void | Promise<void>;
19
+
20
+ export interface IPluginActionHandler {
21
+ code: string;
22
+ handler: (plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) => void | Promise<void>;
23
+ }