import { BaseContext } from '../types';
import { IRowNode } from 'ag-grid-enterprise';
/**
 * Options for managing the Data Import function
 */
export interface DataImportOptions<T = Record<string, any>> {
    /**
     * Custom File Handlers to use for Data Import
     */
    fileHandlers?: DataImportFileHandler<T>[];
    /**
     * Handles Importing Data using text
     */
    textHandler?: (text: string) => T[] | Promise<T[]>;
    /**
     * Function to validate the Imported Data
     */
    validate?: (context: DataImportValidateContext<T>) => DataImportValidationError[] | undefined;
    /**
     * Function to handle the Imported Data and apply it to the Grid. If not provided then the Data will be applied to the Grid automatically.
     */
    handleImportedData?: (context: HandleImportedDataContext<T>) => Promise<void | HandleImportedDataResolution>;
    /**
     * Function to pre-process the data before it is imported
     *
     * @experimental It might change in a future version
     */
    _preprocessRowData?: (context: PreprocessRowDataContext<T>) => Record<string, any>;
    /**
     * Function to get the Primary Key value for a data row (defaults to value of the primaryKey column)
     *
     * @experimental It might change in a future version
     */
    _getPrimaryKeyValue?: (context: GetPrimaryKeyValueContext<T>) => string | number;
}
/**
 * Context used when pre-processing Import Data
 */
export interface PreprocessRowDataContext<T = Record<string, any>> extends BaseContext {
    /**
     * Data which has been imported
     */
    rowData: T;
}
/**
 * Context used when importing Data
 */
export interface HandleImportedDataContext<T = Record<string, any>> extends BaseContext {
    /**
     * Data which has been imported
     */
    data: T[];
}
/**
 * Files that can be handled by Data Import
 */
export interface DataImportFileHandler<T = Record<string, any>> {
    /**
     * Name of File Extension
     */
    fileExtension?: string;
    /**
     * Async function which handles the import returning a Data Record
     */
    handleFile: (file: File) => Promise<T[]>;
}
/**
 * Defines a Validation Error
 */
export interface DataImportValidationError {
    /**
     * Column which contains the Error
     */
    columnId: string;
    /**
     * The validatoin error text
     */
    error: string;
}
/**
 * Context passed to the `validate` function
 */
export interface DataImportValidateContext<T = Record<string, any>> extends BaseContext {
    /**
     * Imported Row Data
     */
    rowData: T;
}
/**
 * Context passed to the `getPrimaryKeyValue` function
 */
export interface GetPrimaryKeyValueContext<T = Record<string, any>> extends BaseContext {
    /**
     * Data being imported
     */
    rowData: T;
}
/**
 * Resolution returned by the `handleImportedData` function
 */
export interface HandleImportedDataResolution {
    /**
     * Whether to emit the `DataImported` event
     */
    emitDataImportedEvent: boolean;
    /**
     * Rows that were added
     */
    addedRows: IRowNode[];
    /**
     * Rows that were updated
     */
    updatedRows: IRowNode[];
}
