import { actionCreators } from '../Container/action'; import { BasicConfig, ContainerProps } from '../Container/types'; /** * Provider 对象数据源配置 */ export interface ProviderSourceConfig { /** * provider模式 */ mode: string; /** * Provider配置 */ config?: any; /** * 请求发起所依赖的参数 */ requiredParams?: string[]; /** * 不仅判断参数的key,同样如果每个参数的value转义之后都是true */ strictRequired?: boolean; /** * Provider命名空间 */ namespace?: string; /** * Provider返回值映射[弃用] */ retMapping?: Object; /** * Provider返回值映射 */ responseRewrite?: Object; /** * 返回值检查Expression String */ retCheckPattern?: string; /** * 错误弹出的错误提示 */ retErrMsg?: string; /** * 调试默认 */ debug?: boolean; __previousConfig?: ProviderSourceConfig | null; } /** * Provider 对象全局配置 */ export interface ProviderGlobalOptions { /** * 代理服务配置 */ proxy?: string; } export interface ProviderActions { /** * 同步批量写入数据 */ setDataList: typeof actionCreators.setDataList; /** * 异步加载中 */ asyncLoadDataProgress: typeof actionCreators.asyncLoadDataProgress; /** * 异步加载成功 */ asyncLoadDataSuccess: typeof actionCreators.asyncLoadDataSuccess; /** * 异步加载失败 */ asyncLoadDataFail: typeof actionCreators.asyncLoadDataFail; /** * 同步加载成功 */ syncLoadDataSuccess: typeof actionCreators.syncLoadDataSuccess; /** * 同步加载失败 */ syncLoadDataFail: typeof actionCreators.syncLoadDataFail; } export interface BasicSyncProviderInterface { configCheck(provider: ProviderSourceConfig): boolean; retCheck(ret: Object, provider: ProviderSourceConfig, props: ContainerProps, context: any): boolean; retParse(ret: Object, provider: ProviderSourceConfig, props: ContainerProps, context: any): Object; parse(provider: ProviderSourceConfig, config: ContainerProps, context: any): ProviderSourceConfig; run(provider: ProviderSourceConfig, options?: ProviderGlobalOptions): any; onError(errmsg: string, e?: Error): void; } export interface BasicAsyncProviderInterface { configCheck(provider: ProviderSourceConfig): boolean; retCheck(ret: Object, provider: ProviderSourceConfig, props: ContainerProps, context: any): boolean; retParse(ret: Object, provider: ProviderSourceConfig, props: ContainerProps, context: any): Object; parse(provider: ProviderSourceConfig, config: ContainerProps, context: any): ProviderSourceConfig; run(provider: ProviderSourceConfig, options?: ProviderGlobalOptions): Promise; onError(errmsg: string, e?: Error): void; } /** * DataProvider 是一个数据源控制器 * 它通过为Container组件提供一个单一, 简单的API调用. 来对各种各样的数据获取操作进行封装 * 它支持控制同步的数据和异步的数据操作. 获取到目标数据之后, * DataProvider会触发action来写入数据到redux store * * 流程图可参考 * src/doc/graphic/dataFlow.png * * 同步的操作会触发一个action, 并进行同步写入 * 异步的操作会有3个运行状态: * * 1. before(异步运行前) * 2. progress(异步运行中) * 3.1 success(异步运行成功) * 3.2 fail(异步运行失败) */ export declare class DataProvider { private getRequestData(providerConfig, props, context); private updateData(providerConfig, actions, info, props, context); requestForData(providerConfig: ProviderSourceConfig[], actions: ProviderActions, info: BasicConfig, props: ContainerProps, context: any): void; }