@faubulous/mentor-rdf
v1.3.1
Published
A library for working with RDF vocabularies with support for basic RDFS and OWL inference.
Downloads
564
Maintainers
Readme
Mentor RDF API
A TypeScript library for working with RDF vocabularies in Node.js and browsers. It powers the Mentor VS Code extension, providing structured access to ontologies through a repository pattern and lightweight structural reasoning.
Features
Repository Pattern
Access RDF resources through specialized repositories that provide type-safe, SPARQL-free querying:
- VocabularyRepository – Query ontologies and SKOS concept schemes
- ClassRepository – Retrieve OWL/RDFS classes with hierarchy traversal
- PropertyRepository – Access object, datatype, and annotation properties
- IndividualRepository – Query class instances and their properties
- ShapeRepository – Work with SHACL node and property shapes
Structural Reasoning
Built-in reasoners expand your RDF graphs with inferred triples:
- RdfsReasoner –
rdfs:subClassOf,rdfs:subPropertyOf, domain/range inference - OwlReasoner – OWL class expressions, property characteristics, equivalences
- SkosReasoner – SKOS concept hierarchies and semantic relations
- ShaclReasoner – SHACL shape target inference
RDF Store
An RDF.js-compatible triple store with:
- Multiple format support: Turtle, N3, N-Triples, N-Quads, TriG, RDF/XML
- Named graph management
- Bundled W3C ontologies (RDF, RDFS, OWL, SKOS, SHACL, XSD)
Installation
Works in Node.js (>=22) and modern browsers:
npm install @faubulous/mentor-rdfQuick Start
import { Store, VocabularyRepository, OwlReasoner } from '@faubulous/mentor-rdf';
const graph = 'http://example.org/test';
// Create a store with OWL reasoning
const store = new Store(new OwlReasoner());
// Load an ontology
await store.loadFromTurtleStream(turtleData, graph);
// Query using repositories
const repository = new VocabularyRepository(store);
// Get all classes defined in the ontology
for (const classUri of repository.getClasses(graph)) {
console.log(classUri);
}
// Get class hierarchy (includes inferred subclass relationships)
const subClasses = repository.getSubClasses(graph, 'http://example.org/MyClass');