Coder Social home page Coder Social logo

petrsimon / stardog.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stardog-union/stardog.js

0.0 2.0 0.0 1.16 MB

Stardog JavaScript Framework for node.js and the browser

Home Page: https://github.com/stardog-union/stardog.js

License: Other

JavaScript 100.00%

stardog.js's Introduction

Stardog.js

Universal Javascript fetch wrapper for communicating with the Stardog HTTP server.

npm

What is it?

This framework wraps all the functionality of a client for the Stardog DBMS, and provides access to a full set of functions such as executing SPARQL queries, administrative tasks on Stardog, and the use of the Reasoning API.

All the implementation uses the HTTP protocol, since most of Stardog functionality is available using this protocol. For more information, go to the Stardog's HTTP Programming documentation.

This is a universal library and as such can be used in both the browser and Node.js.

Installation

To install stardog.js run:

npm install stardog

Development

To get started, just clone the project. You'll need a local copy of Stardog to be able to run the tests. For more information on starting the Stardog DB service and how it works, go to Stardog's documentation, where you'll find everything you need to get up and running with Stardog.

Go to http://stardog.com, download and install the database and load the data provided in data/ using the script in the repository.

  1. Start the Stardog server
stardog-admin server start
  1. Install stardog.js dependencies:
npm install

Running Tests

In order to contribute changes, all test cases must pass. With the Stardog server running, execute the following command to run all test cases in test/spec:

npm test

Contributing

Fork, clone and develop, write or amend tests, and then open a PR. All PRs go against "master". This project uses prettier on file commit, so don't worry about style as it'll just get rewritten when you commit your changes.

Version details

The current version of stardog.js has been tested against version 5.0.0 of Stardog. You are encouraged to use this library if you are using version 5 or greater of Stardog. However, there is very little code that is version specific in stardog.js. It is essentially just a convenience wrapper around fetch. It is very likely that many of the exposed methods will work on older versions of Stardog, but this has not been tested.

If you are using a really old version of Stardog (<= 3.0.0) you should stick with the legacy version of the library which is version 0.3.1.

Discontinued Versions

All versions of stardog.js prior to v1.0.0 have been discontinued and will not receive updates of any kind. If you are using a legacy version of stardog.js you can find the original documentation here. The most recent legacy version is 0.3.1.

Quick Example

const { Connection, query } = require('stardog');

const conn = new Connection({
  username: 'admin',
  password: 'admin',
  endpoint: 'http://localhost:5820',
});

query.execute(conn, 'myDatabaseName', 'select distinct ?s where { ?s ?p ?o }', {
  limit: 10,
  offset: 0,
}).then(({ body }) => {
  console.log(body.results.bindings);
});

API

One of the following values:

'application/x-turtle' | 'text/turtle' | 'application/rdf+xml' | 'text/plain' | 'application/x-trig' | 'text/x-nquads' | 'application/trix'

One of the following values:

'text/plain' | 'application/json' | 'text/boolean'

Object with the following values:

  • status (string)
  • statusText (string)
  • result (object | string | boolean | null)
  • ok (boolean)
  • headers (Headers)

Object with the following values:

  • endpoint (string)
  • username (string)
  • password (string)

Connection (Class)

Constructed with:

Takes the following params:

Returns void

Returns Headers

Takes the following params:

  • resource (string[])

Returns string

Shuts down a Stardog server.

Expects the following parameters:

Returns Promise<HTTP.Body>

Creates a new database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • databaseOptions (object)

  • options ({ files: string[] })

  • params (object)

Returns Promise<HTTP.Body>

Deletes a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Gets an RDF representation of a database. See: https://www.w3.org/TR/sparql11-http-rdf-update/#http-get

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Sets a database offline.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Sets a database online.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Optimizes a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Makes a copy of a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • destination (string)

  • params (object)

Returns Promise<HTTP.Body>

Gets a list of all databases on a Stardog server.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets number of triples in a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Clears the contents of a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • params (object)

Returns Promise<HTTP.Body>

Adds data within a transaction.

Expects the following parameters:

Returns Promise<TransactionResponse>

Removes data within a transaction.

Expects the following parameters:

Returns Promise<TransactionResponse>

Gets a mapping of the namespaces used in a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Exports the contents of a database.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets set of options on a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Sets options on a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • databaseOptions (object)

  • params (object)

Returns Promise<HTTP.Body>

One of the following values:

'gzip' | 'compress' | 'deflate' | 'identity' | 'br'

Object with the following values:

  • transactionId (string)

Object with the following values:

  • contentType (HTTP.ContentMimeTypes)
  • encoding (Encodings)

Begins a new transaction.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<TransactionResponse>

Rolls back a transaction, removing the transaction and undoing all changes

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • params (object)

Returns Promise<TransactionResponse>

Commits a transaction to the database, removing the transaction and making its changes permanent.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • params (object)

Returns Promise<TransactionResponse>

