64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
|
#!/usr/bin/env node
|
||
|
|
||
|
/**
|
||
|
* Script to download official Schematron files for e-invoice validation
|
||
|
*/
|
||
|
|
||
|
import { SchematronDownloader } from '../ts/formats/validation/schematron.downloader.js';
|
||
|
|
||
|
async function main() {
|
||
|
console.log('📥 Starting Schematron download...\n');
|
||
|
|
||
|
const downloader = new SchematronDownloader('assets/schematron');
|
||
|
await downloader.initialize();
|
||
|
|
||
|
// 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}`));
|
||
|
} catch (error) {
|
||
|
console.error(`❌ Failed to download EN16931: ${error.message}`);
|
||
|
}
|
||
|
|
||
|
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}`));
|
||
|
} catch (error) {
|
||
|
console.error(`❌ Failed to download PEPPOL: ${error.message}`);
|
||
|
}
|
||
|
|
||
|
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}`));
|
||
|
} catch (error) {
|
||
|
console.error(`❌ Failed to download XRechnung: ${error.message}`);
|
||
|
}
|
||
|
|
||
|
// List cached files
|
||
|
console.log('\n📂 Cached Schematron files:');
|
||
|
const cached = await downloader.getCachedFiles();
|
||
|
cached.forEach(file => {
|
||
|
if (file.metadata) {
|
||
|
console.log(` - ${file.path}`);
|
||
|
console.log(` Version: ${file.metadata.version}`);
|
||
|
console.log(` Format: ${file.metadata.format}`);
|
||
|
console.log(` Downloaded: ${file.metadata.downloadDate}`);
|
||
|
} else {
|
||
|
console.log(` - ${file.path} (no metadata)`);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
console.log('\n✅ Schematron download complete!');
|
||
|
}
|
||
|
|
||
|
// Run the script
|
||
|
main().catch(error => {
|
||
|
console.error('❌ Script failed:', error);
|
||
|
process.exit(1);
|
||
|
});
|