import type { LoggerInterface } from '../logger/index.js'; import type { ParserInterface } from './parser/ParserInterface.js'; import type { TableInterface } from '../model/index.js'; import type { ImporterInterface } from '../importer-xlsx/index.js'; export declare const TABLE_END_KEY = ""; export declare const START_ROW = 0; export declare const START_COLUMN = 0; export interface FileProcessorOptions { /** The logger for this file processor */ logger?: LoggerInterface; /** * The importer will load only tables wich match the given keys * The key value must be in the first cell of the table defined by * start_row and start_column * The keys are not case sensitive */ tableTypeKeys?: string[]; } /** Strores the sheet definition by its sheet name */ type SheetDefinition = Record; interface SheetDefinitionEntry { startRow: number; startColumn: number; endKey: string; } /** * The file processor. */ export declare class FileProcessor { /** The logger for this file processor */ logger: LoggerInterface; /** Stores importer for file extensions. So the extension of a file defines which importer is used. */ importerMap: Map; /** for every loaded file there may be different type of tables in one Spreadsheet. * This map has a parser for the different table types. The processor reads the value * in the first cell. This value is the table type. Then the processor looks up * if there is a parser registered for this table type. */ parserMap: Map; /** * Defines the start column and row per sheetName. Also which key is used * to find the end of a row or the last column. * This map stores the definition per sheet name. * The format of ths definition is: * \{ * startRow: 0, * startColumn: 0, * endKey: '\', * \} */ sheetDefinition: SheetDefinition; /** * The importer will load only tables wich match the given keys * The key value must be in the first cell of the table defined by * start_row and start_column * The keys are not case sensitive */ tableTypeKeys: string[]; /** Stores the loaded tables by its name */ private _tables; constructor(opts?: FileProcessorOptions); /** * Returns all the laoded table models * @returns A list of tables */ get tables(): TableInterface[]; /** * Delets all the loaded tables */ clearTables(): void; /** * Loads a list of files * @param fileNames - The file(s) to open */ load(fileNames: string | string[]): Promise; /** * Adds a new table to the loaded tables * @param sheetName - The name of the table * @param tableModel - The table itself */ private addTable; /** * Processes the sheets imported by the importer. * @param importer - The sheet importer * @param fileName - The name of the file */ private processImporter; /** * Registers an importer for a file extension. The extension are * not case sensitive * @param extension - The file extension. For Example 'xlsx' * @param importer - An instance of an importer */ registerImporter(extension: string, importer: ImporterInterface): void; /** * Returns an instance of a step class * @param fileName - The name of the file to import * @returns The importer for this file or throws an exception */ getImporter(fileName: string): ImporterInterface; /** * Registers a parser for a table type * @param type - The table type * @param parser - The parser to use */ registerParser(type: string, parser: ParserInterface): void; /** * Returns an instance of a step class * @param type - type of the table * @returns The parser for this table type or undefined */ getParser(type: string): ParserInterface; /** * Sets a config for a sheet name. Each sheet may have different configs * @param sheetName - The name of the sheet * @param config - A config for the sheet. */ setSheetConfig(sheetName: string, config?: SheetDefinitionEntry): void; /** * Returns the startRow for a given sheetName. * If there is no definition for the sheetName * The default definition will be returned. * @param sheetName - Optional: The name of the sheet * @returns The row number to start reading */ private getSheetStartRow; /** * Returns the startColumn for a given sheetName. * If there is no definition for the sheetName * The default definition will be returned. * @param sheetName - Optional: The name of the sheet * @returns startColumn The column number */ private getSheetStartColumn; /** * Returns the endKey for a given sheetName. * If there is no definition for the sheetName * The default definition will be returned. * @param sheetName - Optional: The name of the sheet * @returns The endKey for this sheet */ private getSheetEndKey; } export {}; //# sourceMappingURL=FileProcessor.d.ts.map