Gets the set of integrity constraints on a given database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Adds integrity constraints to a given database.

Expects the following parameters:

Returns Promise<HTTP.Body>

Removes integrity constraints from a given database.

Expects the following parameters:

Returns Promise<HTTP.Body>

Removes all integrity constraints from a given database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Converts a set of integrity constraints into an equivalent SPARQL query for a given database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • icvAxioms (string)

  • options ({ contentType: ContentMimeTypes })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

Checks constraints to see if they are valid

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • options ({ contentType: ContentMimeTypes })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

Checks constraints to see if they are valid within a transaction

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • transactionId (string)

  • options ({ contentType: ContentMimeTypes })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

Accepts integrity constraints as RDF and returns the violation explanations, if any, as RDF.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • options ({ contentType: ContentMimeTypes })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

Accepts integrity constraints as RDF and returns the violation explanations, if any, as RDF.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • options ({ contentType: ContentMimeTypes })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

Returns if the database is consistent

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • options ({ namedGraph: string })

  • params (object)

Returns Promise<HTTP.Body>

Provides an explanation for an inference

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • inference (string)

  • config ({ contentType: string })

  • params (object)

Returns Promise<HTTP.Body>

Provides the reason why a database is inconsistent, as reported by db.reasoning.consistency

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • options ({ namedGraph: string })

  • params (object)

Returns Promise<HTTP.Body>

Provides an explanation for an inference within a transaction

Expects the following parameters:

Returns Promise<HTTP.Body>

Provides the reason why a database is inconsistent, as reported by db.reasoning.consistency

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • options ({ namedGraph: string })

  • params (object)

Returns Promise<HTTP.Body>

Gets the reasoning schema of the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

Object with the following values:

  • uri (string)
  • property (string)

Gets the values for a specific property of a URI individual.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets the query plan generated by Stardog for a given SPARQL query.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • query (string)

  • params (object)

Returns Promise<HTTP.Body>

Executes a query against a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • query (string)

  • params (object)

Returns Promise<HTTP.Body>

Executes a query against a database within a transaction.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • query (string)

  • params (object)

Returns Promise<HTTP.Body>

Gets a list of actively running queries.

Expects the following parameters:

Returns Promise<HTTP.Body>

Kills an actively running query.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets information about an actively running query.

Expects the following parameters:

Returns Promise<HTTP.Body>

Object with the following values:

  • name (string)
  • database (string)
  • query (string)
  • shared (boolean)

Stores a query in Stardog, either on the system level or for a given database.

Expects the following parameters:

Returns Promise<HTTP.Body>

Lists all stored queries.

Expects the following parameters:

Returns Promise<HTTP.Body>

Removes a given stored query.

Expects the following parameters:

  • conn (Connection)

  • storedQuery (string)

  • params (object)

Returns Promise<HTTP.Body>

Object with the following values:

  • username (string)
  • password (string)
  • superuser (boolean)

One of the following values:

'CREATE' | 'DELETE' | 'READ' | 'WRITE' | 'GRANT' | 'REVOKE' | 'EXECUTE'

One of the following values:

'db' | 'user' | 'role' | 'admin' | 'metadata' | 'named-graph' | 'icv-constraints'

Gets a list of users.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets all information for a given user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Creates a new user.

Expects the following parameters:

Returns Promise<HTTP.Body>

Changes a user's password.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • password (string)

  • params (object)

Returns Promise<HTTP.Body>

Verifies that a Connection's credentials are valid.

Expects the following parameters:

Returns Promise<HTTP.Body>

Verifies that a user is enabled.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Enables/disables a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • enabled (boolean)

  • params (object)

Returns Promise<HTTP.Body>

Sets roles for a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • roles (string[])

  • params (object)

Returns Promise<HTTP.Body>

Gets a list of roles assigned to a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Creates a new permission for a user over a given resource.

Expects the following parameters:

Returns Promise<HTTP.Body>

Removes a permission for a user over a given resource.

Expects the following parameters:

Returns Promise<HTTP.Body>

Gets a list of permissions assigned to user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Gets a list of a user's effective permissions.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Specifies whether a user is a superuser.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Deletes a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

Object with the following values:

  • rolename (string)

Object with the following values:

  • action (Action)
  • resourceType (ResourceType)
  • resources (string[])

Creates a new role.

Expects the following parameters:

Returns Promise<HTTP.Body>

Lists all existing roles.

Expects the following parameters:

Returns Promise<HTTP.Body>

Deletes an existing role from the system.

Expects the following parameters:

Returns Promise<HTTP.Body>

Lists all users that have been assigned a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

Adds a permission over a given resource to a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

Removes a permission over a given resource from a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

Lists all permissions assigned to a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

stardog.js's People

Contributors

arb avatar edgarrd avatar laczoka avatar m3rabb avatar snowell avatar andhikanugraha avatar bearnis avatar jonbca avatar mhgrove avatar ronmichael avatar gitter-badger avatar

Watchers

Petr Šimon avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.