/// import { ParseConfig } from "papaparse"; import { MapDataFn, BaseRecord, HttpError, MetaDataQuery } from "../../interfaces"; import { UseCreateReturnType } from "../../hooks/data/useCreate"; import { UseCreateManyReturnType } from "../../hooks/data/useCreateMany"; export declare type ImportSuccessResult = { request: TVariables[]; type: "success"; response: TData[]; }; export declare type ImportErrorResult = { request: TVariables[]; type: "error"; response: HttpError[]; }; export declare type OnFinishParams = { succeeded: ImportSuccessResult[]; errored: ImportErrorResult[]; }; export declare type OnProgressParams = { totalAmount: number; processedAmount: number; }; export declare type ImportOptions = { /** * Resource name for API data interactions. * @default Resource name that it reads from route */ resourceName?: string; /** * A mapping function that runs for every record. Mapped data will be included in the file contents. */ mapData?: MapDataFn; /** * Custom Papa Parse options. * @type [`ParseConfig`](https://www.papaparse.com/docs) */ paparseOptions?: ParseConfig; /** * Requests batch size. If it is 1, all records are sent one by one. By default, it is [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) to send all records in one batch. If it is more than 1, `createMany` should be implemented on DataProvider. */ batchSize?: number; /** * Called with errors and successful responses when all requests are sent. */ onFinish?: (results: OnFinishParams) => void; /** * Metadata query for `dataProvider` */ metaData?: MetaDataQuery; /** * A callback function that returns a current state of uploading process. * * Ex: `percentage = onProgressParams.processedAmount / onProgressParams.totalAmount * 100` */ onProgress?: (onProgressParams: OnProgressParams) => void; /** * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use. */ dataProviderName?: string; }; export declare type CreatedValuesType = ImportSuccessResult | ImportErrorResult; export declare type HandleChangeType = (onChangeParams: { file: Partial; }) => Promise[]>; export declare type UseImportInputPropsType = { type: "file"; accept: string; onChange: (event: React.ChangeEvent) => void; }; export declare type UseImportReturnType = { inputProps: UseImportInputPropsType; mutationResult: UseCreateReturnType | UseCreateManyReturnType; isLoading: boolean; handleChange: HandleChangeType; }; /** * `useImport` hook allows you to handle your csv import logic easily. * * @see {@link https://refine.dev/docs/core/hooks/import-export/useImport} for more details. * * @typeParam TItem - Interface of parsed csv data * @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-references/interfaceReferences#baserecord `BaseRecord`} * @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-references/interfaceReferences#httperror `HttpError`} * @typeParam TVariables - Values for mutation function * */ export declare const useImport: ({ resourceName, mapData, paparseOptions, batchSize, onFinish, metaData, onProgress, dataProviderName, }?: ImportOptions) => UseImportReturnType; //# sourceMappingURL=index.d.ts.map