@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fin.cx/einvoice",
3
- "version": "5.1.3",
3
+ "version": "5.2.0",
4
4
  "private": false,
5
5
  "description": "A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.",
6
6
  "main": "dist_ts/index.js",
@@ -8,19 +8,29 @@
8
8
  "type": "module",
9
9
  "author": "Task Venture Capital GmbH",
10
10
  "license": "MIT",
11
+ "scripts": {
12
+ "test": "(tstest test/ --verbose --logfile --timeout 60)",
13
+ "build": "(tsbuild tsfolders --allowimplicitany)",
14
+ "typecheck:published": "pnpm exec tsc -p test/strict-consumer/tsconfig.json",
15
+ "buildDocs": "(tsdoc)",
16
+ "postinstall": "node dist_ts_install/index.js 2>/dev/null || true",
17
+ "download-schematron": "tsx ts_install/download-schematron.ts",
18
+ "download-test-samples": "tsx ts_install/download-test-samples.ts",
19
+ "test:conformance": "tstest test/test.conformance-harness.ts"
20
+ },
11
21
  "devDependencies": {
12
- "@git.zone/tsbuild": "^2.6.4",
13
- "@git.zone/tsbundle": "^2.2.5",
14
- "@git.zone/tsrun": "^1.3.3",
15
- "@git.zone/tstest": "^2.3.1",
16
- "@types/node": "^22.15.23"
22
+ "@git.zone/tsbuild": "^4.4.0",
23
+ "@git.zone/tsbundle": "^2.10.0",
24
+ "@git.zone/tsrun": "^2.0.2",
25
+ "@git.zone/tstest": "^3.6.3",
26
+ "@types/node": "^25.6.0"
17
27
  },
18
28
  "dependencies": {
19
- "@push.rocks/smartfile": "^11.2.5",
20
- "@push.rocks/smartxml": "^1.1.1",
21
- "@tsclass/tsclass": "^9.2.0",
22
- "@xmldom/xmldom": "^0.9.8",
23
- "jsdom": "^26.1.0",
29
+ "@push.rocks/smartfile": "^13.1.2",
30
+ "@push.rocks/smartxml": "^2.0.0",
31
+ "@tsclass/tsclass": "^9.5.0",
32
+ "@xmldom/xmldom": "^0.9.9",
33
+ "jsdom": "^29.0.2",
24
34
  "pako": "^2.1.0",
25
35
  "pdf-lib": "^1.17.1",
26
36
  "saxon-js": "^2.7.0",
@@ -29,7 +39,7 @@
29
39
  },
30
40
  "repository": {
31
41
  "type": "git",
32
- "url": "git+https://code.foss.global/fin.cx/einvoice.git"
42
+ "url": "https://code.foss.global/fin.cx/einvoice.git"
33
43
  },
34
44
  "bugs": {
35
45
  "url": "https://code.foss.global/fin.cx/einvoice/issues"
@@ -47,7 +57,7 @@
47
57
  "dist_ts_web/**/*",
48
58
  "assets/**/*",
49
59
  "cli.js",
50
- "npmextra.json",
60
+ ".smartconfig.json",
51
61
  "readme.md"
52
62
  ],
53
63
  "keywords": [
@@ -64,13 +74,5 @@
64
74
  "esm",
65
75
  "financial technology"
66
76
  ],
67
- "scripts": {
68
- "test": "(tstest test/ --verbose --logfile --timeout 60)",
69
- "build": "(tsbuild tsfolders --allowimplicitany)",
70
- "buildDocs": "(tsdoc)",
71
- "postinstall": "node dist_ts_install/index.js 2>/dev/null || true",
72
- "download-schematron": "tsx ts_install/download-schematron.ts",
73
- "download-test-samples": "tsx ts_install/download-test-samples.ts",
74
- "test:conformance": "tstest test/test.conformance-harness.ts"
75
- }
76
- }
77
+ "packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
78
+ }
package/readme.hints.md CHANGED
@@ -1,11 +1,11 @@
1
1
  For testing use
2
2
 
3
3
  ```typescript
4
- import {tap, expect} @push.rocks/tapbundle
4
+ import { tap, expect } from '@git.zone/tstest/tapbundle';
5
5
  ```
