diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index b10a8b0a69..ad8a632480 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -51,7 +51,19 @@ export interface DataFetchParams< API: APIClient datasource: TDatasource query: TQuery - options?: {} + options?: Partial> +} + +export interface DataFetchOptions { + // Search config + filter: UISearchFilter | LegacyFilter[] | null + query: TQuery + // Sorting config + sortColumn: string | null + sortOrder: SortOrder + // Pagination config + limit: number + paginate: boolean } /** @@ -73,18 +85,11 @@ export default abstract class DataFetch< supportsSort: boolean supportsPagination: boolean } - options: { + options: DataFetchOptions & { datasource: TDatasource - limit: number - // Search config - filter: UISearchFilter | LegacyFilter[] | null - query: TQuery - // Sorting config - sortColumn: string | null - sortOrder: SortOrder + sortType: SortType | null - // Pagination config - paginate: boolean + // Client side feature customisation clientSideSearching: boolean clientSideSorting: boolean diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index d80aa10df6..4b9de01dae 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -32,7 +32,15 @@ export const DataFetchMap = { } // Constructs a new fetch model for a certain datasource -export const fetchData = ({ API, datasource, options }: any) => { +export const fetchData = ({ + API, + datasource, + options, +}: { + API: APIClient + datasource: TDatasource + options: any +}) => { const Fetch = DataFetchMap[datasource?.type as DataFetchType] || TableFetch const fetch = new Fetch({ API, datasource, ...options })