Skip to content

Expose signed invoice download URLs - #118

Merged
javorosas merged 10 commits into
mainfrom
feat/signed-invoice-download-urls
Sep 19, 2026
Merged

javorosas merged 10 commits into
mainfrom
feat/signed-invoice-download-urls

Conversation

@javorosas

@javorosas javorosas commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add URL counterparts to the existing document download methods: downloadPdfUrl, downloadXmlUrl, and downloadZipUrl where each representation is available
  • add downloadZipRequestUrl, previewPdfUrl, and previewToInvoicePdfUrl alongside their binary counterparts
  • include explicit cancellation-receipt URL methods following the same naming pattern
  • expose url, expires_at, content_type, and filename
  • correct the existing receipts-to-invoice preview path to match the public API
  • validate missing resource IDs before issuing requests
  • publish as additive release 5.1.0 when merged

Format compaction remains a concern of the MCP server; the public SDK preserves its established per-operation method design.

Depends on FacturAPI/facturapi#2285. Public API documentation is in FacturAPI/facturapi-docs#299.

Verification

  • pnpm run build
  • pnpm run test:unit (48 passed: 38 Node + 10 web)
  • pnpm run test:types

The new methods are additive, so this is a minor release.

The bump is not optional here. `deploy.yml` publishes only when
`npm view <package>@<version>` misses, so merging the signed-URL work while
package.json still said 5.0.0 would have skipped the publish silently, and the
Slack notification is gated on the same condition, so nothing would have
reported it either. It is also what unblocks the consumers that need these
methods.
Add `receipts.getDownloadUrl(id)` and `retentions.getDownloadUrl(id, format)`
alongside the invoice methods, so a caller can hand a short-lived URL to its own
user or client instead of receiving the file itself.

A receipt has one representation — a nota de venta is not stamped, so there is
no XML — which is why its method takes no format. `SignedDownloadUrl` moves in
with the other shared types now that three resources return it, and the tests
for the whole surface live in one file.
The escaped unicode sequences in the description, keywords, author and
contributors are equivalent to the literal characters a previous edit replaced
them with, and the change had nothing to do with this feature. Restore the file
so the diff only carries the work it is about.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved requests remain for compile-time API assertions and broader PDF/XML/cancellation URL test coverage.

Pull request overview

Adds signed download URL APIs and metadata across invoice, receipt, retention, preview, and ZIP-request resources.

Changes:

  • Adds SignedDownloadUrl and URL-based resource methods.
  • Corrects the receipts-to-invoice preview endpoint and validates resource IDs.
  • Updates tests, documentation, changelog, and version to 5.1.0.
File summaries
File Summary
test/web/runtime-compat.web.test.ts Updates the preview endpoint expectation.
test/node/signed-download-urls.node.test.ts Tests signed URL requests and validation.
test/node/runtime-compat.node.test.ts Updates the preview endpoint expectation.
test/node/invoices-zip-requests.node.test.ts Tests ZIP-request URL support.
src/types/common.ts Defines the SignedDownloadUrl type.
src/resources/retentions.ts Adds retention URL methods.
src/resources/receipts.ts Adds receipt URL support and corrects preview routing.
src/resources/invoices.ts Adds invoice, cancellation, preview, and ZIP-request URL methods.
README.md Documents signed URL usage.
package.json Bumps the version to 5.1.0.
CHANGELOG.md Records the 5.1.0 release changes.
Review details

Suppressed comments (3)

src/types/common.ts:157

  • This adds a public SignedDownloadUrl contract, but the repository's compile-time API suite (test-d/runtime-types.test-d.ts) has no assertion for this type or any of the new URL methods. The runtime tests do not verify the generated declaration shape, so a wrong export or return type could still pass test:types; add tsd assertions for SignedDownloadUrl and representative URL methods (including the preview and ZIP-request variants).
export interface SignedDownloadUrl {
  url: string;
  expires_at: string;
  content_type: string;
  filename: string;

test/node/signed-download-urls.node.test.ts:88

  • Only retentions.downloadXmlUrl is exercised here; the new PDF and ZIP URL methods are untested, so a typo in either route would not be caught. Add successful-request assertions for all three retention formats, preferably by parameterizing the cases.
    const result = await client.retentions.downloadXmlUrl('ret_123')

test/node/signed-download-urls.node.test.ts:38

  • The added suite only exercises downloadZipUrl for invoice downloads, so regressions in the new PDF/XML URL paths—and the successful cancellation XML URL path—would still pass. Add successful-request cases for each newly exposed invoice format (or a table-driven test) with their expected URLs.
    const result = await client.invoices.downloadZipUrl('inv_123')
  • Files reviewed: 11/11 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@javorosas javorosas self-assigned this Sep 19, 2026
@javorosas
javorosas merged commit 1dd6007 into main Sep 19, 2026
6 checks passed
@javorosas
javorosas deleted the feat/signed-invoice-download-urls branch September 19, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants