Skip to content

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

Open
uniqueg wants to merge 2 commits into
devfrom
feat/452-service-types
Open

uniqueg wants to merge 2 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): 96 passed; the new file has 16 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: all checks green (Lint, Test on Node 22 and 24 incl. WebKit, CodeQL, Codecov patch and project, Read the Docs preview).

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.

Open questions

None.

Closes #452

🤖 Generated with Claude Code

Summary by Sourcery

Add a service types view for GA4GH Service Registries with typed events, resilient provider handling, and supporting documentation.

New Features:

  • Add a service registry component that lists registry service types with their group, artifact, and version.
  • Emit typed service-type change events for loaded, cleared, and failed data.],
  • bug_fixes [],
  • enhancements [
  • Support provider and base URL lifecycle changes with loading, empty, error, and stale-request handling.

Bug Fixes:

Enhancements:

Documentation:

  • Document the new service types component, live preview, provider usage, and demo.

Tests:

  • Add comprehensive component tests covering rendering states, provider lifecycle, events, and stale loads.

Chores:

  • Add a minor-release changeset for the service types component.

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 and expose it from the events barrel.

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

API

Add the service-types component with its provider and base-URL properties, loading lifecycle, table rendering, error handling, and change event.

  • packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts L1-257

Register and export the new custom element, including its tag-name typing and package-level component import.

  • 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

Uses of the API

Add the documentation preview that instantiates the component against the configured registry endpoint and logs its change event.

  • apps/documentation/components/packages/service-registry/ServiceTypesPreview.tsx L1-19

Add a demo page that mounts the component against a registry URL and logs emitted changes, and link it from the demo index.

  • packages/ecc-client-ga4gh-service-registry/demo/index.html L22-25
  • packages/ecc-client-ga4gh-service-registry/demo/service-types/index.html L1-33

Configuration

Record the minor release and summarize the new service-types component in the changeset.

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

Documentation

Document the component's usage, properties, event, states, and live preview, and list it in the service-registry documentation navigation.

  • apps/documentation/pages/docs/service-registry/components/_meta.json L3-4
  • apps/documentation/pages/docs/service-registry/components/service-types.mdx L1-139

Introduce service types as a package capability and connect the provider method documentation to the new component.

  • apps/documentation/pages/docs/service-registry/introduction.mdx L17, L23 (removed lines)
  • apps/documentation/pages/docs/service-registry/providers.mdx L128

Tests

Cover service-type rendering, loading and error states, event payloads, provider lifecycle, and stale-load handling.

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

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.63235% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.88%. Comparing base (47fd42d) to head (ebafe1e).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...stry/src/components/service-types/service-types.ts 99.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #596      +/-   ##
==========================================
+ Coverage   74.40%   74.88%   +0.47%     
==========================================
  Files          63       65       +2     
  Lines       16815    17087     +272     
  Branches      925      954      +29     
==========================================
+ Hits        12512    12796     +284     
+ Misses       4287     4275      -12     
  Partials       16       16              

☔ 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 ebafe1e

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

# Requirement Status Notes
1 Use the provider’s existing getServiceTypes() to list the registry’s service types. ✅ Met The component calls getServiceTypes() and renders each returned type’s group, artifact and version.
2 Add loading, empty ([]) and error states. ✅ Met It renders skeleton rows while loading, “No service types found” for an empty list, and the error message when a load 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 ✨

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;

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.

🟡 Medium · 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.

Prompt for AI agents
In `packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts` at line 114:

**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.

try {
const serviceTypes = await provider.getServiceTypes();
if (stale()) return;
this.serviceTypes = serviceTypes;

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.

🟡 Medium · 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.

Prompt for AI agents
In `packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts` at line 122:

**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.


@property({ type: String, reflect: true }) baseUrl = "";
@property({ attribute: false, reflect: true })
provider?: ServiceRegistryProvider;

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.

⚪ Low · 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.

Prompt for AI agents
In `packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts` at line 40:

**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.

const serviceTypes = await provider.getServiceTypes();
if (stale()) return;
this.serviceTypes = serviceTypes;
this.dispatchChanged(serviceTypes);

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.

🟡 Medium · 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.

Prompt for AI agents
In `packages/ecc-client-ga4gh-service-registry/src/components/service-types/service-types.ts` at line 123:

**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.

await waitUntil(() =>
fetchStub
.getCalls()
.some((call) => call.args[0] === `${OTHER_URL}/services/types`)

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.

🟡 Medium · 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.

Prompt for AI agents
In `packages/ecc-client-ga4gh-service-registry/src/components/service-types/tests/service-types.test.ts` at line 217:

**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.

This branch has not been deployed

No deployments
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

1 participant