REFACTOR: create builder for parser reporterand fix pdf

This commit is contained in:
marcos-silva-rodrigues
2025-04-29 15:18:46 -03:00
parent 04accb6689
commit 36997403e1
9 changed files with 129 additions and 76 deletions
+29
View File
@@ -0,0 +1,29 @@
import path from 'path';
import { TypeParser } from './parser-types';
import { HtmlParser } from './html-parser';
import { CsvParser } from './csv-parser';
import { PDFParser } from './pdf-parser';
import { Parser } from './parser.interface';
export class ParserBuilder {
static build<T>(type: TypeParser): Parser<T> {
const templatePath = path.join(
__dirname,
'../../../src/template/pii-reporter.html',
);
if (type === 'html') {
const htmlParser = new HtmlParser<T>(templatePath);
return htmlParser;
} else if (type === 'csv') {
const csvParser = new CsvParser<T>();
return csvParser;
} else if (type === 'pdf') {
const htmlParser = new HtmlParser<T>(templatePath);
const pdfParser = new PDFParser(htmlParser);
return pdfParser;
}
throw new Error('Unsupported Type: ' + type);
}
}