Repository navigation
Phase 3: page-bundle endpoint for one-RTT dataset detail SSR - #624
neuromechanist merged 2 commits into
Conversation
Phase 3 of epic #618 / Closes #621. New `GET /<id>/page-bundle.json?v=<v>` returns landing + enriched metadata + summary + catalog row in one JSON response so the website can render the dataset detail page in a single SSR fetch instead of its current 4-parallel-SSR + 2-deferred-client waterfall. Internals: - backend/src/services/page-bundle.ts owns the fan-in. Each upstream is wrapped in Promise.allSettled and surfaces as a tagged union ({ok: true, data} | {ok: false, error}) so a single failure doesn't blank the whole bundle. - bundle.complete drives the cache header: success path gets long s-maxage + SWR, partial-failure path gets no-store so a transient blip isn't pinned at the edge for 24h. - Skips the latestManifest read (multi-MB) — the website renders the tree progressively from summary.paths per nemarOrg/website#64, so metadata.bids_index would be unused work here. - pickVersion falls back to landing.latest when the requested version is missing or unknown rather than 404-ing the whole bundle; the consumer can render a 'version not found, showing latest' UI from the bundle's own data. Route is registered before /:datasetId/:version so Hono doesn't treat 'page-bundle.json' as a version param. Mirrors the metadata.json registration order. Tests: 10 new unit tests for the pure helpers (pickVersion + settled). Per project policy, no D1/S3 mocks for the full buildPageBundle — end-to-end coverage is via the post-deploy smoke against a real dataset.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR624Version: 🤖 Updated on each push. |
|
Addressed PR review (4 agents): CRITICAL (silent-failure-hunter): Severity 8 (pr-test-analyzer): Extracted Silent-failure (borderline): Corrupt Comment fixes:
Improvement: summary JSON parse error message now includes the S3 key so forensic triage doesn't need a second lookup. Out of scope (acknowledged): shared Tests: 17/17 pass (was 10 → +7 truth-table). Backend typecheck clean. CI pending on this push. |
24b0df9
into
feature/issue-618-epic-summary-11
Summary
New
GET /<id>/page-bundle.json?v=<v>on data.nemar.org returns landing + enriched metadata + summary + catalog row in one response so the website can render the dataset detail page from a single SSR fetch instead of its current 4-parallel-SSR + 2-deferred-client waterfall.Each upstream is wrapped in
Promise.allSettledand surfaces as a tagged-union component ({ok: true, data}|{ok: false, error}). Partial-failure responses useCache-Control: no-storeso a transient blip isn't pinned at the CF edge for 24h via SWR; the success path getspublic, max-age=60, s-maxage=300, stale-while-revalidate=86400.Closes #621
Phase 3 of epic #618.
Design notes
summary.paths(per Progressive BIDS tree: render skeleton sync, lazy-load subject contents website#64), sometadata.bids_indexwould be unused work. The full/<id>/metadata.jsonendpoint still serves the complete index for the rare consumer that needs it.pickVersionis forgiving — unknown or empty?v=falls back to landing.latest rather than 404-ing the whole bundle. The consumer can render a "version not found, showing latest" UI from the bundle's own data./:datasetId/page-bundle.jsonis registered immediately after/:datasetId/metadata.jsonand before/:datasetId/:versionso Hono doesn't capturepage-bundle.jsonas a version.Why it's safe to ship before the website consumes it
Additive endpoint with no behavior change to existing routes. The website agent has nemarOrg/website#63/#64/#65 in flight and will hit this once it's live; until then nothing breaks.
Test plan
bun test test/page-bundle.unit.test.ts— 10/10 pass (pickVersion + settled wrapper)cd backend && bun run typecheck— cleancurl -s https://data.nemar.org/on005505/page-bundle.json?v=v1.0.0 | jq '{complete, version, landing: .landing.ok, metadata: .metadata.ok, summary: .summary.ok}'returns alltruecomplete: true, summary: {ok: true, data: null}(no published version is not a failure)version: <latest>, complete: trueCompanion