Skip to content

feat(website): add API wrapper for collections backend API#1081

Merged
fhennig merged 14 commits intomainfrom
generalized-collections-frontend-api
Mar 24, 2026
Merged

feat(website): add API wrapper for collections backend API#1081
fhennig merged 14 commits intomainfrom
generalized-collections-frontend-api

Conversation

@fhennig
Copy link
Contributor

@fhennig fhennig commented Mar 17, 2026

This is part of #938

Summary

  • move existing backendApi dir out of the subscriptions, into the top level where the other API stuff is also located (lapis, covspectrum).
  • Add new types and functions for the backend API
  • Use a common proxyToBackend function for subscriptions and collections API
  • drop userId everywhere, because it's already added later on in the backend proxy

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by an appropriate test.

@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboards Ready Ready Preview, Comment Mar 23, 2026 2:37pm

Request Review

@fhennig fhennig self-assigned this Mar 17, 2026
@fhennig fhennig changed the title Generalized collections frontend api feat(website): add API wrapper for collections backend API Mar 17, 2026
@fhennig fhennig force-pushed the generalized-collections-frontend-api branch from 1d68c9d to 6ff08e9 Compare March 17, 2026 14:55
@fhennig fhennig marked this pull request as ready for review March 17, 2026 14:55
@fhennig fhennig force-pushed the generalized-collections-frontend-api branch from 6ff08e9 to 8ca09af Compare March 17, 2026 15:04
@fhennig fhennig force-pushed the generalized-collections-pt1 branch from ae8ba83 to 9629cdd Compare March 18, 2026 10:58
@fhennig fhennig force-pushed the generalized-collections-frontend-api branch from 8ca09af to 5a45f69 Compare March 18, 2026 10:59
@fhennig fhennig force-pushed the generalized-collections-frontend-api branch from 9e5ed16 to db7b941 Compare March 18, 2026 14:11
Base automatically changed from generalized-collections-pt1 to main March 19, 2026 14:50
@fhennig fhennig force-pushed the generalized-collections-frontend-api branch from db7b941 to 9870dc4 Compare March 19, 2026 15:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a generalized website-side API wrapper to support the new “collections” backend endpoints while consolidating existing subscriptions backend API plumbing at website/src/backendApi and introducing a shared /api/* proxy that injects userId from the authenticated session.

Changes:

  • Introduces BackendService collections endpoints + Collection zod schemas.
  • Replaces the subscriptions-specific proxy with a shared proxyToBackend used by both subscriptions and collections routes.
  • Removes explicit userId plumbing in subscriptions UI and client API calls (now derived in the proxy).

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
website/src/util/getErrorLogMessage.ts Updates import path after backend API relocation.
website/src/types/Collection.ts Adds zod schemas/types for collections + request/update payloads.
website/src/pages/subscriptions/index.astro Drops userId prop wiring into client component.
website/src/pages/subscriptions/create.astro Drops userId prop wiring into client component.
website/src/pages/api/subscriptions/[...path].ts Switches to shared proxyToBackend.
website/src/pages/api/collections/[...path].ts Adds collections API route using shared proxyToBackend.
website/src/pages/api/backendProxy.ts New shared backend proxy that appends userId from session.
website/src/layouts/OrganismPage/DataPageLayout.tsx Updates withQueryProvider import location.
website/src/components/views/wasap/WasapPage.tsx Updates withQueryProvider import location.
website/src/components/views/sequencingEfforts/CountStatistics.tsx Updates withQueryProvider import location.
website/src/components/subscriptions/overview/Subscriptions.tsx Removes userId prop usage; updates query/service calls to new API location.
website/src/components/subscriptions/overview/SubscriptionEntry.tsx Removes userId usage for delete; updates API import location.
website/src/components/subscriptions/create/SubscriptionsCreate.tsx Removes userId usage for create; updates API import location.
website/src/components/pageStateSelectors/DynamicDateFilter.browser.spec.tsx Updates withQueryProvider import location for tests.
website/src/backendApi/withQueryProvider.tsx New shared React Query provider HOC.
website/src/backendApi/querySubscriptions.ts Drops userId parameter; uses session-proxied backend API.
website/src/backendApi/backendService.ts Moves/extends backend API client; adds collections endpoints; removes userId params.
website/src/backendApi/backendService.spec.ts Updates tests to align with removal of userId in client calls.
website/routeMocker.ts Updates backend route mock helpers to match new request shapes (no userId).
Comments suppressed due to low confidence (3)

website/src/backendApi/backendService.ts:166

  • The deleteSubscription response schema uses z.literal('').refine((input): input is never => true), which makes the parsed return type never even though the method resolves with an empty string at runtime. This is misleading for callers and can break type-driven control flow. Prefer returning void (transform the schema to undefined) or keep the output type as string without narrowing to never.
    website/src/backendApi/backendService.ts:198
  • Same issue as deleteSubscription: the schema z.literal('').refine((input): input is never => true) narrows the return type to never while the request resolves normally. Consider returning void (schema transform) or keep the schema output type as string to avoid misleading typing for deleteCollection.
    website/src/backendApi/backendService.ts:199
  • BackendService adds new collections endpoints (getCollections, getCollection, postCollection, putCollection, deleteCollection) but there are no corresponding tests in backendService.spec.ts. Since this file already has request/response contract tests for subscriptions, adding similar tests for the collections methods would help catch regressions (URL, params, and schema parsing).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fhennig and others added 12 commits March 23, 2026 12:27
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
userId is injected by the backend proxy from the session, so there
is no need to pass it from the client.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The userId is added by the backend proxy, so callers don't need to supply it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- MutationListDefinition -> FilterObject
- mutationList discriminator -> filterObject
- mutationList field -> filterObject on variant objects
- aaMutations/nucMutations/aaInsertions/nucInsertions -> spelled-out names
- filters sub-object removed; arbitrary filter props now top-level via catchall

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces [...path].ts with index.ts (GET+POST) and [id].ts (GET+PUT+DELETE),
making auth requirements per endpoint explicit. Also adds proxyToBackendOptionalAuth
to backendProxy.ts to support endpoints where auth is optional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover fetching all collections and filtering by organism query param.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ection GETs

Forwarding userId on read requests caused the backend to filter
collections by owner. Collection reads are always public, so no auth
context is needed. Removes proxyToBackendOptionalAuth entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

website/src/backendApi/backendService.spec.ts:188

  • Collections support adds additional BackendService methods (getCollection, postCollection, putCollection, deleteCollection), but the tests added here only cover getCollections. Adding unit tests for the remaining new methods would help catch request/response-shape regressions as the API evolves.
    website/src/backendApi/backendService.ts:165
  • This delete endpoint uses z.literal('').refine((input): input is never => true). The type predicate forces the Zod output type to never, so deleteSubscription is typed as returning Promise<never> even though at runtime it returns the empty string. Use a schema whose output type matches the intended return (e.g., z.literal('')), or transform to void/undefined if the API returns 204/empty bodies.
    website/src/backendApi/backendService.ts:198
  • Same issue as deleteSubscription: z.literal('').refine((input): input is never => true) makes the Zod output type never while runtime returns ''. Prefer z.literal('') (returning '') or a transform to void/undefined for empty-body deletes, so the method return type is usable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fhennig fhennig merged commit b11b4d6 into main Mar 24, 2026
13 checks passed
@fhennig fhennig deleted the generalized-collections-frontend-api branch March 24, 2026 08:29
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.

3 participants