Repository navigation
#71: Consume nemar-cli /<id>/page-bundle.json on dataset detail - #72
Merged
Merged
Conversation
Wires the website's dataset detail SSR fetch chain to the unified GET /<id>/page-bundle.json?v=<v> endpoint (nemar-cli#617). One upstream call replaces three of the four previous parallel fetches (landing + metadata + catalog_row); QA stays separate (intentionally out of the bundle per #617 scope). The bundle accepts ?v=<v> or no version (resolves to landing.latest internally), so deep links and bare /dataset/<id> both pay one RTT. Adds: - BundleField<T> + DatasetPageBundle types in src/lib/data-api.ts - getDatasetPageBundleOutcome(id, v) helper (4s timeout, FetchOutcome shape so the existing resolveDatasetPageStatus works unchanged) - bundleFieldToOutcome adapter that lifts the bundle's per-field { ok, data } envelope into the existing FetchOutcome union - bundle-first SSR in dataset/[id].astro with the pre-#71 fan-out intact as the fallback (404 / 503 / timeout / parse error all fall through cleanly) - 8 unit tests against a captured 16KB real-shape fixture, including schema 1.1 readme.content roundtrip so Phase 2's Step 0.5 contract stays pinned 401/401 tests pass; bun run build clean. Closes #71
Deploying nemar-website with
|
| Latest commit: |
aa68cfa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc536205.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-71-page-bundle.nemar-website.pages.dev |
Five sonnet reviewers ran in parallel. Critical + important fixes: - code-reviewer + pr-test-analyzer: DatasetPageBundle.catalog_row was typed BundleField<Dataset>, but the bundle endpoint actually emits a structurally sparse subset (no id, doi, status, etc.). Define a dedicated BundleCatalogRow with the fields the bundle guarantees; switch catalog_row's generic to it; update the consumer's catalogRow variable type. Dataset is now unused in data-api.ts so the import is dropped. - code-reviewer + pr-test-analyzer (forced into scope by the type fix): enrichedMetadata.license checked catalogRow?.doi (a typo for ?.license, plus ?: instead of ||) so the catalog's license never reached the rendered output for any code path. The BundleCatalogRow type made the broken reference a type error, forcing the fix. Now: license falls back from metadata.license to catalog_row.license to null in the canonical || chain that the sibling modalities/tasks/authors branches already use. - comment-analyzer + type-design-analyzer + code-reviewer: bundleFieldToOutcome's "bundle field ok=false" statusText was misleading when the actual cause was ok=true with data=null. Split into two distinct sentinel strings so Workers logs can triage which side of the worker's contract broke. Add a test asserting the new wording for the ok=true+data=null branch. - silent-failure-hunter: the partial-bundle warning conflated complete=false (real upstream failure) with enrichment_degraded alone (routine OpenNeuro sparse-catalog state). Log only on complete=false so chronic noise doesn't dilute the genuine signal. - silent-failure-hunter: parse_error was the only non-ok bundle outcome that signals CLI contract drift (200 with unparseable body); everything else is transient infrastructure. Branch the fallback log so parse_error fires at error level and the rest stay at warn. - code-reviewer (wording): the bundle-restructured fan-out is still effectively four-way (three SSR fetches + QA), just reorganized. Fix the misleading "three-way" comment. - comment-analyzer: tighten the BundleField doc with a scope- narrowing parenthetical so a future change to resolveDatasetPageStatus that consults summary/catalog_row doesn't silently invalidate the adapter contract. Deferred per existing-scope policy: extracting the enrichedMetadata merger to a pure helper for separate test coverage (pr-test- analyzer 6/10), bundle-vs-fan-out race pattern to bound 9s worst- case TTFB (code-reviewer important, follow-up issue territory). 401/401 tests pass; bun run build clean.
6 tasks
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.
Summary
Wires the website's dataset detail SSR fetch chain to the unified
GET /<id>/page-bundle.json?v=<v>endpoint shipped in nemar-cli#617 (closed; all 130 datasets backfilled to schema 1.1). One upstream call now serves landing + metadata + summary + catalog_row, replacing three of the four parallel fetches at the top ofsrc/pages/dataset/[id].astro. QA aggregates stay separate (intentionally out of the bundle per #617 scope) and run in parallel with the bundle fetch.The bundle accepts
?v=<v>or no version (resolves tolanding.latestinternally), so deep links and bare/dataset/<id>URLs both pay one RTT regardless of how the user arrived.The pre-#71 four-way fan-out stays as the fallback path: bundle 404 / 503 / timeout / parse-error all degrade transparently to the existing helpers, so older datasets without warm bundle entries, transient upstream outages, and rolling deploys never break a render.
Closes #71
Files touched
src/lib/data-api.ts—BundleField<T>+DatasetPageBundletypes,getDatasetPageBundleOutcomehelper (4s timeout, tighter than the 5s fan-out default so a slow bundle fails fast),bundleFieldToOutcomeadapter that lifts the bundle's per-field envelopes into the existingFetchOutcomeunion (soresolveDatasetPageStatusis reused unchanged),bundleUrlbuilder.src/pages/dataset/[id].astro— bundle-first SSR with the previous Promise.all preserved verbatim inside theelsebranch.src/lib/data-api.test.ts— 8 new tests (adapter contract + fixture roundtrip + schema 1.1 readme.content contract).test/fixtures/dataset-page-bundle-on005505.min.json— 16 KB slim of the live bundle (paths trimmed from 5,409 to 10, subjects from 136 to 5; readme.content kept intact for Phase 2 verification).Test plan
bun run typecheck— 0 errors / 0 warnings / 0 hintsbun run lint— biome clean (organizeImports applied by --write)bun run test— 401/401 (was 393; +8 indata-api.test.ts)bun run build— astro build clean, Workers-runtime warnings unchangedhttps://ww2.nemar.org/dataset/on005505should show ONEdata.nemar.orgfetch (the page-bundle) plus the QA fetch on cold isolate, instead of three separate ones. The deferred/api/dataset/<id>/{readme,tree}partial fetches still happen client-side as before./browseagainst the Pages preview — verify cold first-paint TTFB drops to ~1 s (current is closer to ~2 s due to serial fan-out + slowest ofgetMetadataOutcome's 5 s timeout).PUBLIC_DATA_BASE_URLat a bogus host: page must still render via the fan-out path, with the[dataset/<id>] bundle unavailablewarning visible in dev server logs.Out of scope (follow-up issues to file if perf gap persists)
readme.tsandtree.tsstill fetchsummary.jsonthemselves on the client side. The bundle already carriessummary.data— a future change could inline it into the SSR HTML and skip those fetches entirely. Out of scope here (requires shared SSR state or a separate proxy design).getLandingOutcome,getMetadataOutcome,getDatasetstay because they're the fallback path AND they're used directly by the partial endpoints' resolution chains. Cleanup once we're confident the bundle is universally reliable.