feat(core): improve in-memory validation, FatturaPA detection coverage, and published type compatibility
This commit is contained in:
@@ -1,49 +1,59 @@
|
||||
#!/usr/bin/env node
|
||||
/// <reference types="node" />
|
||||
|
||||
/**
|
||||
* Script to download official Schematron files for e-invoice validation
|
||||
*/
|
||||
|
||||
import { SchematronDownloader } from '../dist_ts/formats/validation/schematron.downloader.js';
|
||||
const schematronDownloaderModulePath = '../dist_ts/formats/validation/schematron.downloader.js';
|
||||
|
||||
async function createDownloader() {
|
||||
const { SchematronDownloader } = await import(schematronDownloaderModulePath);
|
||||
const downloader = new SchematronDownloader('assets_downloaded/schematron');
|
||||
await downloader.initialize();
|
||||
return downloader;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('📥 Starting Schematron download...\n');
|
||||
|
||||
const downloader = new SchematronDownloader('assets_downloaded/schematron');
|
||||
await downloader.initialize();
|
||||
const downloader = await createDownloader();
|
||||
|
||||
// Download EN16931 Schematron files
|
||||
console.log('🔵 Downloading EN16931 Schematron files...');
|
||||
try {
|
||||
const en16931Paths = await downloader.downloadStandard('EN16931');
|
||||
console.log(`✅ Downloaded ${en16931Paths.length} EN16931 files`);
|
||||
en16931Paths.forEach(p => console.log(` - ${p}`));
|
||||
en16931Paths.forEach((p: string) => console.log(` - ${p}`));
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to download EN16931: ${error.message}`);
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
console.error(`❌ Failed to download EN16931: ${errorMessage}`);
|
||||
}
|
||||
|
||||
console.log('\n🔵 Downloading PEPPOL Schematron files...');
|
||||
try {
|
||||
const peppolPaths = await downloader.downloadStandard('PEPPOL');
|
||||
console.log(`✅ Downloaded ${peppolPaths.length} PEPPOL files`);
|
||||
peppolPaths.forEach(p => console.log(` - ${p}`));
|
||||
peppolPaths.forEach((p: string) => console.log(` - ${p}`));
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to download PEPPOL: ${error.message}`);
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
console.error(`❌ Failed to download PEPPOL: ${errorMessage}`);
|
||||
}
|
||||
|
||||
console.log('\n🔵 Downloading XRechnung Schematron files...');
|
||||
try {
|
||||
const xrechnungPaths = await downloader.downloadStandard('XRECHNUNG');
|
||||
console.log(`✅ Downloaded ${xrechnungPaths.length} XRechnung files`);
|
||||
xrechnungPaths.forEach(p => console.log(` - ${p}`));
|
||||
xrechnungPaths.forEach((p: string) => console.log(` - ${p}`));
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to download XRechnung: ${error.message}`);
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
console.error(`❌ Failed to download XRechnung: ${errorMessage}`);
|
||||
}
|
||||
|
||||
// List cached files
|
||||
console.log('\n📂 Cached Schematron files:');
|
||||
const cached = await downloader.getCachedFiles();
|
||||
cached.forEach(file => {
|
||||
cached.forEach((file: { path: string; metadata: any }) => {
|
||||
if (file.metadata) {
|
||||
console.log(` - ${file.path}`);
|
||||
console.log(` Version: ${file.metadata.version}`);
|
||||
@@ -65,4 +75,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
});
|
||||
}
|
||||
|
||||
export default main;
|
||||
export default main;
|
||||
|
||||
Reference in New Issue
Block a user