A StorageService implementation that persists RDF graphs in Apache Jena Fuseki. Each resource is stored as a named graph in a Fuseki dataset, accessed through the SPARQL 1.1 Graph Store Protocol and SPARQL query endpoints.
- Node.js >= 22.11.0
- Apache Jena Fuseki running with a configured dataset. For example:
# In-memory (non-persistent):
fuseki-server --mem /ldp
# Persistent with update support:
fuseki-server --update --loc=<path-to-db> /ldpnpm install
npm run buildThe TypeScript source in src/ compiles to dist/.
JenaStorageService is initialized with a StorageEnv object that must include a jenaURL property pointing to the Fuseki dataset endpoint. For example:
{
"jenaURL": "http://localhost:3030/ldp/"
}The URL should include the trailing slash and the dataset name. Fuseki service endpoints (data, sparql, update) are resolved relative to this base URL.
JenaStorageService implements the StorageService interface from the storage-service package, providing:
- CRUD on named graphs --
read,update,remove,reserveURI, andreleaseURIuse the Fuseki Graph Store Protocol (dataendpoint) to manage individual RDF graphs identified by URI. - Partial graph updates --
insertDataandremoveDataissue SPARQL Update requests to add or delete triples within a named graph. - SPARQL queries --
constructQueryreturns parsed RDF results;sparqlQueryreturns raw results in a requested media type;getMembershipTriplesresolves LDP Direct Container membership. - Dataset export/import --
exportDatasetandimportDatasetsupport TriG (named graphs) and Turtle (single-graph) serialization for backup and migration.
RDF parsing and serialization are handled by rdflib.
This module implements the StorageService interface defined in storage-service. It is consumed by ldp-service, which provides LDP protocol handling as Express middleware. The separation allows ldp-service to remain storage-agnostic -- swapping jena-storage-service for another StorageService implementation changes the persistence backend without affecting the LDP logic.
ldp-service ---> StorageService (interface) <--- jena-storage-service (this module)
<--- storage-service (other impls)
Licensed under the Apache License, Version 2.0. See LICENSE for details.