@fin.cx/einvoice 5.1.3 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/{npmextra.json → .smartconfig.json} +12 -6
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/einvoice.d.ts +14 -5
  4. package/dist_ts/einvoice.js +165 -60
  5. package/dist_ts/errors.js +14 -4
  6. package/dist_ts/formats/base/base.decoder.d.ts +4 -0
  7. package/dist_ts/formats/base/base.decoder.js +9 -1
  8. package/dist_ts/formats/base/base.validator.js +3 -2
  9. package/dist_ts/formats/cii/cii.decoder.d.ts +1 -0
  10. package/dist_ts/formats/cii/cii.decoder.js +20 -10
  11. package/dist_ts/formats/cii/cii.encoder.js +2 -5
  12. package/dist_ts/formats/cii/cii.validator.d.ts +1 -1
  13. package/dist_ts/formats/cii/cii.validator.js +19 -12
  14. package/dist_ts/formats/converters/xml-to-einvoice.converter.js +3 -3
  15. package/dist_ts/formats/factories/decoder.factory.d.ts +3 -1
  16. package/dist_ts/formats/factories/decoder.factory.js +4 -3
  17. package/dist_ts/formats/factories/validator.factory.d.ts +4 -1
  18. package/dist_ts/formats/factories/validator.factory.js +11 -8
  19. package/dist_ts/formats/pdf/extractors/base.extractor.js +49 -51
  20. package/dist_ts/formats/pdf/extractors/text.extractor.js +19 -22
  21. package/dist_ts/formats/pdf/pdf.extractor.js +2 -2
  22. package/dist_ts/formats/semantic/semantic.adapter.js +42 -12
  23. package/dist_ts/formats/semantic/semantic.validator.js +3 -1
  24. package/dist_ts/formats/ubl/en16931.ubl.validator.js +5 -3
  25. package/dist_ts/formats/ubl/generic/ubl.encoder.js +11 -7
  26. package/dist_ts/formats/ubl/ubl.decoder.d.ts +1 -0
  27. package/dist_ts/formats/ubl/ubl.decoder.js +18 -8
  28. package/dist_ts/formats/ubl/ubl.validator.d.ts +1 -1
  29. package/dist_ts/formats/ubl/ubl.validator.js +17 -10
  30. package/dist_ts/formats/ubl/xrechnung/xrechnung.decoder.js +37 -29
  31. package/dist_ts/formats/utils/currency.calculator.decimal.js +4 -1
  32. package/dist_ts/formats/utils/currency.utils.js +4 -1
  33. package/dist_ts/formats/utils/decimal.js +9 -2
  34. package/dist_ts/formats/utils/format.detector.js +47 -17
  35. package/dist_ts/formats/validation/codelist.validator.js +2 -4
  36. package/dist_ts/formats/validation/conformance.harness.js +13 -6
  37. package/dist_ts/formats/validation/en16931.business-rules.validator.js +4 -4
  38. package/dist_ts/formats/validation/en16931.validator.d.ts +6 -0
  39. package/dist_ts/formats/validation/en16931.validator.js +18 -12
  40. package/dist_ts/formats/validation/facturx.validator.js +147 -148
  41. package/dist_ts/formats/validation/integrated.validator.js +12 -4
  42. package/dist_ts/formats/validation/peppol.validator.js +2 -1
  43. package/dist_ts/formats/validation/schematron.downloader.js +13 -6
  44. package/dist_ts/formats/validation/schematron.integration.js +12 -5
  45. package/dist_ts/formats/validation/schematron.validator.js +17 -13
  46. package/dist_ts/formats/validation/schematron.worker.js +6 -5
  47. package/dist_ts/formats/validation/vat-categories.validator.js +3 -4
  48. package/dist_ts/formats/validation/xrechnung.validator.js +7 -7
  49. package/dist_ts/index.js +3 -2
  50. package/dist_ts/interfaces/common.js +1 -2
  51. package/dist_ts/plugins.d.ts +3 -4
  52. package/dist_ts/plugins.js +4 -5
  53. package/dist_ts/vendor/pako.d.ts +5 -0
  54. package/dist_ts/vendor/pako.js +3 -0
  55. package/dist_ts/vendor/saxonjs.d.ts +22 -0
  56. package/dist_ts/vendor/saxonjs.js +3 -0
  57. package/dist_ts/vendor/xmldom.d.ts +20 -0
  58. package/dist_ts/vendor/xmldom.js +5 -0
  59. package/dist_ts_install/download-schematron.d.ts +0 -3
  60. package/dist_ts_install/download-schematron.js +20 -11
  61. package/dist_ts_install/download-test-samples.d.ts +0 -3
  62. package/dist_ts_install/download-test-samples.js +4 -2
  63. package/dist_ts_install/download-xrechnung-rules.js +2 -1
  64. package/dist_ts_install/index.d.ts +0 -5
  65. package/dist_ts_install/index.js +26 -12
  66. package/license +21 -0
  67. package/package.json +25 -23
  68. package/readme.hints.md +24 -8
  69. package/readme.md +195 -328
  70. package/ts/00_commitinfo_data.ts +1 -1
  71. package/ts/einvoice.ts +148 -26
  72. package/ts/formats/base/base.decoder.ts +7 -0
  73. package/ts/formats/cii/cii.decoder.ts +17 -8
  74. package/ts/formats/cii/cii.validator.ts +18 -13
  75. package/ts/formats/converters/xml-to-einvoice.converter.ts +4 -5
  76. package/ts/formats/factories/decoder.factory.ts +7 -2
  77. package/ts/formats/factories/validator.factory.ts +14 -8
  78. package/ts/formats/semantic/semantic.adapter.ts +49 -15
  79. package/ts/formats/ubl/en16931.ubl.validator.ts +5 -3
  80. package/ts/formats/ubl/generic/ubl.encoder.ts +12 -7
  81. package/ts/formats/ubl/ubl.decoder.ts +18 -9
  82. package/ts/formats/ubl/ubl.validator.ts +17 -12
  83. package/ts/formats/ubl/xrechnung/xrechnung.decoder.ts +41 -28
  84. package/ts/formats/utils/format.detector.ts +57 -19
  85. package/ts/formats/validation/conformance.harness.ts +6 -4
  86. package/ts/formats/validation/en16931.validator.ts +20 -10
  87. package/ts/formats/validation/integrated.validator.ts +5 -3
  88. package/ts/formats/validation/schematron.downloader.ts +11 -6
  89. package/ts/formats/validation/schematron.integration.ts +7 -4
  90. package/ts/formats/validation/schematron.validator.ts +12 -11
  91. package/ts/index.ts +2 -1
  92. package/ts/interfaces/common.ts +1 -3
  93. package/ts/plugins.ts +3 -4
  94. package/ts/readme.md +55 -0
  95. package/ts/vendor/modules.d.ts +32 -0
  96. package/ts/vendor/pako.ts +8 -0
  97. package/ts/vendor/saxonjs.ts +28 -0
  98. package/ts/vendor/xmldom.ts +27 -0
