node-zugferd
IntroductionInstallation
CLIOptionsContributingAPI Reference

Options

node-zugferd configuration options reference.

List of all the available options for configuring node-zugferd. See node-zugferd Options.

profiles

List of node-zugferd profiles.

import { zugferd } from "node-zugferd";
import { en16931 } from "@node-zugferd/en-16931";

const invoicer = zugferd({
  profiles: [
    en16931(),
  ],
  // ...
});

plugins

List of node-zugferd plugins.

import { zugferd } from "node-zugferd";
import { xsd } from "@node-zugferd/validator-xsd";

const invoicer = zugferd({
  plugins: [
    xsd(),
  ],
  // ...
});

prettyPrint

Whether to pretty print the XML output. Defaults to false.

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
  prettyPrint: true,
  // ...
});

logger

Logger configuration for node-zugferd.

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
	logger: {
		disabled: false,
		level: "warn",
		log: (level, message, ...args) => {
			// Custom logging implementation
			console.log(`[${level}] ${message}`, ...args);
		},
	},
	// ...
});

The logger configuration allows you to customize how node-zugferd handles logging. It supports the following options:

  • disabled

    Disable all logging when set to true (default: false)
  • level

    Set the minimum log level to display (default: "warn")
    • "debug": Show all logs including debug information
    • "info": Show all logs except debug information
    • "warn": Show warnings and errors
    • "error": Show only errors
  • log

    Custom logging function that receives:
    • level: The log level
    • message: The log message
    • ...args: Additional arguments to the logger

Example with custom logging:

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
	logger: {
		level: "info",
		log: (level, message, ...args) => {
			// Send logs to a custom logging service
			myLoggingService.log({
				level,
				message,
				metadata: args,
				timestamp: new Date().toISOString()
			});
		},
	},
	// ...
});

hooks

Invoice lifecycle hooks.

  • afterXMLBuild

Called after the XML document has been built.

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
  hooks: {
    afterXMLBuild: ({ xml, profile, context }) => {
      // Custom logic to execute after XML is built
      validate(profile.id, xml);
    },
  },
  // ...
});

advanced

Advanced configuration options.

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
  advanced: {
    // ...
  },
});

instrumentation

Instrumentation configuration.

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
  advanced: {
    instrumentation: {
      // ...
    },
  },
});

The instrumentation configuration allows you to customize the span implementation. It supports the following options:

  • span
    Custom span implementation that receives:
    • name: The span name
    • attr: The span attributes
    • fn: The span function

Example with custom span implementation:

import { zugferd } from "node-zugferd";

export const invoicer = zugferd({
  advanced: {
    instrumentation: {
      span: async (name, attr, fn) => {
        const result = await fn();
        console.log(`Span ${name} completed with result:`, result);
        return result;
      }
    },
  },
  // ...
});

 

llms.txt
CLI

Contributing

A guide to contributing to node-zugferd.

Edit on GitHubPrivacyImprint

On this page

profilespluginsprettyPrintloggerdisabledlevelloghooksafterXMLBuildadvancedinstrumentationspan

How is this guide?