Skip to content

feat(service-registry): add service types list - #596

Merged
anuragxxd merged 9 commits into
devfrom
feat/452-service-types
Nov 23, 2026
Merged

anuragxxd merged 9 commits into
devfrom
feat/452-service-types

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds ecc-client-ga4gh-service-registry-service-types to @elixir-cloud/service-registry. It lists the service types of a registry (GET /services/types) through the provider's existing getServiceTypes(): one table row per type (group badge, artifact, version) in the registry's order.

  • States: placeholder rows while loading, "No service types found" for [], the error message of a failed request, and the usual "Please provide either a base URL ... or a custom provider" without either.
  • Provider lifecycle as in the sibling services / service components (fix: react to provider set after the first update #577): baseUrl or provider, set or replaced after the first update, only the latest load applies, and a removed provider or failed load clears the list.
  • Event ecc-service-types-changed with { serviceTypes } (typed EccServiceTypesChangedEvent), exported from ./events; React wrapper onEccServiceTypesChanged is generated.
  • Docs: new page service-registry/components/service-types with a live preview (the public registry serves CORS for /services/types), entries in _meta.json, the introduction and the getServiceTypes() provider docs; demo page demo/service-types; changeset (minor).

Verification

  • npx web-test-runner --group default in the package (Chromium and Firefox): 102 passed; the new file has 22 tests, with 100 % line coverage of service-types.ts. WebKit doesn't run locally (the browser build that Playwright 1.56 needs isn't installed and needs system packages); CI runs it.
  • npm run lint (husky pre-commit, all packages): no errors; the only new warning is the no-console on the error log, the same as in the siblings.
  • npx turbo run build and next build of the docs: pass; /docs/service-registry/components/service-types is generated.
  • CI: pending for f8a7a63 (6bb0ca2 all green after one rerun of a WebKit timeout in the unrelated design package; before that all green for 997375d: Lint, Test on Node 22 and 24 incl. WebKit, CodeQL, Codecov, Read the Docs preview, Sourcery review).

Declined review findings

  • Quality (medium): the provider lifecycle code is duplicated from services.ts / service.ts. Every component in the repo carries its own copy today. Extracting a shared controller would touch services.ts, which open PRs feat(cloud-registry): verifications #578 and feat(cloud-registry): verified badge in list #581 change; better a follow-up once they're merged, if Anurag wants it.
  • Quality (medium): the docs pin 2.0.0-alpha.52, not 2.0.0-alpha.6 like the sibling pages. The component first ships in the next release, so an older version in the badge or the esm.sh example would not contain it.
  • Quality (low): reflect: true on provider, any in the preview handler, and no event for an initially missing provider. All three match the sibling components exactly; this PR keeps them consistent.
  • Sourcery (medium): a load that settles between a property change and Lit's next update still applies. That one-microtask window is the same in services and service (fix: react to provider set after the first update #577); closing it belongs in a change to all components of the package.
  • Sourcery (medium): a detached and reinserted element doesn't emit its data again. None of the package's components do.
  • Sourcery (low): provider could take a narrower type. Every component takes the full ServiceRegistryProvider; narrowing it is a package-wide API decision.

Fixed after Sourcery's review: a response that isn't a list now shows an error, and the base URL test checks the types shown for the new URL.

Fixed after Sourcery's review of the stacked #597 (8e578f4, 6bb0ca2, f8a7a63): an Error with an empty message shows the generic error, and a list with null or a type without string group, artifact and version now shows an error instead of breaking the table render, and the docs say that removing a custom provider falls back to the baseUrl.

Open questions

None.

Closes #452

🤖 Generated with Claude Code

Summary by Sourcery

Add a service types component for displaying and reporting the types registered by a GA4GH Service Registry.

New Features:

  • Add a service types web component that lists registry service types with group, artifact, and version information.
  • Emit typed service-type change events and provide the generated React event wrapper.

Bug Fixes:

  • Handle invalid service-type responses and failed or stale provider loads without rendering invalid data.

Enhancements:

  • Support loading, empty, error, provider, and base URL states consistent with the existing service registry components.

Documentation:

  • Add service types component documentation, live preview, provider guidance, and a standalone demo.

Tests:

  • Add comprehensive component coverage for rendering, loading, errors, provider lifecycle, response validation, and event behavior.

Chores:

  • Add the package changeset for the new minor feature.