@@ -1,5 +1,3 @@
1
- import { business, finance } from '../plugins.js';
2
-
3
1
  /**
4
2
  * Supported electronic invoice formats
5
3
  */
@@ -88,4 +86,4 @@ export type { TCreditNote } from '@tsclass/tsclass/dist_ts/finance/index.js';
88
86
  export type { TDebitNote } from '@tsclass/tsclass/dist_ts/finance/index.js';
89
87
  export type { TContact } from '@tsclass/tsclass/dist_ts/business/index.js';
90
88
  export type { TLetterEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
91
- export type { TDocumentEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
89
+ export type { TDocumentEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
package/ts/plugins.ts CHANGED
@@ -21,15 +21,14 @@ import {
21
21
  } from 'pdf-lib';
22
22
 
23
23
  // XML-related imports
24
- import { DOMParser, XMLSerializer } from 'xmldom';
25
- import * as xmldom from 'xmldom';
24
+ import { DOMParser, XMLSerializer, xmldom } from './vendor/xmldom.js';
26
25
  import * as xpath from 'xpath';
27
26
 
28
27
  // XSLT/Schematron imports
29
- import * as SaxonJS from 'saxon-js';
28
+ import { SaxonJS } from './vendor/saxonjs.js';
30
29
 
31
30
  // Compression-related imports
32
- import * as pako from 'pako';
31
+ import { pako } from './vendor/pako.js';
33
32
 
34
33
  // Business model imports
35
34
  import { business, finance, general } from '@tsclass/tsclass';
package/ts/readme.md ADDED
@@ -0,0 +1,55 @@
1
+ # @fin.cx/einvoice
2
+
3
+ Source module for the main `@fin.cx/einvoice` package.
4
+
5
+ This directory contains the public TypeScript API for loading, validating, converting, and embedding European e-invoice XML.
6
+
7
+ ## Issue Reporting and Security
8
+
9
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
10
+
11
+ ## What this module exports
12
+
13
+ - `EInvoice`
14
+ - `createEInvoice()`
15
+ - `validateXml(xml, level?)`
16
+ - `FormatDetector`
17
+ - `PDFExtractor`, `PDFEmbedder`
18
+ - `DecoderFactory`, `EncoderFactory`, `ValidatorFactory`
19
+ - `BaseDecoder`, `BaseEncoder`, `BaseValidator`
20
+ - `UBLBase*` and `CIIBase*` extension points
21
+ - Factur-X and ZUGFeRD format-specific classes
22
+ - root types such as `TInvoice`, `ValidationResult`, `ExportFormat`, `IPdf`
23
+
24
+ ## Main workflow
25
+
26
+ ```ts
27
+ import { EInvoice, ValidationLevel } from '@fin.cx/einvoice';
28
+
29
+ const invoice = await EInvoice.fromFile('./invoice.xml');
30
+ const validation = await invoice.validate(ValidationLevel.BUSINESS);
31
+ const xml = await invoice.exportXml('facturx');
32
+ ```
33
+
34
+ ## Format support
35
+
36
+ | Format | Detect | Import | Export | Notes |
37
+ | --- | --- | --- | --- | --- |
38
+ | `ubl` | Yes | Yes | Yes | Generic UBL flow |
39
+ | `xrechnung` | Yes | Yes | Yes | UBL-based profile |
40
+ | `cii` | Yes | Yes | Yes | Generic export currently routes through the Factur-X encoder path |
41
+ | `facturx` | Yes | Yes | Yes | Main CII generation path |
42
+ | `zugferd` | Yes | Yes | Yes | Input supports v1 and v2+ |
43
+ | `fatturapa` | Yes | No | No | Detection only at the moment |
44
+
45
+ ## Important implementation notes
46
+
47
+ - `peppol` is not a root-level XML export target.
48
+ - `FatturaPA` is not fully implemented for import/export.
49
+ - PDF support means extracting or embedding XML into existing PDFs, not generating invoice PDFs from scratch.
50
+ - Validation is useful and extensive, but should not be documented as blanket certification.
51
+
52
+ ## Related directories
53
+
54
+ - `../readme.md`: full package README for end users
55
+ - `../ts_install/readme.md`: install-time resource bootstrap module
@@ -0,0 +1,32 @@
1
+ declare module 'xmldom' {
2
+ export class DOMParser {
3
+ parseFromString(source: string, mimeType: string): Document;
4
+ }
5
+
6
+ export class XMLSerializer {
7
+ serializeToString(node: Node): string;
8
+ }
9
+ }
10
+
11
+ declare module 'pako' {
12
+ export function inflate(input: Uint8Array | ArrayBuffer | string, options?: unknown): Uint8Array;
13
+ }
14
+
15
+ declare module 'saxon-js' {
16
+ export function compile(options: {
17
+ stylesheetText: string;
18
+ warnings?: string;
19
+ [key: string]: unknown;
20
+ }): Promise<unknown>;
21
+
22
+ export function transform(options: {
23
+ stylesheetInternal?: unknown;
24
+ sourceText: string;
25
+ destination?: string;
26
+ stylesheetParams?: Record<string, unknown>;
27
+ [key: string]: unknown;
28
+ }): Promise<{
29
+ principalResult: string;
30
+ [key: string]: unknown;
31
+ }>;
32
+ }
@@ -0,0 +1,8 @@
1
+ import * as pakoRuntime from 'pako';
2
+
3
+ export interface IPakoModule {
4
+ inflate(input: Uint8Array | ArrayBuffer | string, options?: unknown): Uint8Array;
5
+ [key: string]: unknown;
6
+ }
7
+
8
+ export const pako: IPakoModule = pakoRuntime as unknown as IPakoModule;
@@ -0,0 +1,28 @@
1
+ import * as saxonJSRuntime from 'saxon-js';
2
+
3
+ export interface ISaxonJSCompileOptions {
4
+ stylesheetText: string;
5
+ warnings?: string;
6
+ [key: string]: unknown;
7
+ }
8
+
9
+ export interface ISaxonJSTransformOptions {
10
+ stylesheetInternal?: unknown;
11
+ sourceText: string;
12
+ destination?: string;
13
+ stylesheetParams?: Record<string, unknown>;
14
+ [key: string]: unknown;
15
+ }
16
+
17
+ export interface ISaxonJSTransformResult {
18
+ principalResult: string;
19
+ [key: string]: unknown;
20
+ }
21
+
22
+ export interface ISaxonJSModule {
23
+ compile(options: ISaxonJSCompileOptions): Promise<unknown>;
24
+ transform(options: ISaxonJSTransformOptions): Promise<ISaxonJSTransformResult>;
25
+ [key: string]: unknown;
26
+ }
27
+
28
+ export const SaxonJS: ISaxonJSModule = saxonJSRuntime as unknown as ISaxonJSModule;
@@ -0,0 +1,27 @@
1
+ import * as xmldomRuntime from 'xmldom';
2
+
3
+ export interface IDOMParser {
4
+ parseFromString(source: string, mimeType: string): Document;
5
+ }
6
+
7
+ export interface IDOMParserConstructor {
8
+ new (): IDOMParser;
9
+ }
10
+
11
+ export interface IXMLSerializer {
12
+ serializeToString(node: Node): string;
13
+ }
14
+
15
+ export interface IXMLSerializerConstructor {
16
+ new (): IXMLSerializer;
17
+ }
18
+
19
+ export interface IXmlDomModule {
20
+ DOMParser: IDOMParserConstructor;
21
+ XMLSerializer: IXMLSerializerConstructor;
22
+ [key: string]: unknown;
23
+ }
24
+
25
+ export const DOMParser: IDOMParserConstructor = xmldomRuntime.DOMParser as unknown as IDOMParserConstructor;
26
+ export const XMLSerializer: IXMLSerializerConstructor = xmldomRuntime.XMLSerializer as unknown as IXMLSerializerConstructor;
27
+ export const xmldom: IXmlDomModule = xmldomRuntime as unknown as IXmlDomModule;