Repository navigation
Conversation
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>
Reviewer's GuideData structuresDefine the typed payload for the service-types-changed event and expose it from the events barrel.
APIAdd the service-types component with its provider and base-URL properties, loading lifecycle, table rendering, error handling, and change event.
Register and export the new custom element, including its tag-name typing and package-level component import.
Uses of the APIAdd the documentation preview that instantiates the component against the configured registry endpoint and logs its change event.
Add a demo page that mounts the component against a registry URL and logs emitted changes, and link it from the demo index.
ConfigurationRecord the minor release and summarize the new service-types component in the changeset.
DocumentationDocument the component's usage, properties, event, states, and live preview, and list it in the service-registry documentation navigation.
Introduce service types as a package capability and connect the provider method documentation to the new component.
TestsCover service-type rendering, loading and error states, event payloads, provider lifecycle, and stale-load handling.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
50 files changed ·
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit ebafe1e #452 feat(service-registry): add service-types component · 2 of 2 met
|
There was a problem hiding this comment.
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
| 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; |
There was a problem hiding this comment.
🟡 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; |
There was a problem hiding this comment.
🟡 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; |
There was a problem hiding this comment.
⚪ 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); |
There was a problem hiding this comment.
🟡 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`) |
There was a problem hiding this comment.
🟡 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.
Summary
Adds
ecc-client-ga4gh-service-registry-service-typesto@elixir-cloud/service-registry. It lists the service types of a registry (GET /services/types) through the provider's existinggetServiceTypes(): one table row per type (group badge, artifact, version) in the registry's order.[], the error message of a failed request, and the usual "Please provide either a base URL ... or a custom provider" without either.services/servicecomponents (fix: react to provider set after the first update #577):baseUrlorprovider, set or replaced after the first update, only the latest load applies, and a removed provider or failed load clears the list.ecc-service-types-changedwith{ serviceTypes }(typedEccServiceTypesChangedEvent), exported from./events; React wrapperonEccServiceTypesChangedis generated.service-registry/components/service-typeswith a live preview (the public registry serves CORS for/services/types), entries in_meta.json, the introduction and thegetServiceTypes()provider docs; demo pagedemo/service-types; changeset (minor).Verification
npx web-test-runner --group defaultin the package (Chromium and Firefox): 96 passed; the new file has 16 tests, with 100 % line coverage ofservice-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 theno-consoleon the error log, the same as in the siblings.npx turbo run buildandnext buildof the docs: pass;/docs/service-registry/components/service-typesis generated.Declined review findings
services.ts/service.ts. Every component in the repo carries its own copy today. Extracting a shared controller would touchservices.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.2.0.0-alpha.52, not2.0.0-alpha.6like 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.reflect: trueonprovider,anyin 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:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: