Skip to content

Commit 8db60d8

Browse files
[VET-1703] Data source description endpoint (#278)
* [VET-1703] Add data source description endpoint * [VET-1703] Update docs
1 parent ebd5967 commit 8db60d8

3 files changed

Lines changed: 66 additions & 25 deletions

File tree

README.md

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ To get started, just clone the project. You'll need a local copy of Stardog to b
3737
Go to [http://stardog.com](http://stardog.com), download and install the database and load the data provided in `data/` using the script in the repository.
3838

3939
1. Start the Stardog server
40+
4041
```bash
4142
stardog-admin server start
4243
```
44+
4345
2. Install `stardog.js` dependencies:
46+
4447
```bash
4548
npm install
4649
```
@@ -81,19 +84,20 @@ After releasing, be sure to push to master, including the tags (so that the rele
8184

8285
Each release of stardog.js is tested against the most recent version of Stardog available at the time of the release. The relationship between versions of stardog.js and versions of Stardog is detailed in the following table:
8386

84-
| stardog.js Version | Supported Stardog Version(s) |
85-
| ------------------ | ---------------------------- |
86-
| 4.x.x | 8.x.x |
87-
| 3.x.x | 7.x.x |
88-
| 2.x.x* | 6.x.x |
89-
| 1.x.x* | 5.x.x |
90-
| 0.x.x* | any version < 5 |
87+
| stardog.js Version | Supported Stardog Version(s) |
88+
| ------------------ | ---------------------------- |
89+
| 4.x.x | 8.x.x |
90+
| 3.x.x | 7.x.x |
91+
| 2.x.x\* | 6.x.x |
92+
| 1.x.x\* | 5.x.x |
93+
| 0.x.x\* | any version < 5 |
9194

92-
_* = No longer supported_
95+
_\* = No longer supported_
9396

9497
We support and maintain a particular version of stardog.js only if the corresponding Stardog version(s) is (are) officially supported and maintained. For example, we no longer support v0.x.x of stardog.js, as the corresponding Stardog versions are no longer supported. (That said, later versions of stardog.js will often _mostly_ work with earlier Stardog versions. We just don't test this or make any guarantees to that effect.)
9598

9699
## Quick Example
100+
97101
```js
98102
const { Connection, query } = require('stardog');
99103

@@ -103,13 +107,21 @@ const conn = new Connection({
103107
endpoint: 'http://localhost:5820',
104108
});
105109

106-
query.execute(conn, 'myDatabaseName', 'select distinct ?s where { ?s ?p ?o }', 'application/sparql-results+json', {
107-
limit: 10,
108-
reasoning: true,
109-
offset: 0,
110-
}).then(({ body }) => {
111-
console.log(body.results.bindings);
112-
});
110+
query
111+
.execute(
112+
conn,
113+
'myDatabaseName',
114+
'select distinct ?s where { ?s ?p ?o }',
115+
'application/sparql-results+json',
116+
{
117+
limit: 10,
118+
reasoning: true,
119+
offset: 0,
120+
}
121+
)
122+
.then(({ body }) => {
123+
console.log(body.results.bindings);
124+
});
113125
```
114126

115127
<!--- API Goes Here --->
@@ -2217,3 +2229,13 @@ Expects the following parameters:
22172229

22182230
Returns [`Promise<HTTP.Body>`](#body)
22192231

2232+
#### <a name="typedescription">`dataSources.typeDescription(conn)`</a>
2233+
2234+
Get information about the data source types supported by the stardog instance, and their options
2235+
2236+
Expects the following parameters:
2237+
2238+
- conn ([`Connection`](#connection))
2239+
2240+
Returns [`Promise<HTTP.Body>`](#body)
2241+

lib/dataSources.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,32 @@ const suggestions = (conn, content, opts = {}) => {
179179
}).then(httpBody);
180180
};
181181

182+
const typeDescription = conn => {
183+
const headers = conn.headers();
184+
return fetch(
185+
conn.request('admin', 'data_sources', 'data_source_type_description'),
186+
{
187+
headers,
188+
}
189+
).then(httpBody);
190+
};
191+
182192
module.exports = {
193+
add,
183194
available,
184-
query,
185-
refreshCounts,
195+
getMetadata,
196+
info,
197+
list,
186198
listInfo,
187-
update,
188-
remove,
189199
online,
190-
info,
200+
options,
201+
query,
202+
refreshCounts,
191203
refreshMetadata,
204+
remove,
192205
share,
193-
list,
194-
add,
195-
options,
196206
suggestions,
197-
198-
getMetadata,
207+
typeDescription,
208+
update,
199209
updateMetadata,
200210
};

lib/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,15 @@ declare namespace Stardog {
14221422
content: string,
14231423
options?: { accept?: string; contentType?: string }
14241424
): Promise<HTTP.Body>;
1425+
1426+
/**
1427+
* Get information about the data source types supported by the stardog instance, and their options
1428+
*
1429+
* @param {Connection} conn the Stardog server connection
1430+
*/
1431+
function typeDescription(
1432+
conn: Connection,
1433+
): Promise<HTTP.Body>;
14251434
}
14261435
}
14271436

0 commit comments

Comments
 (0)