npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aifind/mustangjs

v0.4.0

Published

TypeScript port of mustangproject - ZUGFeRD, Factur-X, XRechnung e-invoicing library

Readme

mustangjs

TypeScript port of mustangproject — a library for creating, parsing, and validating EN16931 e-invoices (ZUGFeRD, Factur-X, XRechnung).

Install

npm install @aifind/mustangjs

Usage

import { Invoice, Item, Product, TradeParty, Big } from '@aifind/mustangjs';
import { ZUGFeRD2PullProvider, Profiles } from '@aifind/mustangjs';

const invoice = new Invoice()
  .setNumber('INV-001')
  .setIssueDate(new Date())
  .setSender(new TradeParty('Seller GmbH', 'Str. 1', '10115', 'Berlin', 'DE').addVATID('DE123'))
  .setRecipient(new TradeParty('Buyer AG', 'Str. 2', '80331', 'Munich', 'DE'))
  .addItem(new Item(new Product('Service', '', 'C62', new Big(19)), new Big(100), new Big(1)));

const provider = new ZUGFeRD2PullProvider();
provider.setProfile(Profiles.getByName('EN16931'));
provider.generateXML(invoice);
const xml = provider.getXML(); // CII XML string

Parse

import { ZUGFeRDInvoiceImporter, CalculatedInvoice } from '@aifind/mustangjs';

const importer = new ZUGFeRDInvoiceImporter(xmlString);
const ci = new CalculatedInvoice();
importer.extractInto(ci);
console.log(ci.getGrandTotal().toString());

Validate

Validate invoice XML against official EN16931 and XRechnung Schematron rules using XMLValidator.

import { XMLValidator } from '@aifind/mustangjs';

const validator = new XMLValidator();
const result = await validator.validate(xmlString);

result.isValid();          // true if no errors
result.getErrors();        // ValidationResultItem[]
result.getWarnings();      // warnings (non-blocking)
result.hasRule('BR-02');   // check specific rule

Format (CII/UBL) and profile are auto-detected from the XML. You can override:

import { XMLValidator, Profiles } from '@aifind/mustangjs';

const result = await validator.validate(xmlString, {
  profile: Profiles.getByName('XRECHNUNG'),  // override auto-detected profile
  skipProgrammatic: true,                     // Schematron only (recommended)
});

There is also a lower-level InvoiceValidator for programmatic rule checks on Invoice objects (without XML/Schematron):

import { InvoiceValidator, Profiles } from '@aifind/mustangjs';

const validator = new InvoiceValidator(Profiles.getByName('EN16931'));
const result = validator.validate(invoice);

Schematron rules

Validation is powered by pre-compiled Schematron XSLT stylesheets (via saxon-js):

| Ruleset | Format | Covers | |---------|--------|--------| | EN16931-CII | CII | Core EN16931 business rules for ZUGFeRD/Factur-X | | EN16931-UBL | UBL | Core EN16931 business rules (incl. PEPPOL BIS) | | XRechnung-CII | CII | German XRechnung-specific rules (v3.0) | | XRechnung-UBL | UBL | German XRechnung-specific rules (v3.0) |

The SEF files live in src/validation/schematron/. See SCHEMATRON.md for how to update them when new rule versions are released.

Supported formats

  • CII (Cross-Industry Invoice): ZUGFeRD 2.x, Factur-X
  • UBL (Universal Business Language): XRechnung

Profiles

MINIMUM, BASICWL, BASIC, EN16931, EXTENDED, XRECHNUNG

Build & test

npm run build
npm test

License

This project is licensed under the Apache License 2.0. Third-party runtime dependencies and bundled validation artifacts are under their own licenses. See NOTICE.