import { Ref } from 'vue'; import { DataSource, DataSourceConfig, DataSourceOptions } from './DataProvider'; interface UseDataSourceOptions extends DataSourceOptions { /** 是否在 onMounted 时自动加载 */ autoLoad?: boolean; /** 监听的参数,参数变化时自动刷新 */ watchParams?: Ref> | (() => Record); /** 参数变化时刷新的数据源 key */ watchKeys?: string[]; } declare function useDataSource(sources: DataSourceConfig | DataSourceConfig[] | any, options?: UseDataSourceOptions): { /** DataSource 实例 */ _sourceInstance: DataSource; /** 融合后的数组数据 */ sourceData: import('vue').Reactive; /** 所有状态 */ sourceState: Record>; /** 全局加载状态 */ isLoading: Ref; /** 全局错误状态 */ hasError: Ref; /** 加载数据 */ loadData: (keys?: string | string[]) => Promise; /** 刷新单个数据源 */ refreshData: (key: string, params?: Record) => Promise | undefined>; /** 兼容旧版 reload 行为 */ reload: (key?: string, params?: Record) => Promise | undefined>; /** 刷新所有数据源 */ refreshAll: (params?: Record>) => Promise; /** 更新数据 */ updateData: (key: string, newData: T) => Promise; /** 获取状态 */ getState: (key: string) => import('./DataProvider').DataSourceState; /** 融合数据(调用 DataSource 的 mergeData) */ mergeData: (transformer?: (dataMap: { [x: string]: any; }) => T[]) => T[]; /** 添加数据更新监听器 */ onDataUpdate: (listener: import('./DataProvider').DataUpdateListener) => () => void; /** 清除数据 */ clear: () => void; /** 销毁实例 */ destroy: () => void; }; /** * 处理静态数据,将其转换为数组格式 * @param data 静态数据,可能是数字、字符串、数组或对象 * @param dataField 如果数据是数字、字符串,指定dataField作为数组元素的键 * @returns 转换后的数组格式数据 */ declare const convertDataToArray: (data: any, dataField?: any) => Promise; /** * 判断是否是 DataSource 类实例 */ declare function isSourceClass(val: any): val is DataSource; /** * 判断是否是 useDataSource 返回的实例 */ declare function isSourceHook(val: any): val is ReturnType; /** * 创建调试右键点击处理器 * @param dbOptions 组件的数据源配置对象 * @returns 右键点击事件处理器 */ declare function createDebugHandler(dbOptions?: any): (e: MouseEvent) => Promise; export { useDataSource, isSourceHook, isSourceClass, convertDataToArray, createDebugHandler, type UseDataSourceOptions, };