import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams, GridGetRowsOptions } from "../../../models/gridDataSource.mjs"; import type { GridRowId, GridRowModel, GridRowModelReplace, GridRowModelUpdate } from "../../../models/gridRows.mjs"; import type { GridDataSourceCacheDefaultConfig } from "./cache.mjs"; /** * The parameters for the `fetchRows` method. */ export type GridDataSourceFetchRowsParams = Partial & GridGetRowsOptions; export interface GridDataSourceFetchRowChildrenOptions { showChildrenLoading?: boolean; } export interface GridDataSourceApi { /** * The data source API. */ dataSource: { /** * Fetches the rows from the server. * If no `parentId` option is provided, it fetches the root rows. * Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.). * @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`). * @param {GridDataSourceFetchRowsParams} params Request parameters override. * @returns {Promise} A promise that resolves when the rows are fetched. */ fetchRows: (parentId?: GridRowId, params?: GridDataSourceFetchRowsParams) => Promise; /** * The data source cache object. */ cache: GridDataSourceCache; /** * Syncs the row with the server and updates in the grid. * @param {GridUpdateRowParams} params The parameters for the edit operation. * @returns {Promise | undefined} The updated row or `undefined` if `dataSource.updateRow` is not passed. */ editRow: (params: GridUpdateRowParams) => Promise | undefined; }; } export interface GridDataSourceApiBase { fetchRows: GridDataSourceApi['dataSource']['fetchRows']; cache: GridDataSourceApi['dataSource']['cache']; editRow: GridDataSourceApi['dataSource']['editRow']; } export interface GridDataSourceBaseOptions { cacheOptions?: GridDataSourceCacheDefaultConfig; fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void; clearDataSourceState?: () => void; handleEditRow?: (params: GridUpdateRowParams, rowUpdate: GridRowModelUpdate | GridRowModelReplace) => void; }