Repository navigation
Conversation
Upgrade GOBL to v0.508.0 and offer conversions between GOBL and external formats through its new convert package. Only formats registered with the register are offered, replacing the hand-maintained format list of #22. Modules: gobl v0.507.0 -> v0.508.0 gobl.ar.arca new v0.0.3 (ar-arca-v4 moved out of core) gobl.co.dian new v0.0.3 (co-dian-v2 moved out of core) gobl.ubl new v0.86.0 (registers ubl+ formats) gobl.cii new v0.69.0 (registers cii+ formats) gobl.fi.finvoice v0.0.2 -> v0.0.6 gobl.it.sdi v0.81.0 -> v0.83.0 gobl.mx.cfdi v0.64.0 -> v0.68.0 gobl.pl.ksef v0.45.0 -> v0.47.0 GOBL 0.508.0 changes handled: - The ARCA and DIAN addons now live in their own modules; blank-import both in the bundle so the approved addon test passes. - data/addons was removed. Addon definitions are already served from the registry, so only the TestListDataDir subtest reading it is dropped. - Shortened schema descriptions and the new tax/filter schema: refresh the correction options snapshots and the bulk schema expectations. Conversions: - internal/ops: Formats, Import and Export wrap the convert register. Export envelops documents and calculates unsigned envelopes first, so drafts can be exported directly. - CLI: `gobl convert` exports with --to (keys in order of preference), imports with format detection otherwise (--from limits it), and lists the formats with --list. - API: GET /v0/formats, POST /v0/import and POST /v0/export?format=, taking raw bodies. The format used is returned in a GOBL-Format header, exposed through CORS. Unescaped "+" in keys is accepted. - Editor: an Export picker lists the registered export formats and shows the result in a read-only XML pane beside the editor, via /v0/export. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #63 +/- ##
==========================================
- Coverage 72.56% 68.98% -3.59%
==========================================
Files 48 53 +5
Lines 1994 2399 +405
==========================================
+ Hits 1447 1655 +208
- Misses 467 649 +182
- Partials 80 95 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Rework the editor around three modes: - Build: as before, the GOBL source is replaced with the built document. - Export: the source is left untouched; /v0/export builds it internally and the result is shown in a read-only viewer. The formats offered are those registered with the convert package whose export schemas include the document's schema and whose addons are all declared by it, after expanding addon requirements as GOBL does when building. - Import: a separate XML input is converted through /v0/import, and the resulting envelope is shown in the viewer. Add bare-minimum example documents for the US, UK, Spain (with and without VERI*FACTU), Germany (EN 16931 and XRechnung), France and the Netherlands (EN 16931), Italy (SDI), Portugal (SAF-T) and Mexico (CFDI). Their region and label are derived from the regime and addon registries, loaded lazily so externally implemented addons are registered first. In import mode an example is offered as the output of its first export format. Tests build every example and export it into every format the editor would offer it. ubl+peppol+bis-v3 is recorded as a known gap: it also exports bill/status, so the EN 16931 addon it needs for invoices is only checked in Accepts and is missing from the register's metadata. The mode, example and format are remembered in localStorage. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrades GOBL to v0.508.0 and adds conversions between GOBL and external formats, built on GOBL's new
convertregister. This supersedes #22: rather than a hand-maintained list of formats, gobl.dev offers exactly the formats that the bundled converters register.Conversions
Bundle —
gobl.ublv0.86.0 andgobl.ciiv0.69.0 are blank-imported next to the addons. Together they registerubl+en16931-v2017,ubl+peppol+bis-v3,cii+en16931-v2017andcii+peppol+bis-v3. They also register import-only fallbacks (ubl,cii) for detection.internal/ops—Formats,ImportandExportwrap the register.Exportwraps documents in an envelope and calculates unsigned envelopes first, so drafts export directly.CLI —
gobl convert:API —
GET /v0/formats,POST /v0/importandPOST /v0/export?format=…(repeated or comma-separated). The body is raw, so XML can be posted directly. The format used comes back in theGOBL-Formatheader, which CORS exposes.+in keys can be left unescaped in the query. The OpenAPI spec is updated.Editor — three modes:
requires, which GOBL expands on build)./v0/import, and the resulting envelope shows in the viewer.The mode, example and format choices persist across reloads.
Examples —
editor/examples/*.json, a bare-minimum document per region: US, UK, Spain (plain and VERI*FACTU), Germany (EN 16931 and XRechnung), France and the Netherlands (EN 16931), Italy (SDI), Portugal (SAF-T) and Mexico (CFDI). Labels come from the regime and addon registries. Each example has only the fields its build needs, plus series/code where a format requires an invoice number. In import mode, an example is loaded as the output of its first export format.Changes from #22
RegisterFormats.eu-en16931-v2017). Otherwise the export fails withnot-supported.GOBL v0.508.0 and module updates
ar-arca-v4moved out of core)co-dian-v2moved out of core)Changes needed for 0.508.0:
data/addonswas removed upstream. Addon definitions were already served from the registry, so only aTestListDataDirsubtest is dropped.tax/filterschema added, so the correction-options snapshots and bulk schema expectations are refreshed.Testing
go test -race ./...passes. There are new tests for ops, CLI, API and editor, including UBL/CII export → import round trips, preference order, unknown and unsupported formats, and restricted detection.gobl.devserver with curl: the page renders the picker, and/v0/formats,/v0/exportand/v0/importwork end to end.ubl+peppol+bis-v3This format also exports
bill/status, so in the convert register it declares no addons. The EN 16931 requirement for invoices is checked only in gobl.ubl'sAccepts. Matching on addons therefore offers UBL Peppol for any invoice, including the US example, and the export then fails withnot-supported. Fixing this needs the register to expose per-schema addon requirements (or an "accepts" check) upstream in GOBL'sconvert.🤖 Generated with Claude Code