0.1.4 • Published 4 years ago

lbd-server v0.1.4

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

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

Typedefs

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.

ParamTypeDescription
usernamestringYour 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.
emailstringYour e-mail address. Should be unique.
passwordstringYour 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.

ParamTypeDescription
emailstringYour e-mail address.
passwordstringYour LBDserver password.

logout(token) ⇒ Promise.<void>

Log out on the LBDserver (backend defined in process.env.REACT_APP_BACKEND)

Kind: global function

ParamTypeDescription
tokenstringThe 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

ParamTypeDescription
tokenstringThe 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

ParamTypeDescription
projectObject.<string, any>The project object.
project.titlestringThe title "name" of the project. It will be registered in the project metadata graph of the project as rdfs:label.
project.descriptionstringA small description of the project. It will be registered in the project metadata graph as rdfs:comment.
project.openbooleanWhether 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).
tokenstringThe 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

ParamTypeDescription
projectstringThe URL or the ID of the project.
tokenstringThe 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

ParamTypeDescription
projectstringThe URL or the ID of the project.
tokenstringThe 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

ParamTypeDescription
urlstringThe url of the resource.
tokenstringThe 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

ParamTypeDescription
propsObject.<string, any>The properties of the object to be uploaded.
props.labelstringA label for the resource. It will be registered in the metadata graph of the resource as rdfs:label.
props.descriptionstringA description for the resource. It will be registered in the metadata graph of the resource as rdfs:comment.
props.fileBlobThe file originating from a HTMLInputElement upload. Only one file at a time.
props.aclstring | BlobAn 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.
projectstringThe URL or the ID of the project.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the requested resource.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the requested resource.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the resource.
tokenstringThe 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

ParamTypeDescription
propsObject.<string, any>The properties of the object to be uploaded.
props.labelstringA label for the resource. It will be registered in the metadata graph of the resource as rdfs:label.
props.descriptionstringA description for the resource. It will be registered in the metadata graph of the resource as rdfs:comment.
props.fileBlobThe file originating from a HTMLInputElement upload. Only one file at a time.
props.aclstring | BlobAn 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.
projectstringThe URL or the ID of the project.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the requested resource.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the resource corresponding with the metadata graph or the URL of the metadata graph itself.
tokenstringThe 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

ParamTypeDescription
urlstringThe URL of the resource.
tokenstringThe 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

ParamTypeDescription
projectstringThe URL or the ID of the project.
querystringA SPARQL select query.
tokenstringThe 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

ParamTypeDescription
projectstringThe URL or the ID of the project.
querystringA SPARQL select query.
graphsArray.<string>An array of the graphs that are to be included in the query.
tokenstringThe 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

ParamTypeDescription
urlstringThe url of the graph to be queried.
querystringA SPARQL select query.
tokenstringThe 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

ParamTypeDescription
urlstringThe url of the graph to be updated.
querystringA SPARQL INSERT/DELETE query.
tokenstringThe 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

NameType
usernamestring
emailstring
projectsArray.<string>
uristring

returnUser : Object

Kind: global typedef
Properties

NameType
userUser
tokenstring

Metadata : Object

Kind: global typedef
Properties

NameTypeDescription
uristringURI of the document
metadataObjectThe metadata as JSON-LD.

Project : Object

Kind: global typedef
Properties

NameTypeDescription
metadataObjectA JSON-LD object of the project metadata
idstringThe project id
uristringThe project uri. Optional (only when creating a project => otherwise it is just the url of the request)
graphsResourceAn object containing all the graphs in the project. The object key is the graph url, the value is its metadata as JSON-LD.
documentsResourceAn object containing all the documents in the project. The object key is the document url, the value is its metadata as JSON-LD.
resultsQueryResultsthe result of an eventual SPARQL SELECT query. Only if a query was sent along.

Resource

Kind: global typedef
Properties

NameType
metadataObject
permissionsArray.<string>

QueryResults : Object

Kind: global typedef
Properties

NameTypeDescription
headObject
head.varsArray.<string>
resultsObject
results.bindingsArray.<Object>links the variables to the results.

Graph : Object

Kind: global typedef
Properties

NameTypeDescription
uristringURI of the document
metadataObjectThe metadata as JSON-LD.
dataObjectThe graph content as JSON-LD
0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago