BREAKING CHANGE(core): Rebrand XInvoice to EInvoice: update package name, class names, imports, and documentation

This commit is contained in:
2025-05-24 16:33:58 +00:00
parent 805adc6d5c
commit a93ea090ce
27 changed files with 3172 additions and 295 deletions

View File

@ -1,10 +1,10 @@
import { tap, expect } from '@push.rocks/tapbundle';
import { XInvoice } from '../ts/classes.xinvoice.js';
import { EInvoice } from '../ts/einvoice.js';
import { InvoiceFormat, ValidationLevel } from '../ts/interfaces/common.js';
import * as fs from 'fs/promises';
import * as path from 'path';
tap.test('XInvoice should validate corpus files correctly', async () => {
tap.test('EInvoice should validate corpus files correctly', async () => {
// Find test files
const testDir = path.join(process.cwd(), 'test', 'assets');
@ -81,21 +81,21 @@ async function testValidation(files: string[], expectValid: boolean) {
// Load the XML file
const xmlContent = await fs.readFile(file, 'utf8');
// Create an XInvoice instance
let xinvoice: XInvoice;
// Create an EInvoice instance
let einvoice: EInvoice;
// If the file is a PDF, load it as a PDF
if (file.endsWith('.pdf')) {
const pdfBuffer = await fs.readFile(file);
xinvoice = await XInvoice.fromPdf(pdfBuffer);
einvoice = await EInvoice.fromPdf(pdfBuffer);
} else {
// Otherwise, load it as XML
xinvoice = await XInvoice.fromXml(xmlContent);
einvoice = await EInvoice.fromXml(xmlContent);
}
try {
// Validate the invoice
const validationResult = await xinvoice.validate(ValidationLevel.SYNTAX);
const validationResult = await einvoice.validate(ValidationLevel.SYNTAX);
// Check if the validation result matches our expectation
if (validationResult.valid === expectValid) {