Skip to content

refactor(node): fetch device links from the API, drop the bundled matcher#5765

Merged
jamesarich merged 1 commit into
release/2.8.0from
jamesarich/device-links-api
Jun 10, 2026
Merged

refactor(node): fetch device links from the API, drop the bundled matcher#5765
jamesarich merged 1 commit into
release/2.8.0from
jamesarich/device-links-api

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

What

The device-links API is now live, so this reworks the "I want one" feature (#5714) to fetch resolved links from GET /resource/deviceLinks instead of bundling urls.json + marketplaces.json and matching them client-side.

The server now does all the classification (type / targets / regions), so the entire DeviceLinkMatcher heuristic — prefix/suffix parsing, the rak-strip, the marketplaces.json region map — is deleted. The client seeds from a bundled snapshot, refreshes from the network, and filters the cache, mirroring the existing DeviceHardwareRepository pattern.

Depends on (both merged): meshtastic/api#94 (the endpoint + hourly sync) and meshtastic/msh.to#3 (the Type/Targets model + lint ratchet).

How

Layer Change
core/model NetworkDeviceLink / NetworkDeviceLinksResponse DTOs + toDeviceLink(). DeviceLink drops originalUrl, adds targets. MshToLinks deleted.
core/network ApiService.getDeviceLinks() + DeviceLinksRemoteDataSource.
core/database device_link drops original_url, adds targets. DB v42 → v43 (AutoMigration42to43 @DeleteColumn original_url; targets auto-added, nullable).
core/data Rewrote DeviceLinkRepositoryImpl (seed-if-empty → single-flight TTL refresh). Deleted DeviceLinkMatcher + MshToLinksJsonDataSource; new DeviceLinksJsonDataSource seed loader.
assets urls.json + marketplaces.json → a single device_links.json snapshot of the API response.
flavors F-Droid + desktop stubs updated to the new datasource.

Filtering is now trivial: platformioTarget ∈ targets && region && vendor-first. The UI (DeviceLinksSection, directory) is unchanged — DeviceLink.isVendor / regions / url are preserved.

Behavior notes

  • Internal links (GitHub, YouTube, …) are now excluded from the Settings → Device Links directory. The API classifies these as internal and its schema explicitly says clients should exclude them from purchase UI. (Node-detail was already unaffected — internal links carry no targets.)
  • Node-detail stays non-blocking: getLinksForTarget never waits on the network; it serves cache and relies on reconcile() firing during the device-hardware refresh that resolves the node's hardware anyway.
  • F-Droid / desktop: no API call; they serve the bundled device_links.json snapshot, exactly as they do for device hardware.

Testing

./gradlew spotlessApply spotlessCheck detekt assembleDebug test allTests kmpSmokeCompile — all green (2,031 tests). Room generated + validated 43.json. DeviceLinkRepositoryImplTest rewritten for the network/seed flow.

Follow-up to #5714.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the refactor no functional changes label Jun 10, 2026
…cher

Replace the bundled urls.json + marketplaces.json and the client-side DeviceLinkMatcher heuristic with a fetch of the now-live /resource/deviceLinks endpoint, which returns fully-resolved links (type, targets, regions). The client seeds from a bundled snapshot, refreshes from the network, and filters the cache - mirroring the DeviceHardware repository pattern.

- core/model: NetworkDeviceLink DTOs; DeviceLink drops originalUrl, adds targets
- core/network: ApiService.getDeviceLinks() + DeviceLinksRemoteDataSource
- core/database: device_link drops original_url, adds targets; DB v42 -> v43
- core/data: rewrite DeviceLinkRepositoryImpl (seed -> single-flight refresh); delete DeviceLinkMatcher + the MshTo datasource/model
- assets: replace urls.json + marketplaces.json with a device_links.json snapshot

Internal links are excluded from the directory per the API contract ("clients exclude 'internal' from purchase UI"). F-Droid and desktop fall back to the bundled snapshot when the API is unavailable, as they do for device hardware.

Follow-up to #5714; depends on meshtastic/api#94 and meshtastic/msh.to#3 (both merged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jamesarich jamesarich force-pushed the jamesarich/device-links-api branch from 9c686a7 to 7683b91 Compare June 10, 2026 19:10
@jamesarich jamesarich merged commit f00943c into release/2.8.0 Jun 10, 2026
15 checks passed
@jamesarich jamesarich deleted the jamesarich/device-links-api branch June 10, 2026 21:25
jamesarich added a commit that referenced this pull request Jun 10, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 10, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 12, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 13, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 16, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 16, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jamesarich added a commit that referenced this pull request Jun 16, 2026
…cher (#5765)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jamesarich jamesarich mentioned this pull request Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor no functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant