#!/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); });