LBDserver API
Documentation for the LBDserver project. Includes shared interfaces as well as functions for communicating with the LBDserver backend.
Installation
Install the package with NPM:
$ npm install lbd-server
Functions
-
register(username, email, password) ⇒
Promise.<returnUser>
-
Register as a user to the local LBDserver (backend defined in process.env.REACT_APP_BACKEND).
-
login(email, password) ⇒
Promise.<returnUser>
-
Login as an existing user to the LBDserver (backend defined in process.env.REACT_APP_BACKEND)
-
logout(token) ⇒
Promise.<void>
-
Log out on the LBDserver (backend defined in process.env.REACT_APP_BACKEND)
-
getOpenProjects() ⇒
Promise.<Array.<Project>>
-
Get all the documents accessible to unauthenticated users (public projects) on the local LBDserver (backend defined in process.env.REACT_APP_BACKEND)
-
getUserProjects(token) ⇒
Promise.<Array.<Project>>
-
Get all the projects associated with the currently authenticated user.
-
createProject(project, [token]) ⇒
Promise.<Project>
-
Create a new project on the local LBDserver
-
getOneProject(project, [token]) ⇒
Promise.<Project>
-
Get a project by its URL or ID. If an ID is given, the URL is reconstructed via the backend URL defined in process.env.REACT_APP_BACKEND.
-
deleteProject(project, [token]) ⇒
Promise.<void>
-
Delete a project by ID or URL. If an ID is provided; the URL is reconstructed based on the backend URL defined in process.env.REACT_APP_BACKEND.
-
deleteResource(url, [token]) ⇒
Promise.<void>
-
Delete a resource and its metadata graph.
-
uploadDocument(props, project, [token]) ⇒
Promise.<Metadata>
-
Upload a document to a defined project. Props include a "label", a "description" and a "resource", with the "resource" referring to the actual file to be uploaded. The "label" and "description" are used in the automatically created metadata file, which is equal to {fileurl}.meta.
-
getDocument(url, [token]) ⇒
Promise.<Buffer>
-
Get a (non RDF) document from the LBDserver by providing its URL. Authenticate with a token.
-
getDocumentMetadata(url, [token]) ⇒
Promise.<Metadata>
-
Get the metadata of a document resource on the lbdserver. The url of the document should be provided; either with .meta or without (if without; the ".meta" suffix is automatically added).
-
deleteDocument(url, [token]) ⇒
Promise.<void>
-
Erase a document (and its corresponding metadata graph) from existence.
-
uploadGraph(props, project, [token]) ⇒
Promise.<Metadata>
-
Upload an RDF graph to a defined project. Props include a "label", a "description" and a "resource", with the "resource" referring to the actual RDF graph to be uploaded. In the case no resource is passed, an empty graph gets created, using the label and description in the metadata, which is equal to {graphurl}.meta. A custom ACL graph or reference may be provided.
-
getGraph(url, [token]) ⇒
Promise.<Graph>
-
Get a graph by its URL. You can also request metadata graphs explicitly in with this function. However, you may also use the function "getGraphMetadata" for this purpose.
-
getGraphMetadata(url, [token]) ⇒
Promise.<Metadata>
-
Get the metadata graph of a given graph. You may either provide the ".meta" suffix or skip it.
-
deleteGraph(url, [token]) ⇒
Promise.<void>
-
Erase a project graph and its corresponding metadata graph from existence.
-
queryProjectSelect(project, query, [token]) ⇒
Promise.<QueryResults>
-
Query a project with SPARQL SELECT. Only the graphs to which the user has access will be queried.
-
queryMultiple(project, query, graphs, [token]) ⇒
Promise.<QueryResults>
-
Query multiple graphs with SPARQL SELECT.
-
queryGraphSelect(url, query, [token]) ⇒
QueryResults
-
Query a graph with SPARQL SELECT.
-
updateGraph(url, query, [token]) ⇒
Promise.<void>
-
Update a named graph in the project (SPARQL INSERT/DELETE). Be careful.
Typedefs
-
User :
Object
-
returnUser :
Object
-
Metadata :
Object
-
Project :
Object
- Resource
-
QueryResults :
Object
-
Graph :
Object
Promise.<returnUser>
register(username, email, password) ⇒ Register as a user to the local LBDserver (backend defined in process.env.REACT_APP_BACKEND).
Kind: global function
Returns: Promise.<returnUser>
- Returns a User object and a token.
Param | Type | Description |
---|---|---|
username | string |
Your username will be used to create a webID (personal URL) that can be used for access control in a Linked Data world. Should be unique. |
string |
Your e-mail address. Should be unique. | |
password | string |
Your LBDserver passsword. |
Promise.<returnUser>
login(email, password) ⇒ Login as an existing user to the LBDserver (backend defined in process.env.REACT_APP_BACKEND)
Kind: global function
Returns: Promise.<returnUser>
- Returns a User object and a token.
Param | Type | Description |
---|---|---|
string |
Your e-mail address. | |
password | string |
Your LBDserver password. |
Promise.<void>
logout(token) ⇒ Log out on the LBDserver (backend defined in process.env.REACT_APP_BACKEND)
Kind: global function
Param | Type | Description |
---|---|---|
token | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Array.<Project>>
getOpenProjects() ⇒ Get all the documents accessible to unauthenticated users (public projects) on the local LBDserver (backend defined in process.env.REACT_APP_BACKEND)
Promise.<Array.<Project>>
getUserProjects(token) ⇒ Get all the projects associated with the currently authenticated user.
Kind: global function
Param | Type | Description |
---|---|---|
token | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Project>
createProject(project, [token]) ⇒ Create a new project on the local LBDserver
Kind: global function
Param | Type | Description |
---|---|---|
project | Object.<string, any> |
The project object. |
project.title | string |
The title "name" of the project. It will be registered in the project metadata graph of the project as rdfs:label. |
project.description | string |
A small description of the project. It will be registered in the project metadata graph as rdfs:comment. |
project.open | boolean |
Whether the project should be visible for the broader public or only for the creator. This is registered within the default ACL file (which can be changed afterwards as well). |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Project>
getOneProject(project, [token]) ⇒ Get a project by its URL or ID. If an ID is given, the URL is reconstructed via the backend URL defined in process.env.REACT_APP_BACKEND.
Kind: global function
Param | Type | Description |
---|---|---|
project | string |
The URL or the ID of the project. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. Optional. |
Promise.<void>
deleteProject(project, [token]) ⇒ Delete a project by ID or URL. If an ID is provided; the URL is reconstructed based on the backend URL defined in process.env.REACT_APP_BACKEND.
Kind: global function
Param | Type | Description |
---|---|---|
project | string |
The URL or the ID of the project. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<void>
deleteResource(url, [token]) ⇒ Delete a resource and its metadata graph.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The url of the resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Metadata>
uploadDocument(props, project, [token]) ⇒ Upload a document to a defined project. Props include a "label", a "description" and a "resource", with the "resource" referring to the actual file to be uploaded. The "label" and "description" are used in the automatically created metadata file, which is equal to {fileurl}.meta.
Kind: global function
Param | Type | Description |
---|---|---|
props | Object.<string, any> |
The properties of the object to be uploaded. |
props.label | string |
A label for the resource. It will be registered in the metadata graph of the resource as rdfs:label. |
props.description | string |
A description for the resource. It will be registered in the metadata graph of the resource as rdfs:comment. |
props.file | Blob |
The file originating from a HTMLInputElement upload. Only one file at a time. |
[props.acl] |
string | Blob
|
An optional parameter to indicate the ACL graph for the resource. Can be a string pointing at the URL of an already existing ACL graph or a new ACL graph, uploaded via a HTMLInputElement. |
project | string |
The URL or the ID of the project. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Buffer>
getDocument(url, [token]) ⇒ Get a (non RDF) document from the LBDserver by providing its URL. Authenticate with a token.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the requested resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Metadata>
getDocumentMetadata(url, [token]) ⇒ Get the metadata of a document resource on the lbdserver. The url of the document should be provided; either with .meta or without (if without; the ".meta" suffix is automatically added).
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the requested resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<void>
deleteDocument(url, [token]) ⇒ Erase a document (and its corresponding metadata graph) from existence.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Metadata>
uploadGraph(props, project, [token]) ⇒ Upload an RDF graph to a defined project. Props include a "label", a "description" and a "resource", with the "resource" referring to the actual RDF graph to be uploaded. In the case no resource is passed, an empty graph gets created, using the label and description in the metadata, which is equal to {graphurl}.meta. A custom ACL graph or reference may be provided.
Kind: global function
Param | Type | Description |
---|---|---|
props | Object.<string, any> |
The properties of the object to be uploaded. |
props.label | string |
A label for the resource. It will be registered in the metadata graph of the resource as rdfs:label. |
props.description | string |
A description for the resource. It will be registered in the metadata graph of the resource as rdfs:comment. |
props.file | Blob |
The file originating from a HTMLInputElement upload. Only one file at a time. |
[props.acl] |
string | Blob
|
An optional parameter to indicate the ACL graph for the resource. Can be a string pointing at the URL of an already existing ACL graph or a new ACL graph, uploaded via a HTMLInputElement. |
project | string |
The URL or the ID of the project. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Graph>
getGraph(url, [token]) ⇒ Get a graph by its URL. You can also request metadata graphs explicitly in with this function. However, you may also use the function "getGraphMetadata" for this purpose.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the requested resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<Metadata>
getGraphMetadata(url, [token]) ⇒ Get the metadata graph of a given graph. You may either provide the ".meta" suffix or skip it.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the resource corresponding with the metadata graph or the URL of the metadata graph itself. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<void>
deleteGraph(url, [token]) ⇒ Erase a project graph and its corresponding metadata graph from existence.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The URL of the resource. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<QueryResults>
queryProjectSelect(project, query, [token]) ⇒ Query a project with SPARQL SELECT. Only the graphs to which the user has access will be queried.
Kind: global function
Param | Type | Description |
---|---|---|
project | string |
The URL or the ID of the project. |
query | string |
A SPARQL select query. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<QueryResults>
queryMultiple(project, query, graphs, [token]) ⇒ Query multiple graphs with SPARQL SELECT.
Kind: global function
Param | Type | Description |
---|---|---|
project | string |
The URL or the ID of the project. |
query | string |
A SPARQL select query. |
graphs | Array.<string> |
An array of the graphs that are to be included in the query. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
QueryResults
queryGraphSelect(url, query, [token]) ⇒ Query a graph with SPARQL SELECT.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The url of the graph to be queried. |
query | string |
A SPARQL select query. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Promise.<void>
updateGraph(url, query, [token]) ⇒ Update a named graph in the project (SPARQL INSERT/DELETE). Be careful.
Kind: global function
Param | Type | Description |
---|---|---|
url | string |
The url of the graph to be updated. |
query | string |
A SPARQL INSERT/DELETE query. |
[token] | string |
The access token you got from logging in. You don't need to pass the "Bearer" suffix - it is added within the function. |
Object
User : Kind: global typedef
Properties
Name | Type |
---|---|
username | string |
string |
|
projects | Array.<string> |
uri | string |
Object
returnUser : Kind: global typedef
Properties
Name | Type |
---|---|
user | User |
token | string |
Object
Metadata : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
uri | string |
URI of the document |
metadata | Object |
The metadata as JSON-LD. |
Object
Project : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
metadata | Object |
A JSON-LD object of the project metadata |
id | string |
The project id |
[uri] | string |
The project uri. Optional (only when creating a project => otherwise it is just the url of the request) |
graphs | Resource |
An object containing all the graphs in the project. The object key is the graph url, the value is its metadata as JSON-LD. |
documents | Resource |
An object containing all the documents in the project. The object key is the document url, the value is its metadata as JSON-LD. |
[results] | QueryResults |
the result of an eventual SPARQL SELECT query. Only if a query was sent along. |
Resource
Kind: global typedef
Properties
Name | Type |
---|---|
metadata | Object |
permissions | Array.<string> |
Object
QueryResults : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
head | Object |
|
head.vars | Array.<string> |
|
results | Object |
|
results.bindings | Array.<Object> |
links the variables to the results. |
Object
Graph : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
uri | string |
URI of the document |
metadata | Object |
The metadata as JSON-LD. |
data | Object |
The graph content as JSON-LD |