@ruiapp/rapid-core 0.1.18 → 0.1.20

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 (36) hide show
  1. package/dist/core/pluginManager.d.ts +3 -0
  2. package/dist/core/routeContext.d.ts +1 -0
  3. package/dist/core/server.d.ts +6 -2
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +189 -93
  6. package/dist/plugins/entityAccessControl/EntityAccessControlPlugin.d.ts +17 -0
  7. package/dist/plugins/entityWatch/EntityWatchPluginTypes.d.ts +3 -2
  8. package/dist/plugins/fileManage/FileManagePlugin.d.ts +0 -10
  9. package/dist/server.d.ts +4 -2
  10. package/dist/types.d.ts +11 -0
  11. package/dist/utilities/accessControlUtility.d.ts +5 -0
  12. package/package.json +2 -2
  13. package/rollup.config.js +1 -18
  14. package/src/core/pluginManager.ts +12 -0
  15. package/src/core/routeContext.ts +1 -0
  16. package/src/core/routesBuilder.ts +9 -4
  17. package/src/core/server.ts +6 -2
  18. package/src/dataAccess/dataAccessor.ts +7 -7
  19. package/src/dataAccess/entityManager.ts +24 -24
  20. package/src/helpers/inputHelper.ts +3 -3
  21. package/src/helpers/runCollectionEntityActionHandler.ts +1 -2
  22. package/src/index.ts +2 -1
  23. package/src/plugins/auth/AuthPlugin.ts +0 -1
  24. package/src/plugins/dataManage/DataManagePlugin.ts +0 -1
  25. package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +0 -1
  26. package/src/plugins/dataManage/actionHandlers/queryDatabase.ts +2 -2
  27. package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +104 -0
  28. package/src/plugins/entityWatch/EntityWatchPlugin.ts +1 -2
  29. package/src/plugins/entityWatch/EntityWatchPluginTypes.ts +11 -2
  30. package/src/plugins/fileManage/FileManagePlugin.ts +0 -31
  31. package/src/plugins/metaManage/MetaManagePlugin.ts +6 -6
  32. package/src/plugins/webhooks/WebhooksPlugin.ts +2 -2
  33. package/src/queryBuilder/queryBuilder.ts +3 -3
  34. package/src/server.ts +31 -9
  35. package/src/types.ts +13 -0
  36. package/src/utilities/accessControlUtility.ts +33 -0
@@ -1,6 +1,7 @@
1
1
  import { RpdApplicationConfig } from "../types";
2
2
  import { IRpdServer, RapidPlugin } from "./server";
3
3
  import { RouteContext } from "./routeContext";
4
+ import { ActionHandlerContext } from "./actionHandler";
4
5
  declare class PluginManager {
5
6
  #private;
6
7
  constructor(server: IRpdServer);
@@ -31,5 +32,7 @@ declare class PluginManager {
31
32
  onApplicationReady(applicationConfig: RpdApplicationConfig): Promise<void>;
32
33
  /** 在接收到HTTP请求,准备路由上下文时调用。 */
33
34
  onPrepareRouteContext(routeContext: RouteContext): Promise<void>;
35
+ /** 在接收到HTTP请求,执行 actions 前调用。 */
36
+ beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>;
34
37
  }
35
38
  export default PluginManager;
@@ -9,6 +9,7 @@ export declare class RouteContext {
9
9
  method: string;
10
10
  path: string;
11
11
  params: Record<string, string>;
12
+ routeConfig: any;
12
13
  constructor(request: RapidRequest);
13
14
  set(headerName: string, headerValue: string): void;
14
15
  json(obj: any, status?: HttpStatus, headers?: HeadersInit): void;
@@ -1,5 +1,5 @@
1
- import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes } from "../types";
2
- import { IPluginActionHandler, ActionHandler } from "./actionHandler";
1
+ import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdDataModelProperty, RpdServerEventTypes } from "../types";
2
+ import { IPluginActionHandler, ActionHandler, ActionHandlerContext } from "./actionHandler";
3
3
  import { Next, RouteContext } from "./routeContext";
4
4
  import EntityManager from "../dataAccess/entityManager";
5
5
  export interface IRpdServer {
@@ -15,10 +15,12 @@ export interface IRpdServer {
15
15
  getEntityManager<TEntity = any>(singularCode: string): EntityManager<TEntity>;
16
16
  getApplicationConfig(): RpdApplicationConfig;
17
17
  appendApplicationConfig(config: Partial<RpdApplicationConfig>): any;
18
+ appendModelProperties(modelSingularCode: string, properties: RpdDataModelProperty[]): any;
18
19
  getModel(options: GetModelOptions): RpdDataModel | undefined;
19
20
  registerEventHandler<K extends keyof RpdServerEventTypes>(eventName: K, listener: (...args: RpdServerEventTypes[K]) => void): this;
20
21
  emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender: RapidPlugin, payload: RpdServerEventTypes[K][1]): void;
21
22
  handleRequest(request: Request, next: Next): Promise<Response>;
23
+ beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>;
22
24
  }
23
25
  export type RpdConfigurationItemTypes = "integer" | "text" | "boolean" | "date" | "datetime" | "json";
24
26
  export interface RpdConfigurationItemOptions {
@@ -85,4 +87,6 @@ export interface RapidPlugin {
85
87
  onApplicationReady?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
86
88
  /** 在接收到HTTP请求,准备路由上下文时调用。 */
87
89
  onPrepareRouteContext?: (server: IRpdServer, routeContext: RouteContext) => Promise<any>;
90
+ /** 在接收到HTTP请求,执行 actions 前调用。 */
91
+ beforeRunRouteActions?: (server: IRpdServer, handlerContext: ActionHandlerContext) => Promise<any>;
88
92
  }
package/dist/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export { default as ServerOperationPlugin } from "./plugins/serverOperation/Serv
17
17
  export * from "./plugins/serverOperation/ServerOperationPluginTypes";
18
18
  export { default as EntityWatchPlugin } from "./plugins/entityWatch/EntityWatchPlugin";
19
19
  export * from "./plugins/entityWatch/EntityWatchPluginTypes";
20
+ export { default as EntityAccessControlPlugin } from "./plugins/entityAccessControl/EntityAccessControlPlugin";