4.0.2 • Published 1 month ago

@comunica/query-sparql-solid v4.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Comunica SPARQL Solid

npm version Docker Pulls

Comunica SPARQL Solid is a SPARQL query engine for JavaScript that can query over Solid data pods.

This package is safe to use in both Node.js and browser environments.

This module is part of the Comunica framework. Click here to learn more about Comunica and Solid.

Known issues

This library has the following known issues in certain cases, that are out of our control (but have been reported).

No issues are known with the Community Solid Server

Install

$ yarn add @comunica/query-sparql-solid

or

$ npm install -g @comunica/query-sparql-solid

Usage

Show 100 triples from a private resource by authenticating through the https://solidcommunity.net/ identity provider (when using https://pod.inrupt.com/, your IDP will be https://broker.pod.inrupt.com/):

$ comunica-sparql-solid --idp https://solidcommunity.net/ \
  http://example.org/private-resource.ttl \
  "SELECT * WHERE {
       ?s ?p ?o
   } LIMIT 100"

This command will connect with the given identity provider, and open your browser to log in with your WebID. After logging in, the query engine will be able to access all the documents you have access to.

Show the help with all options:

$ comunica-sparql-solid --help

Just like Comunica SPARQL, a dynamic variant (comunica-dynamic-sparql-solid) also exists.

Read more about querying from the command line.

Usage within application

This engine can be used in JavaScript/TypeScript applications as follows:

const QueryEngine = require('@comunica/query-sparql-solid').QueryEngine;
const { interactiveLogin } = require('solid-node-interactive-auth');

// This will open your Web browser to log in
const session = await interactiveLogin({ oidcIssuer: 'https://solidcommunity.net/' });
const myEngine = new QueryEngine();

const bindingsStream = await myEngine.queryBindings(`
  SELECT * WHERE {
      ?s ?p ?o
  } LIMIT 100`, {
  sources: [session.info.webId], // Sets your profile as query source
  '@comunica/actor-http-inrupt-solid-client-authn:session': session,
});

// Consume results as a stream (best performance)
bindingsStream.on('data', (binding) => {
  console.log(binding.toString()); // Quick way to print bindings for testing

  console.log(binding.has('s')); // Will be true

  // Obtaining values
  console.log(binding.get('s').value);
  console.log(binding.get('s').termType);
  console.log(binding.get('p').value);
  console.log(binding.get('o').value);
});
bindingsStream.on('end', () => {
  // The data-listener will not be called anymore once we get here.
});
bindingsStream.on('error', (error) => {
  console.error(error);
});

// Consume results as an array (easier)
const bindings = await bindingsStream.toArray();
console.log(bindings[0].get('s').value);
console.log(bindings[0].get('s').termType);

Note that solid-node-interactive-auth only works within Node.js apps. Please refer to @inrupt/solid-client-authn-browser if yoyou want to login via a browser app.

Read more about querying an application.

Usage as a SPARQL endpoint

Start a webservice exposing a private resource via the SPARQL protocol, i.e., a SPARQL endpoint, by authenticating through the https://solidcommunity.net/ identity provider.

$ comunica-sparql-solid-http --idp https://solidcommunity.net/ \
  http://example.org/private-resource.ttl

Show the help with all options:

$ comunica-sparql-solid-http --help

The SPARQL endpoint can only be started dynamically. An alternative config file can be passed via the COMUNICA_CONFIG environment variable.

Use bin/http.js when running in the Comunica monorepo development environment.

Read more about setting up a SPARQL endpoint.

