feat(db): add GET /api/db/collection/export (zip / installable .xar)#68
Draft
joewiz wants to merge 1 commit into
Draft
feat(db): add GET /api/db/collection/export (zip / installable .xar)#68joewiz wants to merge 1 commit into
joewiz wants to merge 1 commit into
Conversation
7512021 to
9ef350a
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 58 |
| Duplication | 3 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
9ef350a to
74da078
Compare
Export a collection subtree as a ZIP (default) or an installable EXPath .xar, with caller-chosen serialization params (indent, omit-xml-declaration, expand-xincludes, and the full vocabulary) applied to XML resources only; binary resources are stored byte-for-byte. format=xar names the archive <abbrev>-<version>.xar from expath-pkg.xml and places expath-pkg.xml/repo.xml at the archive root so it installs via repo:install-and-deploy (400 if the collection has no descriptor). Delegates to eXist's compression:zip, passing the serialization params as its 5th argument; reuses the dbc:serialization-params helper from the resource-consolidation work (exist:-namespace expand-xincludes). Requires an eXist base with the compression serialization-options argument (eXist-db/exist#6493). Bumps the OpenAPI contract version (info.version) to 0.10.0 for the additive endpoint. Tests: cypress db_export.cy.js (13 cases), green against the #6493 build; fixtures seed via native eXist REST to stay independent of the resource-store path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
74da078 to
72cd777
Compare
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.
[This PR was co-authored with Claude Code. -Joe]
Summary
Adds
GET /api/db/collection/export— download a whole collection subtree as a ZIP (default) or an installable EXPath.xar, with caller-chosen serialization parameters applied to the XML resources. This is the server side of the existdb-oxygen-plugin / eXide "download collection / download package" features (both need per-call serialization control over the archived XML).Endpoint
Content-Type: application/zip,Content-Disposition: attachment.zip→<collectionName>.zip.xar→<abbrev>-<version>.xarread from the collection'sexpath-pkg.xml, withexpath-pkg.xml/repo.xmlat the archive root so it installs viarepo:install-and-deploy. Axarrequest for a collection withoutexpath-pkg.xmlis a clean400.conf.xmldefaults.404for a missing collection,400for a missingpath.How it works
The handler delegates to eXist's
compression:zip, passing the caller's serialization parameters as its 5th argument — the<output:serialization-parameters>element built by the existingdbc:serialization-paramshelper (theexist:-namespaceexpand-xincludesform from the resource-consolidation work). Core does the recursion, prefix-stripping, binary-safety, and per-resource serialization; the handler is a thin wrapper.db-core.xqmgainsdbc:export-collection(roaster-independent);db.xqmgains thedb:export-collectionroute handler.Serialization parameters follow the same convention as
/api/db/resource: the W3C parameters keep their plain names (indent,omit-xml-declaration, …) and the implementation-defined eXist extensions carry anexist:prefix on the wire (exist:expand-xincludes,exist:highlight-matches, …), mirroring theexist:serialization namespace. That convention is shared with/api/db/resource(merged in #59).Dependency
compression: add serialization-options argument to compression:zip / compression:tar). The endpoint's 5-argumentcompression:zipcall has no fallback: the signature simply does not exist without this core change, so the module fails to compile and the whole/api/dbsurface 500s. This PR waits on #6493 being reviewed and merged, then reaching theexistdb/existdb:latestCI image./api/db/resourceconsolidation this built on) has merged, so this branch is now rebased ontodevelopas a single export commit — it inherits the mergedexist:serializer convention and thedbc:storebinary-under-XML-mime workaround (the eXist-db/exist#6497 fix), which is why #6497 does not separately gate this PR. #6493 is the only remaining blocker.Testing
src/test/cypress/e2e/db_export.cy.js— 13 cases, all green against a build carrying eXist-db/exist#6493:Content-Dispositionfilename; archive-root-relative entry names across a subtreeindent(compact vs pretty),omit-xml-declaration,exist:expand-xincludes(preserve vs expand) applied to the archived XML; no-params =conf.xmldefaultxarfilename + descriptors at the archive root;xar-without-expath-pkg.xml→400; missingpath→400; missing collection →404Fixtures are seeded via native eXist REST so the export tests don't depend on the resource-store endpoint.
Notes
info.versionto0.15.0(additive endpoint, above develop's0.14.0).jszipas a dev-dependency, used by the spec to assert archive contents.