uniqueg and others added 2 commits November 17, 2026 19:48
Add ecc-client-ga4gh-service-registry-service-types, which lists the
service types of a registry (GET /services/types) through the
provider's getServiceTypes(), with loading, empty and error states. It
follows the provider lifecycle of the other components (provider set
or replaced after the first update, only the latest load applies) and
fires ecc-service-types-changed with the loaded types.

Add its documentation page, live preview, demo page and changeset.

Closes #452

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test that clearing the base URL of the service types list clears the
types, fires ecc-service-types-changed with none and asks for a
provider. Correct the docs, which said that removing the provider
loads the types again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Data structures

Define the typed payload for the service-types-changed event so consumers receive a consistent serviceTypes array.

  • packages/ecc-client-ga4gh-service-registry/src/events/ecc-service-types-changed.ts L1-11

API

Expose and register the service-types custom element, including its public properties and documented change event.

  • packages/ecc-client-ga4gh-service-registry/src/components/index.ts L3
  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/index.ts L1-15
  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts L26-53, L105-114
  • packages/ecc-client-ga4gh-service-registry/src/events/index.ts L3

Implementation

Implement provider selection, loading, response validation, stale-request handling, and clearing or reporting failed data.

  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts L1-25, L54-104, L115-156

UI

Render loading placeholders, the empty state, errors, and a table row for each service type.

  • packages/ecc-client-ga4gh-service-registry/demo/index.html L22-25
  • packages/ecc-client-ga4gh-service-registry/demo/service-types/index.html L1-33
  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts L157-274

Configuration

Record the package minor release and the new component in the changeset.

  • .changeset/service-registry-service-types.md L1-5

Documentation

Document the service-types component, its provider usage and event, and add it to the registry overview and provider guidance.

  • apps/documentation/components/packages/service-registry/ServiceTypesPreview.tsx L1-19
  • apps/documentation/pages/docs/service-registry/components/_meta.json L3-4
  • apps/documentation/pages/docs/service-registry/components/service-types.mdx L1-137
  • apps/documentation/pages/docs/service-registry/introduction.mdx L17, L23 (removed lines)
  • apps/documentation/pages/docs/service-registry/providers.mdx L128

Tests

Verify rendering, provider lifecycle, invalid responses, events, and stale-load behavior for the new component.

  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/tests/service-types.test.ts L1-428

Other changes

Files not grouped.

  • apps/documentation/pages/docs/service-registry/introduction.mdx L24

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.65398% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.48%. Comparing base (b35b87a) to head (8f2866d).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...stry/src/components/service-types/service-types.ts 99.63% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #596      +/-   ##
==========================================
+ Coverage   77.46%   78.48%   +1.02%     
==========================================
  Files          76       78       +2     
  Lines       19477    19928     +451     
  Branches     1268     1352      +84     
==========================================
+ Hits        15087    15640     +553     
+ Misses       4368     4275      -93     
+ Partials       22       13       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@uniqueg
uniqueg requested a review from anuragxxd November 17, 2026 20:44
@uniqueg
uniqueg marked this pull request as ready for review November 17, 2026 20:45
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 8f2866d

#452 feat(service-registry): add service-types component · 2 of 2 met

# Requirement Status Notes
1 Add a service-types component that lists registry service types using the provider's existing getServiceTypes(). ✅ Met The component calls getServiceTypes() and renders one row per returned type, preserving the provider's order.
2 Add loading, empty and error states, including an empty state when there are no service types. ✅ Met It renders placeholder rows while loading, “No service types found” for an empty list, and an error message when loading fails.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 5 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts" line_range="114" />
<code_context>
+    const load = this.dataLoads;
+    // a load from a provider that was replaced in the meantime, or that a
+    // newer load replaced, is dropped
+    const stale = () => provider !== this._provider || load !== this.dataLoads;
+
+    this.loading = true;
</code_context>
<issue_to_address>
**Old provider results briefly win**

When a provider or base URL changes after the old request settles but before Lit processes the resulting update, the old request's continuation sees the unchanged `_provider` and `dataLoads` before `updated()` processes the new property value, so it stores and emits the old types even though the caller has already selected another provider or URL. Event-driven callers can act on stale registry data before the new load completes.

Include the current public provider/base URL selection in the stale check, or otherwise invalidate outstanding loads synchronously when those properties change.
</issue_to_address>

