feat(core): improve in-memory validation, FatturaPA detection coverage, and published type compatibility

This commit is contained in:
2026-04-16 20:30:56 +00:00
parent 55bee02a2e
commit 3f37f6538c
60 changed files with 5723 additions and 6678 deletions
+27 -25
View File
@@ -78,33 +78,35 @@ tap.test('Format Detection - PEPPOL large invoice samples', async () => {
tap.test('Format Detection - FatturaPA Italian invoice format', async () => {
const files = await TestFileHelpers.getTestFiles(TestFileCategories.FATTURAPA, '*.xml');
console.log(`Testing ${files.length} FatturaPA files`);
if (files.length === 0) {
const syntheticFatturaPa = `<?xml version="1.0"?>
<FatturaElettronica xmlns="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2">
<FatturaElettronicaHeader />
</FatturaElettronica>`;
const format = FormatDetector.detectFormat(syntheticFatturaPa);
expect(format).toEqual(InvoiceFormat.FATTURAPA);
console.log('✓ Synthetic FatturaPA XML is detected correctly');
return;
}
let detectedCount = 0;
for (const file of files) {
try {
const xmlBuffer = await TestFileHelpers.loadTestFile(file);
const xmlString = xmlBuffer.toString('utf-8');
const { result: format, duration } = await PerformanceUtils.measure(
'fatturapa-detection',
async () => FormatDetector.detectFormat(xmlString)
);
// FatturaPA detection might not be fully implemented yet
if (format === InvoiceFormat.FATTURAPA) {
detectedCount++;
}
console.log(`${format === InvoiceFormat.FATTURAPA ? '✓' : '○'} ${path.basename(file)}: ${format} (${duration.toFixed(2)}ms)`);
} catch (error) {
console.log(`${path.basename(file)}: Error - ${error.message}`);
}
}
// Log if FatturaPA detection needs implementation
if (detectedCount === 0 && files.length > 0) {
console.log('Note: FatturaPA format detection may need implementation');
const xmlBuffer = await TestFileHelpers.loadTestFile(file);
const xmlString = xmlBuffer.toString('utf-8');
const { result: format, duration } = await PerformanceUtils.measure(
'fatturapa-detection',
async () => FormatDetector.detectFormat(xmlString)
);
expect(format).toEqual(InvoiceFormat.FATTURAPA);
detectedCount++;
console.log(`${path.basename(file)}: ${format} (${duration.toFixed(2)}ms)`);
}
expect(detectedCount).toEqual(files.length);
});
// Test format detection for EN16931 examples
@@ -263,4 +265,4 @@ tap.test('Format Detection - Confidence scoring', async () => {
// expect(result.confidence).toBeGreaterThan(0.8);
});
tap.start();
tap.start();