6
6
 
7
- tapbundle exports expect from @push.rocks/smartexpect
8
- You can find the readme here: https://code.foss.global/push.rocks/smartexpect/src/branch/master/readme.md
7
+ tapbundle is provided by `@git.zone/tstest`.
8
+ You can find the readme here: https://code.foss.global/git.zone/tstest
9
9
 
10
10
  This module also uses @tsclass/tsclass: You can find the TInvoice type here: https://code.foss.global/tsclass/tsclass/src/branch/master/ts/finance/invoice.ts
11
11
 
@@ -15,6 +15,22 @@ It is ok to ask questions, if you are unsure about something.
15
15
 
16
16
  ---
17
17
 
18
+ # Upgrade Notes (2026-04-16)
19
+
20
+ - Command: `/c-upgrade`
21
+ - Files modified: 2
22
+ - Dependency status: `pnpm outdated --format json` returned `{}`, so no package version bumps were needed.
23
+ - Decorators: no decorator usage was found in `*.ts`, so TC39 decorator migration was not required.
24
+ - Pattern changes:
25
+ - Removed obsolete `experimentalDecorators` and `useDefineForClassFields` compiler options from `tsconfig.json`.
26
+ - Updated the stale test import hint from `@push.rocks/tapbundle` to `@git.zone/tstest/tapbundle`.
27
+ - Verification:
28
+ - `pnpm run build`: passed
29
+ - `pnpm test`: failed due to pre-existing test issues in `test/test.conformance-harness.ts` (no tests defined) and `test/suite/einvoice_security/test.sec-06.memory-dos.ts` (assertion failure at line 142)
30
+ - Issues encountered: full test suite is not green before or after this minimal upgrade because of the pre-existing failures above.
31
+
32
+ ---
33
+
18
34
  # Architecture Analysis (2025-01-31)
19
35
 
20
36
  ## Overall Architecture
@@ -490,7 +506,7 @@ countryCode: country
490
506
 
491
507
  ### **MILESTONE REACHED: The module now achieves 100% data preservation in round-trip conversions!**
492
508
 
493
- This makes the module fully spec-compliant and suitable as the default open-source e-invoicing solution.
509
+ This materially improved round-trip data preservation, but it did not by itself prove full standards compliance across every supported format and profile.
494
510
 
495
511
  ### Data Preservation Improvements:
496
512
  - Initial preservation score: 51%
@@ -800,7 +816,7 @@ Successfully fixed all remaining test failures to achieve 100% test pass rate:
800
816
  - Format detection: <5ms average for most formats
801
817
  - PDF extraction: Successfully extracts from ZUGFeRD v1/v2 and Factur-X PDFs
802
818
 
803
- All tests are now passing, making the library fully spec-compliant and production-ready.
819
+ The targeted test suites available at that point were passing, but that still did not establish full standards compliance or production readiness across every supported format/profile.
804
820
 
805
821
  ---
806
822
 
@@ -855,10 +871,10 @@ for (const idNode of partyIdNodes) {
855
871
  ```
856
872
 
857
873
  ### FatturaPA (Italian Standard)
858
- While not fully implemented as decoder/encoder, the library detects FatturaPA format:
874
+ FatturaPA currently has format detection, but not full decoder/encoder support:
859
875
  - Detects root element `<FatturaElettronica>`
860
876
  - Recognizes namespace `fatturapa.gov.it`
861
- - Supports mixed UBL+FatturaPA documents
877
+ - May classify mixed UBL+FatturaPA documents as FatturaPA during detection
862
878
 
863
879
  ## 3. Advanced Validation Architecture
864
880
 
@@ -1104,4 +1120,4 @@ Each format has its own implementation strategy while maintaining common interfa
1104
1120
  5. **Extensible Design**: New formats can be added without core changes
1105
1121
  6. **Production Ready**: Handles edge cases, malformed input, and large files
1106
1122
 
1107
- The library represents a mature, well-architected solution for European e-invoicing with careful attention to both standards compliance and practical usage scenarios.
1123
+ The library represents a mature, well-architected solution for European e-invoicing with careful attention to both standards compliance and practical usage scenarios.