Files
einvoice/ts_install/download-schematron.ts
Juergen Kunz 58506e287d refactor: Move downloaded resources from assets/ to assets_downloaded/
- Changed default download location to assets_downloaded/schematron
- Updated all references in SchematronDownloader, integration, and validator
- Updated postinstall scripts to use new location
- assets_downloaded/ is already in .gitignore to exclude downloaded files from git
- Moved existing downloaded files to new location
- All functionality tested and working correctly
2025-08-12 05:25:50 +00:00

68 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Script to download official Schematron files for e-invoice validation
*/
import { SchematronDownloader } from '../dist_ts/formats/validation/schematron.downloader.js';
async function main() {
console.log('📥 Starting Schematron download...\n');
const downloader = new SchematronDownloader('assets_downloaded/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 if executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
main().catch(error => {
console.error('❌ Script failed:', error);
process.exit(1);
});
}
export default main;