@ruiapp/rapid-core 0.1.8 → 0.1.9

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.
@@ -18,18 +18,18 @@ declare class PluginManager {
18
18
  /** 注册任务处理程序 */
19
19
  registerTaskProcessors(): Promise<void>;
20
20
  /** 在加载应用前调用。 */
21
- onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
21
+ onLoadingApplication(applicationConfig: RpdApplicationConfig): Promise<void>;
22
22
  /** 配置数据模型 */
23
- configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
23
+ configureModels(applicationConfig: RpdApplicationConfig): Promise<void>;
24
24
  /** 配置模型属性 */
25
- configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
25
+ configureModelProperties(applicationConfig: RpdApplicationConfig): Promise<void>;
26
26
  /** 配置路由 */
27
- configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
27
+ configureRoutes(applicationConfig: RpdApplicationConfig): Promise<void>;
28
28
  /** 在应用配置加载完成后调用。此时插件可以进行一些数据的初始化工作。 */
29
- onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
29
+ onApplicationLoaded(applicationConfig: RpdApplicationConfig): Promise<void>;
30
30
  /** 在应用准备完成后调用。此时服务器已经可以处理网络请求。 */
31
- onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
31
+ onApplicationReady(applicationConfig: RpdApplicationConfig): Promise<void>;
32
32
  /** 在接收到HTTP请求,准备路由上下文时调用。 */
33
- onPrepareRouteContext(server: IRpdServer, routeContext: RouteContext): Promise<void>;
33
+ onPrepareRouteContext(routeContext: RouteContext): Promise<void>;
34
34
  }
35
35
  export default PluginManager;
@@ -1,6 +1,7 @@
1
1
  import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes } from "../types";
2
2
  import { IPluginActionHandler, ActionHandler } from "./actionHandler";
3
3
  import { Next, RouteContext } from "./routeContext";
4
+ import EntityManager from "../dataAccess/entityManager";
4
5
  export interface IRpdServer {
5
6
  config: RapidServerConfig;
6
7
  databaseConfig: IDatabaseConfig;
@@ -11,6 +12,7 @@ export interface IRpdServer {
11
12
  registerActionHandler(plugin: RapidPlugin, options: IPluginActionHandler): void;
12
13
  getActionHandlerByCode(code: string): ActionHandler | undefined;
13
14
  getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
15
+ getEntityManager(singularCode: string): EntityManager;
14
16
  getApplicationConfig(): RpdApplicationConfig;
15
17
  appendApplicationConfig(config: Partial<RpdApplicationConfig>): any;
16
18
  getModel(options: GetModelOptions): RpdDataModel | undefined;
@@ -1,6 +1,14 @@
1
- import { CreateEntityOptions, FindEntityOptions, IRpdDataAccessor, UpdateEntityByIdOptions } from "../types";
1
+ import { CountEntityOptions, CountEntityResult, CreateEntityOptions, FindEntityOptions, IRpdDataAccessor, RpdDataModel, UpdateEntityByIdOptions } from "../types";
2
2
  import { IRpdServer } from "../core/server";
3
- export declare function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: FindEntityOptions): Promise<any[]>;
4
- export declare function findEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: FindEntityOptions): Promise<any>;
5
- export declare function createEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: CreateEntityOptions): Promise<any>;
6
- export declare function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: UpdateEntityByIdOptions): Promise<any>;
3
+ export default class EntityManager<TEntity = any> {
4
+ #private;
5
+ constructor(server: IRpdServer, dataAccessor: IRpdDataAccessor);
6
+ findEntities(options: FindEntityOptions): Promise<TEntity[]>;
7
+ findEntity(options: FindEntityOptions): Promise<TEntity | null>;
8
+ findById(id: any): Promise<TEntity | null>;
9
+ createEntity(options: CreateEntityOptions): Promise<TEntity>;
10
+ updateEntityById(options: UpdateEntityByIdOptions): Promise<TEntity>;
11
+ count(options: CountEntityOptions): Promise<CountEntityResult>;
12
+ deleteById(id: any): Promise<void>;
13
+ getModel(): RpdDataModel;
14
+ }
@@ -1,5 +1,6 @@
1
- import { IRpdDataAccessor, RunEntityActionHandlerOptions } from "../types";
1
+ import { RunEntityActionHandlerOptions } from "../types";
2
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>;
3
+ import EntityManager from "../dataAccess/entityManager";
4
+ type EntityActionHandler = (entityManager: EntityManager, input: any) => Promise<any>;
5
+ export default function runCollectionEntityActionHandler(ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions, code: string, handleEntityAction: EntityActionHandler): Promise<void>;
5
6
  export {};