@comunica/actor-bindings-aggregator-factory-average@comunica/actor-bindings-aggregator-factory-count@comunica/actor-bindings-aggregator-factory-group-concat@comunica/actor-bindings-aggregator-factory-max@comunica/actor-bindings-aggregator-factory-min@comunica/actor-bindings-aggregator-factory-sample@comunica/actor-bindings-aggregator-factory-sum@comunica/actor-bindings-aggregator-factory-wildcard-count@comunica/actor-context-preprocess-convert-shortcuts@comunica/actor-context-preprocess-query-source-identify@comunica/actor-context-preprocess-query-source-skolemize@comunica/actor-context-preprocess-set-defaults@comunica/actor-context-preprocess-source-to-destination@comunica/actor-dereference-fallback@comunica/actor-dereference-http@comunica/actor-dereference-rdf-parse@comunica/actor-expression-evaluator-factory-default@comunica/actor-function-factory-expression-bnode@comunica/actor-function-factory-expression-bound@comunica/actor-function-factory-expression-coalesce@comunica/actor-function-factory-expression-concat@comunica/actor-function-factory-expression-extensions@comunica/actor-function-factory-expression-if@comunica/actor-function-factory-expression-in@comunica/actor-function-factory-expression-logical-and@comunica/actor-function-factory-expression-logical-or@comunica/actor-function-factory-expression-not-in@comunica/actor-function-factory-expression-same-term@comunica/actor-function-factory-term-abs@comunica/actor-function-factory-term-addition@comunica/actor-function-factory-term-ceil@comunica/actor-function-factory-term-contains@comunica/actor-function-factory-term-datatype@comunica/actor-function-factory-term-day@comunica/actor-function-factory-term-division@comunica/actor-function-factory-term-encode-for-uri@comunica/actor-function-factory-term-equality@comunica/actor-function-factory-term-floor@comunica/actor-function-factory-term-greater-than@comunica/actor-function-factory-term-greater-than-equal@comunica/actor-function-factory-term-hours@comunica/actor-function-factory-term-inequality@comunica/actor-function-factory-term-iri@comunica/actor-function-factory-term-is-blank@comunica/actor-function-factory-term-is-iri@comunica/actor-function-factory-term-is-literal@comunica/actor-function-factory-term-is-numeric@comunica/actor-function-factory-term-is-triple@comunica/actor-function-factory-term-lang@comunica/actor-function-factory-term-langmatches@comunica/actor-function-factory-term-lcase@comunica/actor-function-factory-term-lesser-than@comunica/actor-function-factory-term-lesser-than-equal@comunica/actor-function-factory-term-md5@comunica/actor-function-factory-term-minutes@comunica/actor-function-factory-term-month@comunica/actor-function-factory-term-multiplication@comunica/actor-function-factory-term-not@comunica/actor-function-factory-term-now@comunica/actor-function-factory-term-object@comunica/actor-function-factory-term-predicate@comunica/actor-function-factory-term-rand@comunica/actor-function-factory-term-regex@comunica/actor-function-factory-term-replace@comunica/actor-function-factory-term-round@comunica/actor-function-factory-term-seconds@comunica/actor-function-factory-term-sha1@comunica/actor-function-factory-term-sha256@comunica/actor-function-factory-term-sha384@comunica/actor-function-factory-term-sha512@comunica/actor-function-factory-term-str@comunica/actor-function-factory-term-str-after@comunica/actor-function-factory-term-str-before@comunica/actor-function-factory-term-str-dt@comunica/actor-function-factory-term-str-ends@comunica/actor-function-factory-term-str-lang@comunica/actor-function-factory-term-str-len@comunica/actor-function-factory-term-str-starts@comunica/actor-function-factory-term-str-uuid@comunica/actor-function-factory-term-sub-str@comunica/actor-function-factory-term-subject@comunica/actor-function-factory-term-subtraction@comunica/actor-function-factory-term-timezone@comunica/actor-function-factory-term-triple@comunica/actor-function-factory-term-tz@comunica/actor-function-factory-term-ucase@comunica/actor-function-factory-term-unary-minus@comunica/actor-function-factory-term-unary-plus@comunica/actor-function-factory-term-uuid@comunica/actor-function-factory-term-xsd-to-boolean@comunica/actor-function-factory-term-xsd-to-date@comunica/actor-function-factory-term-xsd-to-datetime@comunica/actor-function-factory-term-xsd-to-day-time-duration@comunica/actor-function-factory-term-xsd-to-decimal@comunica/actor-function-factory-term-xsd-to-double@comunica/actor-function-factory-term-xsd-to-duration@comunica/actor-function-factory-term-xsd-to-float@comunica/actor-function-factory-term-xsd-to-integer@comunica/actor-function-factory-term-xsd-to-string@comunica/actor-function-factory-term-xsd-to-time@comunica/actor-function-factory-term-xsd-to-year-month-duration@comunica/actor-function-factory-term-year@comunica/actor-hash-bindings-murmur@comunica/actor-hash-quads-murmur@comunica/actor-http-fetch@comunica/actor-http-inrupt-solid-client-authn@comunica/actor-http-proxy@comunica/actor-http-retry@comunica/actor-http-wayback@comunica/actor-init-query@comunica/actor-optimize-query-operation-assign-sources-exhaustive@comunica/actor-optimize-query-operation-bgp-to-join@comunica/actor-optimize-query-operation-construct-distinct@comunica/actor-optimize-query-operation-describe-to-constructs-subject@comunica/actor-optimize-query-operation-filter-pushdown@comunica/actor-optimize-query-operation-group-sources@comunica/actor-optimize-query-operation-join-bgp@comunica/actor-optimize-query-operation-join-connected@comunica/actor-optimize-query-operation-prune-empty-source-operations@comunica/actor-optimize-query-operation-rewrite-add@comunica/actor-optimize-query-operation-rewrite-copy@comunica/actor-optimize-query-operation-rewrite-move@comunica/actor-query-operation-ask@comunica/actor-query-operation-bgp-join@comunica/actor-query-operation-construct@comunica/actor-query-operation-distinct-hash@comunica/actor-query-operation-extend@comunica/actor-query-operation-filter@comunica/actor-query-operation-from-quad@comunica/actor-query-operation-group@comunica/actor-query-operation-join@comunica/actor-query-operation-leftjoin@comunica/actor-query-operation-minus@comunica/actor-query-operation-nop@comunica/actor-query-operation-orderby@comunica/actor-query-operation-path-alt@comunica/actor-query-operation-path-inv@comunica/actor-query-operation-path-link@comunica/actor-query-operation-path-nps@comunica/actor-query-operation-path-one-or-more@comunica/actor-query-operation-path-seq@comunica/actor-query-operation-path-zero-or-more@comunica/actor-query-operation-path-zero-or-one@comunica/actor-query-operation-project@comunica/actor-query-operation-reduced-hash@comunica/actor-query-operation-service@comunica/actor-query-operation-slice@comunica/actor-query-operation-source@comunica/actor-query-operation-union@comunica/actor-query-operation-update-clear@comunica/actor-query-operation-update-compositeupdate@comunica/actor-query-operation-update-create@comunica/actor-query-operation-update-deleteinsert@comunica/actor-query-operation-update-drop@comunica/actor-query-operation-update-load@comunica/actor-query-operation-values@comunica/actor-query-parse-graphql@comunica/actor-query-parse-sparql@comunica/actor-query-process-explain-logical@comunica/actor-query-process-explain-parsed@comunica/actor-query-process-explain-physical@comunica/actor-query-process-sequential@comunica/actor-query-result-serialize-json@comunica/actor-query-result-serialize-rdf@comunica/actor-query-result-serialize-simple@comunica/actor-query-result-serialize-sparql-csv@comunica/actor-query-result-serialize-sparql-json@comunica/actor-query-result-serialize-sparql-tsv@comunica/actor-query-result-serialize-sparql-xml@comunica/actor-query-result-serialize-stats@comunica/actor-query-result-serialize-table@comunica/actor-query-result-serialize-tree@comunica/actor-query-source-identify-hypermedia@comunica/actor-query-source-identify-hypermedia-none@comunica/actor-query-source-identify-hypermedia-qpf@comunica/actor-query-source-identify-hypermedia-sparql@comunica/actor-query-source-identify-rdfjs@comunica/actor-query-source-identify-serialized@comunica/actor-rdf-join-entries-sort-cardinality@comunica/actor-rdf-join-inner-hash@comunica/actor-rdf-join-inner-multi-bind@comunica/actor-rdf-join-inner-multi-bind-source@comunica/actor-rdf-join-inner-multi-empty@comunica/actor-rdf-join-inner-multi-smallest@comunica/actor-rdf-join-inner-multi-smallest-filter-bindings@comunica/actor-rdf-join-inner-nestedloop@comunica/actor-rdf-join-inner-none@comunica/actor-rdf-join-inner-single@comunica/actor-rdf-join-inner-symmetrichash@comunica/actor-rdf-join-minus-hash@comunica/actor-rdf-join-optional-bind@comunica/actor-rdf-join-optional-hash@comunica/actor-rdf-join-optional-nestedloop@comunica/actor-rdf-join-selectivity-variable-counting@comunica/actor-rdf-metadata-accumulate-cardinality@comunica/actor-rdf-metadata-accumulate-pagesize@comunica/actor-rdf-metadata-accumulate-requesttime@comunica/actor-rdf-metadata-all@comunica/actor-rdf-metadata-extract-allow-http-methods@comunica/actor-rdf-metadata-extract-hydra-controls@comunica/actor-rdf-metadata-extract-hydra-count@comunica/actor-rdf-metadata-extract-hydra-pagesize@comunica/actor-rdf-metadata-extract-patch-sparql-update@comunica/actor-rdf-metadata-extract-put-accepted@comunica/actor-rdf-metadata-extract-request-time@comunica/actor-rdf-metadata-extract-sparql-service@comunica/actor-rdf-metadata-primary-topic@comunica/actor-rdf-parse-html@comunica/actor-rdf-parse-html-microdata@comunica/actor-rdf-parse-html-rdfa@comunica/actor-rdf-parse-html-script@comunica/actor-rdf-parse-jsonld@comunica/actor-rdf-parse-n3@comunica/actor-rdf-parse-rdfxml@comunica/actor-rdf-parse-shaclc@comunica/actor-rdf-parse-xml-rdfa@comunica/actor-rdf-resolve-hypermedia-links-next@comunica/actor-rdf-resolve-hypermedia-links-queue-fifo@comunica/actor-rdf-serialize-jsonld@comunica/actor-rdf-serialize-n3@comunica/actor-rdf-serialize-shaclc@comunica/actor-rdf-update-hypermedia-patch-sparql-update@comunica/actor-rdf-update-hypermedia-put-ldp@comunica/actor-rdf-update-hypermedia-sparql@comunica/actor-rdf-update-quads-hypermedia@comunica/actor-rdf-update-quads-rdfjs-store@comunica/actor-term-comparator-factory-expression-evaluator@comunica/bus-function-factory@comunica/bus-http-invalidate@comunica/bus-query-operation@comunica/config-query-sparql@comunica/config-query-sparql-solid@comunica/context-entries@comunica/core@comunica/logger-void@comunica/mediator-all@comunica/mediator-combine-pipeline@comunica/mediator-combine-union@comunica/mediator-join-coefficients-fixed@comunica/mediator-number@comunica/mediator-race@comunica/runner@comunica/runner-cli@comunica/types@rubensworks/solid-client-authn-isomorphicsolid-node-interactive-authyargs
4.0.1

1 month ago

4.0.2

1 month ago

4.0.1-alpha.6.0

2 months ago

3.1.1

4 months ago

3.1.0

7 months ago

3.0.1

8 months ago

3.0.1-alpha.5.0

9 months ago

3.0.1-alpha.4.0

9 months ago

3.0.1-alpha.3.0

9 months ago

2.4.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.1

3 years ago

2.0.1-alpha.2.0

3 years ago

2.0.1-alpha.1.0

3 years ago