Necessarily Precedes Mischief
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@agentlab/sparql-jsld-client

4.1.4 • Public • Published

SPARQL JSON Schema Linked Data Client

It is an intelligent SPARQL Client with SHACL Shapes support. You could use JSON objects and JSON Schemas to query SPARQL Endpoint, semi-similar to GraphQL style.

Some core features requires:

  • RDF4J REST API in addition to standard SPARQL 1.1 Query and SPARQL 1.1 Update.
  • SHACL Shapes for rdfs classes in server RDF repository.

Features

  • Retrieves lazily SPARQL Prefixes (namespaces) from server (requires RDF4J REST API)
  • Retrieves lazily SHACL Shapes from server, converts it into JSON Schems and UI Schems and caches them
  • Uses JS objects and JSON Schemas (converted from shapes) to generate SPARQL Select Queries and SPARQL Update queries
  • Converts SPARQL Results into JS objects for consumption in apps
  • Have API server RDF repository creation and deletion (requires RDF4J REST API)
  • Supports bulk-load data from local files to server RDF repository (requires RDF4J REST API)

Usage

const provider = new ObjectProviderImpl();
provider.setUser('users:guest');
const client = provider.getClient();
client.setServerUrl('<url to ref4j rest api server>');
await client.createRepositoryAndSetCurrent( {'Repository ID': 'myrepo'} );
await client.uploadFiles(files, rootFolder);
 
//select all objects by schema (by rdfs class)
const artifacts = await provider.selectObjects('rm:Artifact');
 
//select all objects by schema (by rdfs class) with explisit schema object
const artifactSchema = await provider.getSchemaByUri('rm:Artifact');
const artifacts2 = await provider.selectObjects(artifactSchema);
 
//select all objects by schema and conditions
const artifact30000 = await provider.selectObjectsWithTypeInfo(artifactSchema, { identifier: 30000 });
const artifactsFromFolder = await provider.selectObjects(artifactSchema, { assetFolder: 'folders:samples_module' });

Local Development

This project was bootstrapped with TSDX.

For single test run

npm test -- -t "should select namespaces"

For single testsuite run

npm test SparqlClient.spec.ts

License

Install

npm i @agentlab/sparql-jsld-client

DownloadsWeekly Downloads

17

Version

4.1.4

License

EPL

Unpacked Size

1.45 MB

Total Files

48

Last publish

Collaborators

  • avatar