@comunica/query-sparql-file 2.0.1-alpha.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +22 -0
- package/README.md +105 -0
- package/bin/http.d.ts +2 -0
- package/bin/http.js +8 -0
- package/bin/query-dynamic.d.ts +2 -0
- package/bin/query-dynamic.js +6 -0
- package/bin/query.d.ts +2 -0
- package/bin/query.js +6 -0
- package/config/config-browser.json +8 -0
- package/config/config-default.json +8 -0
- package/engine-browser.js +951 -0
- package/engine-default.js +956 -0
- package/lib/QueryEngine.d.ts +8 -0
- package/lib/QueryEngine.js +15 -0
- package/lib/QueryEngineFactory.d.ts +8 -0
- package/lib/QueryEngineFactory.js +15 -0
- package/lib/index-browser.d.ts +1 -0
- package/lib/index-browser.js +16 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +15 -0
- package/package.json +180 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Comunica SPARQL File
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/query-sparql-file)
|
|
4
|
+
|
|
5
|
+
Comunica SPARQL is a SPARQL query engine for JavaScript for querying local and remote RDF files.
|
|
6
|
+
|
|
7
|
+
This module is part of the [Comunica framework](https://comunica.dev/).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ yarn global add @comunica/query-sparql-file
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ npm install -g @comunica/query-sparql-file
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage from the command line
|
|
22
|
+
|
|
23
|
+
Show 100 triples from a remote FOAF profile:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
$ comunica-sparql-file https://ruben.verborgh.org/profile/#me "CONSTRUCT WHERE { ?s ?p ?o } LIMIT 100"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Show 100 triples from a local RDF file:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ comunica-sparql-file path/to/my/file.ttl "CONSTRUCT WHERE { ?s ?p ?o } LIMIT 100"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Show all triples from a local and remote file:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
$ comunica-sparql-file path/to/my/file.ttl https://ruben.verborgh.org/profile/#me "CONSTRUCT WHERE { ?s ?p ?o } LIMIT 100"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Show the help with all options:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
$ comunica-sparql-file --help
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Just like [Comunica SPARQL](https://github.com/comunica/comunica/tree/master/packages/query-sparql),
|
|
48
|
+
a [dynamic variant](https://github.com/comunica/comunica/tree/master/packages/query-sparql#usage-from-the-command-line) (`comunica-dynamic-sparql-file`) also exists.
|
|
49
|
+
|
|
50
|
+
_[**Read more** about querying from the command line](https://comunica.dev/docs/query/getting_started/query_cli_file/)._
|
|
51
|
+
|
|
52
|
+
### Usage within application
|
|
53
|
+
|
|
54
|
+
This engine can be used in JavaScript/TypeScript applications as follows:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const newEngine = require('@comunica/query-sparql-file').newEngine;
|
|
58
|
+
const myEngine = newEngine();
|
|
59
|
+
|
|
60
|
+
const result = await myEngine.query(`
|
|
61
|
+
SELECT ?s ?p ?o WHERE {
|
|
62
|
+
?s ?p <http://dbpedia.org/resource/Belgium>.
|
|
63
|
+
?s ?p ?o
|
|
64
|
+
} LIMIT 100`, {
|
|
65
|
+
sources: ['http://fragments.dbpedia.org/2015/en'],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Consume results as a stream (best performance)
|
|
69
|
+
result.bindingsStream.on('data', (binding) => {
|
|
70
|
+
console.log(binding.get('?s').value);
|
|
71
|
+
console.log(binding.get('?s').termType);
|
|
72
|
+
|
|
73
|
+
console.log(binding.get('?p').value);
|
|
74
|
+
|
|
75
|
+
console.log(binding.get('?o').value);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Consume results as an array (easier)
|
|
79
|
+
const bindings = await result.bindings();
|
|
80
|
+
console.log(bindings[0].get('?s').value);
|
|
81
|
+
console.log(bindings[0].get('?s').termType);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
_[**Read more** about querying an application](https://comunica.dev/docs/query/getting_started/query_app/)._
|
|
85
|
+
|
|
86
|
+
### Usage as a SPARQL endpoint
|
|
87
|
+
|
|
88
|
+
Start a webservice exposing http://fragments.dbpedia.org/2015-10/en via the SPARQL protocol, i.e., a _SPARQL endpoint_.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
$ comunica-sparql-file-http "{ \"sources\": [\"/path/to/my/file.ttl\"]}"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Show the help with all options:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
$ comunica-sparql-file-http --help
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The SPARQL endpoint can only be started dynamically.
|
|
101
|
+
An alternative config file can be passed via the `COMUNICA_CONFIG` environment variable.
|
|
102
|
+
|
|
103
|
+
Use `bin/http.js` when running in the Comunica monorepo development environment.
|
|
104
|
+
|
|
105
|
+
_[**Read more** about setting up a SPARQL endpoint](https://comunica.dev/docs/query/getting_started/setup_endpoint/)._
|
package/bin/http.d.ts
ADDED
package/bin/http.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const actor_init_query_1 = require("@comunica/actor-init-query");
|
|
5
|
+
const defaultConfigPath = `${__dirname}/../config/config-default.json`;
|
|
6
|
+
actor_init_query_1.HttpServiceSparqlEndpoint.runArgsInProcess(process.argv.slice(2), process.stdout, process.stderr, `${__dirname}/../`, process.env, defaultConfigPath, code => process.exit(code))
|
|
7
|
+
.catch(error => process.stderr.write(`${error.message}/n`));
|
|
8
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const runner_cli_1 = require("@comunica/runner-cli");
|
|
5
|
+
(0, runner_cli_1.runArgsInProcess)(`${__dirname}/../`, `${__dirname}/../config/config-default.json`);
|
|
6
|
+
//# sourceMappingURL=query-dynamic.js.map
|
package/bin/query.d.ts
ADDED
package/bin/query.js
ADDED