Skip to content

refactor(sparql-importer): replace import result classes with discriminated union#212

Open
ddeboer wants to merge 2 commits intomainfrom
refactor/import-result-discriminated-union
Open

refactor(sparql-importer): replace import result classes with discriminated union#212
ddeboer wants to merge 2 commits intomainfrom
refactor/import-result-discriminated-union

Conversation

@ddeboer
Copy link
Member

@ddeboer ddeboer commented Mar 6, 2026

Summary

  • Replace ImportSuccessful, ImportFailed, and NotSupported classes in @lde/sparql-importer with interfaces carrying a type discriminant ('successful', 'failed', 'not-supported')
  • Add ImportResult union type as the return type for Importer.import()
  • Update @lde/sparql-qlever to return plain objects instead of class instances
  • Replace all instanceof checks with result.type === '...' comparisons in @lde/pipeline's ImportResolver and all tests
  • Change value imports to type-only imports where classes are no longer needed as values

This eliminates instanceof failures that occur when npm doesn't dedupe @lde/sparql-importer across packages — with a discriminated union there's no prototype chain to compare, so the check works regardless of how many copies of the package are installed.

ddeboer added 2 commits March 6, 2026 19:58
…inated union

- Replace ImportSuccessful, ImportFailed, NotSupported classes with
  interfaces carrying a `type` discriminant ('successful', 'failed',
  'not-supported')
- Add ImportResult union type for the Importer.import() return type
- Update sparql-qlever Importer to return plain objects instead of
  class instances
- Replace instanceof checks with type-property checks in pipeline's
  ImportResolver and all tests
- Change value imports to type-only imports where possible
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.

1 participant