Merged
Conversation
…zer with tests Co-authored-by: luandev <6452989+luandev@users.noreply.github.com>
Co-authored-by: luandev <6452989+luandev@users.noreply.github.com>
Co-authored-by: luandev <6452989+luandev@users.noreply.github.com>
… checks Co-authored-by: luandev <6452989+luandev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Wikidata SPARQL metadata provider implementation
Add Wikidata SPARQL metadata provider
Jan 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a free, API-key-less metadata provider using Wikidata's SPARQL endpoint. The implementation follows a clean architecture with comprehensive test coverage (66 tests), intelligent name normalization, result ranking with platform boost, and aggressive caching (21-day TTL).
Key Changes:
- New metadata provider system with generic interfaces for supporting multiple metadata sources
- Wikidata-specific SPARQL client with rate limiting (1 req/sec default)
- Intelligent game name normalization and result ranking
- Database tables for dual-layer caching (search and individual game lookups)
- Comprehensive test suite covering all modules
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/metadata-types.ts | Generic MetadataProvider interface and GameMetadata type for cross-provider compatibility |
| packages/shared/src/wikidata-types.ts | Wikidata-specific types for SPARQL responses and result ranking |
| packages/shared/src/index.ts | Export new metadata and Wikidata types |
| apps/server/src/providers/wikidata/queryBuilder.ts | SPARQL query templates for search and QID lookup with proper escaping |
| apps/server/src/providers/wikidata/client.ts | HTTP client with rate limiting and health check functionality |
| apps/server/src/providers/wikidata/mapper.ts | Transforms SPARQL JSON responses to structured GameMetadata |
| apps/server/src/providers/wikidata/normalizer.ts | ROM name normalization and result ranking with platform matching |
| apps/server/src/providers/wikidata/provider.ts | Main provider implementation with dual-layer caching |
| apps/server/src/providers/wikidata/index.ts | Module exports for clean API surface |
| apps/server/src/providers/wikidata/README.md | Comprehensive documentation with examples and architecture details |
| apps/server/src/providers/wikidata/tests/*.test.ts | 66 tests across 5 test files covering all functionality |
| apps/server/src/db.ts | Added wikidata_cache_search and wikidata_cache_game tables with get/set functions |
| vi.mock("../client"); | ||
| vi.mock("../../../db"); | ||
|
|
||
| import { WikidataClient } from "../client"; |
There was a problem hiding this comment.
Unused import WikidataClient.
Suggested change
| import { WikidataClient } from "../client"; |
…gation - Renamed `mapSparqlResultToGame` to `mapSparqlResultToPartialGame` for clarity, indicating it returns a partial result. - Changed mapping logic to handle single values for platforms, genres, and publishers instead of pipe-separated strings. - Introduced a new `mapSparqlResultToGame` function for backward compatibility, which aggregates results from the partial mapping. - Optimized SPARQL queries by removing `GROUP_CONCAT` and simplifying label retrieval, enhancing performance and reducing timeout issues. - Updated aggregation logic in `aggregateSparqlResults` to utilize Sets for unique values and ensure proper handling of optional fields.
… unit tests - Introduced integration tests for the WikidataProvider to validate end-to-end functionality with real API calls. - Updated unit tests to reflect changes in data structure, including the aggregation of results and the use of new field names (e.g., platformLabel, genreLabel). - Enhanced test cases to ensure proper handling of optional fields and improved assertions for aggregated results. - Adjusted SPARQL query builder tests to account for changes in query limits and filtering mechanisms.
… web projects - Added explicit names for the node-tests and web-tests in the Vitest configuration for better clarity and organization. - Added a blank line at the end of the integration test file for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implementation
Core Provider (
apps/server/src/providers/wikidata/)Type System (
packages/shared/src/)Database (
apps/server/src/db.ts)wikidata_cache_searchandwikidata_cache_gametablesUsage
Testing
Checklist
/semver: patch,/semver: minor, or/semver: major. (See template for examples)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.