feat: add JSON-LD download and consolidate report download actions#146
Conversation
Wires the new ``LedgerClient.getReportBundleDownloadUrl`` SDK
method (0.3.35) into the saved-report viewer at /reports/[id]. The
button sits in the page-header actions row next to Share, scoped
to ``generationStatus === 'published'`` Reports — pre-publish
drafts have no stamped bundle to download.
Click flow:
1. SDK call fetches a short-lived presigned URL from the backend
(300s lifetime).
2. ``window.location.href = downloadUrl`` triggers the browser
download — the backend sets Content-Disposition: attachment
with a versioned filename (``{report_id}-v{n}.jsonld``), so
navigating to the URL writes the file to disk rather than
rendering it inline.
Error feedback surfaces in a dismissible Alert above the status
banner, carrying the server-returned detail string (e.g. "Report
has no stamped bundle — regenerate to produce one", which is the
expected failure for Reports published before the serialization
feature shipped).
In-flight state disables the button and swaps the icon for a
spinner — the SDK round-trip is the only thing the user waits
for; the download itself starts as soon as the browser hits the
presigned URL.
The two side-by-side ``Download JSON-LD`` and ``Download XBRL`` buttons read as cluttered now that we have format alternatives. Replace with a single ``Download`` button that opens a dropdown listing the available formats: Download ▾ ├── JSON-LD bundle └── XBRL 2.1 package Cleaner toolbar; trivially extensible when new flavors arrive (Turtle, OIM xBRL-JSON, etc.) — each becomes another ``DropdownItem`` without growing the header's button count. Disabled state on the dropdown trigger reflects either in-flight download; per-item disabled reflects the specific format's spinner. XBRL handler: * Calls the new SDK ``getReportBundleXbrlZip`` method (Blob + server-suggested filename + generation count from response headers). * Creates an object URL, anchor-clicks it with the suggested filename, then schedules ``URL.revokeObjectURL`` after 5 seconds so the browser's download path completes before the URL is released (immediate revoke cancels in-flight saves on some browsers). Tested end to end through puppeteer: dropdown opens cleanly, XBRL option triggers an SDK call returning a 10KB zip with the right Content-Type, the anchor click triggers the download with the suggested filename. JSON-LD path remains unchanged from the prior implementation.
Picks up ``getReportBundleDownloadUrl`` (presigned URL for the stamped JSON-LD bundle) and ``getReportBundleXbrlZip`` (binary stream for the XBRL 2.1 zip) from the published TypeScript SDK. The /reports/[id] page already uses both — the dep bump replaces the ``file:../robosystems-typescript-client`` local-dev swap with the published version. 420 tests pass, lint clean.
|
@claude please review this PR |
|
Claude finished @jfrench9's task in 1m 35s —— View job PR Review: feat: add JSON-LD download and consolidate report download actionsTasks:
OverviewOverall this is a solid, well-structured addition. The two-strategy download pattern (presigned URL redirect for JSON-LD, blob/anchor for XBRL) is architecturally sound and the individual concerns below are mostly minor. A few things worth addressing before merge. Issues1. Version bump violates project convention (medium)
The underlying SDK functionality may require this bump, but the version pin should be reverted and the user should own that change separately. Fix this → 2. Redundant
|
…ments The parent Download dropdown is already disabled while either download is in flight, so the per-item disabled props never evaluated. Also condense the download-handler comments to the non-obvious why.
Summary
This PR introduces JSON-LD serialization support for reports and improves the download experience by consolidating multiple download buttons into a single unified dropdown menu.
Changes
Report Viewer Enhancements (
src/app/(app)/reports/[id]/content.tsx)Dependency Updates
@robosystems/clientfrom previous version to 0.3.36, which likely includes the underlying API support for JSON-LD report serialization.Key UI/UX Improvements
Breaking Changes
None. This is an additive feature change. Existing download functionality is preserved within the new dropdown UI.
Testing Notes for Reviewers
/reports/[id]and verify the download button renders as a dropdown with all available options (including JSON-LD)..jsonldor.jsonextension.@context,@typefields as applicable).Browser Compatibility Considerations
Blob/URL.createObjectURLor an anchor download) works consistently across browsers, especially Safari which can have differing behavior with programmatic downloads.🤖 Generated with Claude Code
Branch Info:
feature/report-serializationmainCo-Authored-By: Claude noreply@anthropic.com