lbd-server
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

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

register(username, email, password) ⇒ Promise.<returnUser>

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.
email string Your e-mail address. Should be unique.
password string Your LBDserver passsword.

login(email, password) ⇒ Promise.<returnUser>

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
email string Your e-mail address.
password string Your LBDserver password.

logout(token) ⇒ Promise.<void>

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.

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)

Kind: global function

getUserProjects(token) ⇒ Promise.<Array.<Project>>

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.

createProject(project, [token]) ⇒ Promise.<Project>

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.

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.

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.

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.

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.

deleteResource(url, [token]) ⇒ Promise.<void>

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.

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.

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.

getDocument(url, [token]) ⇒ Promise.<Buffer>

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.

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).

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.

deleteDocument(url, [token]) ⇒ Promise.<void>

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.

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.

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.

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.

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.

getGraphMetadata(url, [token]) ⇒ Promise.<Metadata>

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.

deleteGraph(url, [token]) ⇒ Promise.<void>

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.

queryProjectSelect(project, query, [token]) ⇒ Promise.<QueryResults>

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.

queryMultiple(project, query, graphs, [token]) ⇒ Promise.<QueryResults>

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.

queryGraphSelect(url, query, [token]) ⇒ QueryResults

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.

updateGraph(url, query, [token]) ⇒ Promise.<void>

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.

User : Object

Kind: global typedef
Properties

Name Type
username string
email string
projects Array.<string>
uri string

returnUser : Object

Kind: global typedef
Properties

Name Type
user User
token string

Metadata : Object

Kind: global typedef
Properties

Name Type Description
uri string URI of the document
metadata Object The metadata as JSON-LD.

Project : Object

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>

QueryResults : Object

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.

Graph : Object

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

Readme

Keywords

Package Sidebar

Install

npm i lbd-server

Weekly Downloads

1

Version

0.1.4

License

MIT

Unpacked Size

88.6 kB

Total Files

11

Last publish

Collaborators

  • jmauwerb