import ImportRecord from './ImportRecord'; import { Pipe } from './PipeParser'; import Validator from './Validator'; import Transformer from './Transformer'; import { MetricsTracker } from './MetricsTracker'; export default class ReviewProcessor { private readonly headers; private readonly records; private readonly transformer; private readonly transformers; private readonly validator; private readonly validators; private readonly onUniqueErrorsChange; private readonly onErrorCountChange; private readonly config; private readonly metricsTracker?; private processedIndex; private errorsCount; private uniqueErrors; private processing; private withContext; private validationStopwatch?; constructor(headers: string[], records: ImportRecord[], transformer: Transformer, transformers: { [key: string]: Pipe[]; } | undefined, validator: Validator, validators?: { [key: string]: Pipe[]; }, onUniqueErrorsChange?: (uniqueErrors: { [key: string]: number; }) => void, onErrorCountChange?: (errorsCount: number) => void, config?: { startWith: number; batchSize: number; }, metricsTracker?: MetricsTracker | undefined); start(): Promise; /** * Returns true if there are still records to process * * @returns boolean */ inProgress(): boolean; /** * It resets and reprocesses the errors and unique errors for all records. * Useful when the records have been updated. * * @returns void */ refresh(): void; /** * Reprocess an already processed record * We are not going through transformers again to avoid changing user input * but also to run the same transformer twice. * * @param records all records * @param recordIndex the record to reprocess */ reprocessRecord(records: ImportRecord[], recordIndex: number): Promise; /** * Reprocess a large number of already processed records * We are not going through transformers again to avoid changing user input * but also to run the same transformer twice. * @returns */ reprocessRecords(records: ImportRecord[], filteredRecords: number[]): Promise; getErrorsCount(): number; getUniqueErrors(): Map; /** * Process records in background to avoid blocking the main thread * * @param size number of records to process. If not provided, it defaults to the batch size from the config */ private processNextBatch; }