### Comment 2
<location path="packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts" line_range="122" />
<code_context>
+    try {
+      const serviceTypes = await provider.getServiceTypes();
+      if (stale()) return;
+      this.serviceTypes = serviceTypes;
+      this.dispatchChanged(serviceTypes);
+    } catch (err) {
</code_context>
<issue_to_address>
**Malformed responses break rendering**

When the registry returns valid JSON that is not a `ServiceType[]`, `renderRows()` assumes the resolved value is an array and calls `.length` and `.map()` on it; a successful response with an unexpected JSON shape bypasses `loadData()`'s catch and breaks the table render instead of showing the error state.

Validate the response shape before assigning it, and route invalid data through the component's error state.
</issue_to_address>

### Comment 3
<location path="packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts" line_range="40" />
<code_context>
+
+  @property({ type: String, reflect: true }) baseUrl = "";
+  @property({ attribute: false, reflect: true })
+  provider?: ServiceRegistryProvider;
+
+  @state() private serviceTypes: ServiceType[] = [];
</code_context>
<issue_to_address>
**Custom providers need unrelated methods**

When a caller supplies a focused custom provider that only supports listing service types, a caller with a custom provider that implements only `getServiceTypes()` cannot pass it to this property without a TypeScript error; it must also implement `getServices()`, `getServiceById()` and `getServiceInfo()`, even though this component never calls them.

Type the property against a narrow interface or `Pick<ServiceRegistryProvider, "getServiceTypes">` so focused custom providers can be passed directly.
</issue_to_address>

### Comment 4
<location path="packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts" line_range="123" />
<code_context>
+      const serviceTypes = await provider.getServiceTypes();
+      if (stale()) return;
+      this.serviceTypes = serviceTypes;
+      this.dispatchChanged(serviceTypes);
+    } catch (err) {
+      if (stale()) return;
</code_context>
<issue_to_address>
**Detached loads lose their event**

When the element is detached from its listening ancestor while a request is pending, then reinserted after that request resolves, `loadData()` updates the list and dispatches the change event while the element is detached, so ancestor listeners do not receive it. Reinserted elements do not run `firstUpdated()` again or emit the current list, leaving event-driven callers out of sync.

On reconnection, emit the current loaded types or restart the load so ancestor listeners receive the current state.
</issue_to_address>

### Comment 5
<location path="packages/ecc-client-ga4gh-service-registry/src/components/service-types/tests/service-types.test.ts" line_range="217" />
<code_context>
+    await waitUntil(() =>
+      fetchStub
+        .getCalls()
+        .some((call) => call.args[0] === `${OTHER_URL}/services/types`)
+    );
+  });
</code_context>
<issue_to_address>
**Changed registry results go unchecked**

When a regression makes a request for the changed base URL but does not apply its response, `loads from the base URL and reloads when it changes` passes if the component fetches the new URL but ignores its response: the assertion checks only the request URL, not the types displayed after the change.

Return different types for each URL and assert that the changed URL's types are displayed or emitted.
</issue_to_address>

Sourcery assessment

Approval pending. 4 findings to address first.

Blocking findings: packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts:114, packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts:122, packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts:123, packages/ecc-client-ga4gh-service-registry/src/components/service-types/tests/service-types.test.ts:217


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Show an error, instead of breaking the table, when the registry sends
valid JSON for /services/types that is not a list. Check in the base
URL test that the types of the new URL are shown, not only fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uniqueg and others added 3 commits November 18, 2026 01:23
A list with null or a type without string group, artifact and version
broke the table render (getGroupVariant called includes on undefined).
Such a response now shows an error, like a response that is no list.

The docs say so, and that removing a custom provider falls back to the
base URL; only removing both clears the types and shows the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The error for a malformed type says the parts must be strings, as a
numeric artifact is present but wrong; the docs say so too, and the
tests check the full message with a typed case table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Error with an empty message left the error state empty, so the
component showed "No service types found" instead of a failure. It
now falls back to the generic message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@anuragxxd anuragxxd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @uniqueg — tested locally (110/110 in all three browsers, plus a run against elixir-on.cloud). I trimmed the docs and changeset a bit; hope that's OK.

@anuragxxd
anuragxxd merged commit f02ed1c into dev Nov 23, 2026
21 of 25 checks passed
@anuragxxd
anuragxxd deleted the feat/452-service-types branch November 23, 2026 06:53
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.

feat(service-registry): add service-types component

2 participants