Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stardog

stardog-union916Apache-2.08.0.1TypeScript support: included

Stardog JavaScript Framework for node.js and the browser - Develop apps using the Stardog RDF Database & JS.

stardog, rdf, sparql, library, semantic web, linked data, query

readme

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

Usage

Stardog.js conforms to the Universal Module Definition API. To use it in Node.js, simply require or import it as you would any other Node module. To use it in the browser, you can either:

  1. Do the same as you would with Node.js, in which case you'll have to use webpack, parcel, browserify, or some other module bundler,
  2. Use require.js or some other module loader, or
  3. Directly import the built stardog.js file in your HTML (e.g., <script src="./node_modules/stardog/dist/stardog.js"></script>) and then reference the global stardogjs object (e.g., stardogjs.query.execute(/* . . . */)).

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

To test the cluster commands you will need to first start a Stardog cluster then run the cluster suite. The easiest way to do this is to run docker-compose to start a cluster:

docker-compose -f .circleci/docker-compose.yml up

Then run the cluster test suite in test/cluster:

npm run test:cluster

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.

Releasing

First, ensure that there is a milstone for the release version, and that all PRs that you want to appear in the CHANGELOG are tagged with that milestone. The milestone must be closed before publishing.

If you have publishing rights, BE SURE TO RUN npm version (major|minor|patch) IMMEDIATELY BEFORE PUBLISHING. This will ensure that the build is up-to-date and will also (1) bump the version number in package.json accordingly, (2) create a git tag matching the version number, and (3) automatically update the README and the CHANGELOG using our type declarations and data from the stardog.js GitHub repo. For this process to work correctly, you will need to have generated a GitHub OAuth token and assigned it to the MDCHANGELOG_TOKEN environment variable (the name of the token is a relic of the fact that this repo once used mdchangelog to generate changelogs; it now uses a custom script). You can then publish by running npm publish. In order to ensure that this process is followed, there will be a very annoying alert triggered whenever you publish; if you're all set, just ignore the alert.

After releasing, be sure to push to master, including the tags (so that the release is reflected on GitHub).

Version/Support Details

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:

stardog.js Version Supported Stardog Version(s)
8.x.x 11.1.x
7.x.x 11.0.x
6.x.x 10.x.x
5.x.x 9.x.x
4.x.x 8.x.x
3.x.x 7.x.x
2.x.x* 6.x.x
1.x.x* 5.x.x
0.x.x* any version < 5

* = No longer supported

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

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 }',
    'application/sparql-results+json',
    {
      limit: 10,
      reasoning: true,
      offset: 0,
    }
  )
  .then(({ body }) => {
    console.log(body.results.bindings);
  });

API

HTTP

RdfMimeType

One of the following values:

'application/ld+json' | 'text/turtle' | 'application/rdf+xml' | 'application/n-triples' | 'application/n-quads' | 'application/trig'

SparqlMimeType

One of the following values:

'application/sparql-results+json' | 'application/sparql-results+xml'

AcceptMimeType

One of the following values:

RdfMimeType | SparqlMimeType | 'text/plain' | 'text/boolean' | 'application/json' | '*/*'

ExplainAcceptMimeType

One of the following values:

'text/plain' | 'application/json'

Body

Object with the following values:

  • status (number)
  • statusText (string)
  • result (object | string | boolean | null)
  • ok (boolean)
  • headers (Headers)
  • body (any)
  • url (string)

ConnectionOptions

Object with the following values:

  • endpoint (string)
  • username (string)
  • password (string)
  • token (string)
  • meta (ConnectionMeta)

RequestConstructor

One of the following values:

{ new (input: string | Request, init?: RequestInit): Request; }

RequestCreator

One of the following values:

({ uri, Request }: { uri: string; Request: Constructor }) => ReturnType

ConnectionMeta

Object with the following values:

  • createRequest (RequestCreator<RequestConstructor, string | Request>)
  • createHeaders ((defaults: { headers: Headers; }) => Headers)

Connection (Class)

Constructed with:

Takes the following params:

Returns void

Connection.headers()

Returns Headers

Connection.uri(resource)

Takes the following params:

  • resource (string[])

Returns string

server

server.shutdown(conn, params)

Shuts down a Stardog server.

Expects the following parameters:

Returns Promise<HTTP.Body>

server.status(conn, params)

Retrieves general status information about a Stardog server. By default, also includes status information about all databases on that server. If params.databases is false, however, then the information about databases is omitted.

Expects the following parameters:

  • conn (Connection)

  • params ({ databases?: boolean; })

Returns Promise<HTTP.Body>

server.properties(conn, names)

Retrieves server properties. By default, it will return all server properties, but you can specify names to return specific ones.

Expects the following parameters:

Returns Promise<HTTP.Body>

db

db.create(conn, database, databaseOptions, options, params)

Creates a new database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • databaseOptions (object)

  • options ({ files: { filename: string}[] })

  • params (object)

Returns Promise<HTTP.Body>

db.drop(conn, database, params)

Deletes a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.get(conn, database, params)

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>

db.offline(conn, database, params)

Sets a database offline.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.online(conn, database, params)

Sets a database online.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.optimize(conn, database, params)

Optimizes a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.list(conn, params)

Gets a list of all databases on a Stardog server.

Expects the following parameters:

Returns Promise<HTTP.Body>

db.listInfo(conn, params)

Gets a list of databases info on a Stardog server.

Expects the following parameters:

Returns Promise<HTTP.Body>

db.size(conn, database, params)

Gets number of triples in a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.model(conn, database, options, params)

Gets the model for a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • options (object)

  • params (object)

Returns Promise<HTTP.Body>

db.clear(conn, database, transactionId, params)

Clears the contents of a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • params (object)

Returns Promise<HTTP.Body>

db.add(conn, database, transactionId, content, options, params)

Adds data within a transaction.

Expects the following parameters:

Returns Promise<transaction.TransactionResponse>

db.remove(conn, database, transactionId, content, options, params)

Removes data within a transaction.

Expects the following parameters:

Returns Promise<transaction.TransactionResponse>

db.exportData(conn, database, options, params)

Exports the contents of a database.

Expects the following parameters:

Returns Promise<HTTP.Body>

options

db.options.getAvailable(conn)

Gets all available database options with their default values.

Expects the following parameters:

Returns Promise<HTTP.Body>

db.options.get(conn, database, params)

Gets set of options on a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.options.getAll(conn, database)

Gets all options on a database.

Expects the following parameters:

Returns Promise<HTTP.Body>

db.options.set(conn, database, databaseOptions, params)

Sets options on a database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • databaseOptions (object)

  • params (object)

Returns Promise<HTTP.Body>

graph

db.graph.doGet(conn, database, graphUri, accept, params)

Retrieves the specified named graph

Expects the following parameters:

Returns Promise<HTTP.Body>

db.graph.doPut(conn, database, graphData, graphUri, contentType, params)

Stores the given RDF data in the specified named graph

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • graphData (string)

  • graphUri (string)

  • contentType (RdfMimeType)

  • params (object)

Returns Promise<HTTP.Body>

db.graph.doDelete(conn, database, graphUri, params)

Deletes the specified named graph

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • graphUri (string)

  • params (object)

Returns Promise<HTTP.Body>

db.graph.doPost(conn, database, graphUri, options, params)

Merges the given RDF data into the specified named graph

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • graphUri (string)

  • options ({ contentType: RdfMimeType })

  • params (object)

Returns Promise<HTTP.Body>

transaction

Encodings

One of the following values:

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

TransactionResponse extends HTTP.Body

Object with the following values:

  • transactionId (string)

TransactionOptions

Object with the following values:

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

db.transaction.begin(conn, database, params)

Begins a new transaction.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<TransactionResponse>

db.transaction.rollback(conn, database, transactionId, params)

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>

db.transaction.commit(conn, database, transactionId, params)

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>

icv

db.icv.get(conn, database, params)

Gets the set of integrity constraints on a given database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.icv.add(conn, database, icvAxioms, options, params)

Adds integrity constraints to a given database.

DEPRECATED: Support for storing ICV constraints in the system database is deprecated in Stardog 7.5.0 and removed in Stardog 8.0.0; instead, SHACL constraints can be managed using db.add.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • icvAxioms (string)

  • options ({ contentType: RdfMimeType })

  • params (object)

Returns Promise<HTTP.Body>

db.icv.remove(conn, database, icvAxioms, options, params)

Removes integrity constraints from a given database.

DEPRECATED: Support for storing ICV constraints in the system database is deprecated in Stardog 7.5.0 and removed in Stardog 8.0.0; instead, SHACL constraints can be managed using db.remove.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • icvAxioms (string)

  • options ({ contentType: RdfMimeType })

  • params (object)

Returns Promise<HTTP.Body>

db.icv.clear(conn, database, params)

Removes all integrity constraints from a given database.

DEPRECATED: Support for storing ICV constraints in the system database is deprecated in Stardog 7.5.0 and removed in Stardog 8.0.0; instead, SHACL constraints can be managed using db.remove.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.icv.validate(conn, database, constraints, options, params)

Checks constraints to see if they are valid

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • options ({ contentType: RdfMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

db.icv.validateInTx(conn, database, transactionId, constraints, options, params)

Checks constraints to see if they are valid within a transaction

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • constraints (string)

  • options ({ contentType: RdfMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

db.icv.violations(conn, database, constraints, options, params)

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: RdfMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

db.icv.violationsInTx(conn, database, transactionId, constraints, options, params)

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

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • constraints (string)

  • options ({ contentType: RdfMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

db.icv.report(conn, database, constraints, options, params)

Accepts integrity constraints as RDF and returns a validation report.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • constraints (string)

  • options ({ contentType?: HTTP.RdfMimeType, accept?: AcceptMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

db.icv.reportInTx(conn, database, transactionId, constraints, options, params)

Accepts integrity constraints as RDF and returns a validation report.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • constraints (string)

  • options ({ contentType?: HTTP.RdfMimeType, accept?: AcceptMimeType })

  • params ({ graphUri: string })

Returns Promise<HTTP.Body>

reasoning

db.reasoning.consistency(conn, database, options, params)

Returns if the database is consistent

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • options ({ namedGraph: string })

  • params (object)

Returns Promise<HTTP.Body>

db.reasoning.explainInference(conn, database, inference, config, params)

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>

db.reasoning.explainInconsistency(conn, database, options, params)

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>

db.reasoning.explainInferenceInTransaction(conn, database, transactionId, inference, config, params)

Provides an explanation for an inference within a transaction

Expects the following parameters:

Returns Promise<HTTP.Body>

db.reasoning.explainInconsistencyInTransaction(conn, database, transactionId, options, params)

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>

db.reasoning.schema(conn, database, params)

Gets the reasoning schema of the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

docs

db.docs.size(conn, database, params)

Retrieves the size of the document store

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.docs.clear(conn, database, params)

Clears the document store

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

db.docs.add(conn, database, fileName, fileContents, params)

Adds a document to the document store

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • fileName (string)

  • fileContents (string)

  • params (object)

Returns Promise<HTTP.Body>

db.docs.remove(conn, database, fileName, params)

Removes a document from the document store

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • fileName (string)

  • params (object)

Returns Promise<HTTP.Body>

db.docs.get(conn, database, fileName, params)

Retrieves a document from the document store

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • fileName (string)

  • params (object)

Returns Promise<HTTP.Body>

namespaces

db.namespaces.get(conn, database)

Gets a mapping of the namespaces used in a database.

Expects the following parameters:

Returns Promise<HTTP.Body>

db.namespaces.add(conn, database, fileOrContents, options)

Extracts namespaces from an RDF file or RDF string and adds new and updates existing namespaces in the database.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • fileOrContents (object | string)

  • options ({ contentType?: RdfMimeType })

Returns Promise<HTTP.Body>

query

QueryType

One of the following values:

'select' | 'ask' | 'construct' | 'describe' | 'validate' | 'update' | 'paths' | null

PropertyOptions

Object with the following values:

  • uri (string)
  • property (string)

AdditionalHandlers

Object with the following values:

  • onResponseStart ((res: Response) => boolean | void)

query.property(conn, database, config, params)

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

Expects the following parameters:

Returns Promise<HTTP.Body>

query.explain(conn, database, query, accept, params)

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

Expects the following parameters:

Returns Promise<HTTP.Body>

query.execute(conn, database, query, accept, params, additionalHandlers)

Executes a query against a database.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.executeInTransaction(conn, database, transactionId, query, options, params)

Executes a query against a database within a transaction.

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • transactionId (string)

  • query (string)

  • options ({ accept: RdfMimeType })

  • params (object)

Returns Promise<HTTP.Body>

query.list(conn)

Gets a list of actively running queries.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.kill(conn, queryId)

Kills an actively running query.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.get(conn, queryId)

Gets information about an actively running query.

Expects the following parameters:

Returns Promise<HTTP.Body>

StoredQueryOptions

Object with the following values:

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

stored

query.stored.create(conn, storedQuery, options)

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

Expects the following parameters:

  • conn (Connection)

  • storedQuery ([StoredQueryOptions | object](#storedqueryoptions | object))

  • options ({ accept?: string, contentType?: string })

Returns Promise<HTTP.Body>

query.stored.list(conn, options)

Lists all stored queries.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.stored.update(conn, storedQuery, options, useUpdateMethod)

Updates a given stored query and creates it if the name does not refer to an existing stored query.

Expects the following parameters:

  • conn (Connection)

  • storedQuery ([StoredQueryOptions | object](#storedqueryoptions | object))

  • options ({ accept?: string, contentType?: string })

  • useUpdateMethod (boolean)

Returns Promise<HTTP.Body>

query.stored.remove(conn, storedQuery)

Removes a given stored query.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.stored.get(conn, storedQuery)

Gets a given stored query.

Expects the following parameters:

Returns Promise<HTTP.Body>

query.stored.rename(conn, name, newName)

Renames a given stored query.

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • newName (string)

Returns Promise<HTTP.Body>

graphql

query.graphql.execute(conn, database, query, variables, params, additionalHandlers)

Executes a GraphQL query

Expects the following parameters:

Returns Promise<HTTP.Body>

query.graphql.listSchemas(conn, database, params)

Retrieves a list of GraphQL schemas in the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

query.graphql.addSchema(conn, database, name, schema, params)

Adds a GraphQL schema to the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • name (string)

  • schema (object)

  • params (object)

Returns Promise<HTTP.Body>

query.graphql.updateSchema(conn, database, name, schema, params)

Updates (or adds if non-existent) a GraphQL schema to the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • name (string)

  • schema (object)

  • params (object)

Returns Promise<HTTP.Body>

query.graphql.getSchema(conn, database, name, params)

Retrieves a GraphQL schema from the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • name (string)

  • params (object)

Returns Promise<HTTP.Body>

query.graphql.removeSchema(conn, database, name, params)

Removes a GraphQL schemafrom the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • name (string)

  • params (object)

Returns Promise<HTTP.Body>

query.graphql.clearSchemas(conn, database, params)

Clears all GraphQL schemas in the database

Expects the following parameters:

  • conn (Connection)

  • database (string)

  • params (object)

Returns Promise<HTTP.Body>

utils

query.utils.queryType(query)

Returns the QueryType (as a string or null) for the given query.

Expects the following parameters:

  • query (string)

Returns QueryType

query.utils.mimeType(query)

Returns the default HTTP Accept MIME type for the given query.

Expects the following parameters:

  • query (string)

Returns HTTP.AcceptMimeType

user

User

Object with the following values:

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

Action

One of the following values:

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

ResourceType

One of the following values:

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

user.list(conn, params)

Gets a list of users.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.listInfo(conn)

Retrieve a list of user info

Expects the following parameters:

Returns Promise<HTTP.Body>

user.get(conn, username, params)

Gets all information for a given user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.create(conn, user, params)

Creates a new user.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.changePassword(conn, username, currentPassword, password, params)

Changes a user's password.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • currentPassword (string)

  • password (string)

  • params (object)

Returns Promise<HTTP.Body>

user.valid(conn, params)

Verifies that a Connection's credentials are valid.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.enabled(conn, username, params)

Verifies that a user is enabled.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.enable(conn, username, enabled, params)

Enables/disables a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • enabled (boolean)

  • params (object)

Returns Promise<HTTP.Body>

user.setRoles(conn, username, roles, params)

Sets roles for a user. (Overwrites any existing roles)

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • roles (string[])

  • params (object)

Returns Promise<HTTP.Body>

user.assignRole(conn, username, role, params)

Adds a role to a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • role (string)

  • params (object)

Returns Promise<HTTP.Body>

user.listRoles(conn, username, params)

Gets a list of roles assigned to a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.assignPermission(conn, username, permission, params)

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

Expects the following parameters:

Returns Promise<HTTP.Body>

user.deletePermission(conn, username, permission, params)

Removes a permission for a user over a given resource.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.permissions(conn, username, params)

Gets a list of permissions assigned to user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.effectivePermissions(conn, username, params)

Gets a list of a user's effective permissions.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.superUser(conn, username, params)

Specifies whether a user is a superuser.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.remove(conn, username, params)

Deletes a user.

Expects the following parameters:

  • conn (Connection)

  • username (string)

  • params (object)

Returns Promise<HTTP.Body>

user.token(conn)

Returns a token for the user if the connection is valid.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.whoAmI(conn)

Returns the username for the given connection.

Expects the following parameters:

Returns Promise<HTTP.Body>

Permission

Object with the following values:

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

role

user.role.create(conn, role, params)

Creates a new role.

Expects the following parameters:

  • conn (Connection)

  • role ({ name: string })

  • params (object)

Returns Promise<HTTP.Body>

user.role.list(conn, params)

Lists all existing roles.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.listInfo(conn)

Retrieve a list of role info

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.remove(conn, role, params)

Deletes an existing role from the system.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.usersWithRole(conn, role, params)

Lists all users that have been assigned a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.assignPermission(conn, role, permission, params)

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

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.deletePermission(conn, role, permission, params)

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

Expects the following parameters:

Returns Promise<HTTP.Body>

user.role.permissions(conn, role, params)

Lists all permissions assigned to a given role.

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs

SharedOptions

Object with the following values:

  • base (string)
  • mappings.syntax (string)
  • percent.encode (boolean)
  • optimize.import (boolean)
  • query.translation ('DEFAULT' | 'LEGACY')

RdbmsOptions extends SharedOptions

Object with the following values:

  • jdbc.url (string)
  • jdbc.username (string)
  • jdbc.password (string)
  • jdbc.driver (string)
  • parser.sql.quoting ('NATIVE' | 'ANSI')
  • sql.functions (string)
  • sql.schemas (string)
  • default.mappings.include.tables (string)
  • default.mappings.exclude.tables (string)

MongoOptions extends SharedOptions

Object with the following values:

  • mongodb.uri (string)

CsvOptions extends SharedOptions

Object with the following values:

  • csv.separator (string)
  • csv.quote (string)
  • csv.escape (string)
  • csv.header (boolean)
  • csv.skip.empty (boolean)

AllVgOptions

One of the following values:

SharedOptions & RdbmsOptions & MongoOptions & CsvOptions

MappingsRequestOptions

Object with the following values:

  • preferUntransformed (boolean)
  • syntax (string)

VgMeta

Object with the following values:

  • db (string)
  • dataSource (string)

virtualGraphs.list(conn)

Retrieve a list of virtual graphs

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.listInfo(conn)

Retrieve a list of virtual graphs info

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.add(conn, name, mappings, options, meta)

Add a virtual graph to the system

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.update(conn, name, mappings, options, meta)

Update a virtual graph in the system

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.remove(conn, name)

Remove a virtual graph from the system

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.online(conn, name)

Bring a virtual graph online

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.available(conn, name)

Determine if the named virtual graph is available

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.options(conn, name)

Retrieve a virtual graph's options

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.mappings(conn, name, requestOptions)

Retrieve a virtual graph's mappings

Expects the following parameters:

Returns Promise<HTTP.Body>

virtualGraphs.importFile(conn, file, fileType, fileIri, database, importOptions)

Import a JSON or CSV file into a database via virtual import.

Expects the following parameters:

  • conn (Connection)

  • file (object)

  • fileType (string)

  • fileIri (string)

  • database (string)

  • importOptions (`{

        mappings?: string,
        properties?: string,
        namedGraph?: string,
      }`)

Returns Promise<HTTP.Body>

storedFunctions

storedFunctions.add(conn, functions, params)

Adds one or more stored functions to the server

Expects the following parameters:

  • conn (Connection)

  • functions (string)

  • params (object)

Returns Promise<HTTP.Body>

storedFunctions.get(conn, name, params)

Retrieves the specified function definition

Expects the following parameters:

Returns Promise<HTTP.Body>

storedFunctions.remove(conn, name, params)

Removes a stored function from the server

Expects the following parameters:

Returns Promise<HTTP.Body>

storedFunctions.clear(conn, params)

Removes all stored functions from the server

Expects the following parameters:

Returns Promise<HTTP.Body>

storedFunctions.getAll(conn, params)

Retrieves an export of all stored functions on the server

Expects the following parameters:

Returns Promise<HTTP.Body>

cluster

cluster.info(conn)

Retrieves basic information about a Stardog cluster.

Expects the following parameters:

Returns Promise<HTTP.Body>

cluster.status(conn)

Retrieves detailed status information about a Stardog cluster.

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog

catalog.status(conn)

Lists the status of catalog providers

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog.reload(conn, provider)

Starts a reload of information about a specific provider

Expects the following parameters:

Returns Promise<HTTP.Body>

Credentials

One of the following values:

{ username: string, password: string } | { token: string } | { clientId: string, clientSecret: string }

catalog.addCredential(conn, credentials, label)

Adds a provider credential

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog.listCredentials(conn)

Lists stored provider credentials

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog.removeCredential(conn, accessKey)

Removes a stored provider credential

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog.runJob(conn, jobname)

Manually starts a provider job

Expects the following parameters:

Returns Promise<HTTP.Body>

catalog.testConnection(conn, connectionOptions)

Tests a provider connection using existing/new credentials.

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources

dataSources.list(conn)

Retrieve a list of data sources

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.listInfo(conn)

Retrieve a list of data sources info

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.info(conn, name)

Retrieve the named data source info

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.add(conn, name, options)

Add a data source to the system

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.update(conn, name, options, requestOptions)

Update the named data source in the system

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • options (T)

  • requestOptions ({ delta_options?: boolean; force?: boolean })

Returns Promise<HTTP.Body>

dataSources.remove(conn, name, params)

Remove the named data source from the system

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.share(conn, name)

Change a private data source to a shared one

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.online(conn, name)

Bring the named data source online

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.available(conn, name)

Determine if the named data source is available

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.options(conn, name)

Retrieve the named data source options

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.getMetadata(conn, name, options)

Retrieve the named data source metadata

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • options (object)

Returns Promise<HTTP.Body>

dataSources.updateMetadata(conn, name, metadata, options)

Update the named data source metadata

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • metadata (T)

  • options (object)

Returns Promise<HTTP.Body>

dataSources.getTables(conn, name, options)

Retrieve tables

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • options (object)

Returns Promise<HTTP.Body>

dataSources.getTableMetadata(conn, name, options)

Retrieve the named table metadata

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • options (object)

Returns Promise<HTTP.Body>

DataSourceQuery

One of the following values:

string | { query: string, options: object }

dataSources.query(conn, name, dataSourceQuery)

Query data source

Expects the following parameters:

Returns Promise<HTTP.Body>

dataSources.refreshCounts(conn, name, tableName)

Refresh table row-count estimates

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • tableName (string)

Returns Promise<HTTP.Body>

dataSources.refreshMetadata(conn, name, tableName)

Refresh metadata

Expects the following parameters:

  • conn (Connection)

  • name (string)

  • tableName (string)

Returns Promise<HTTP.Body>

dataSources.suggestions(conn, content, options)

Get suggestions for property matches on a model.

Expects the following parameters:

  • conn (Connection)

  • content (string)

  • options ({ accept?: string; contentType?: string })

Returns Promise<HTTP.Body>

dataSources.typeDescription(conn)

Get information about the data source types supported by the stardog instance, and their options

Expects the following parameters:

Returns Promise<HTTP.Body>

changelog

v8.0.0

  • 311 [VET-5579] require current password for changing passwords

v7.1.0

  • 310 Add get stored query endpoint

v7.0.0

  • 309 [VET-5298] Add input_file_iri for virtual file import

v6.0.0

  • 307 [VET-4456] Add DS table endpoints
  • 305 VET-3936 add jobs endpoint

v5.3.1

  • 306 [VET-3766][VET-4297] Update addCredentials to support Atlan and Purview

v5.3.0

  • 304 [VET-4197] Add testConnection method for Knowledge Catalog

v5.2.1

  • 303 [VET-4121] Avoid internal errors for bad namespace responses

v5.2.0

  • 302 [VET-3627] Add support for catalog endpoints

v5.1.0

  • 301 Allow delta_options request option for updating data sources

v5.0.0

  • 300 Stardog 9 updates
  • 299 [VET-3276] Add Validate to Stardog.js

v4.9.0

  • 297 [Cloud-1157] Add server.properties

v4.8.0

  • 295 [VET-3070] add db.listInfo

v4.7.1

  • 291 [VET-2831] Allow arbitrary metadata for stored queries

v4.7.0

  • 292 [VET-2901] Rename docker environment variables
  • 290 [VET-2824] Add node 18 compatibility

v4.6.1

  • 289 [VET-2689] Add support for data source query options

v4.6.0

  • 288 Re-add deprecated icv methods
  • 287 [VET-2765] Add user.listInfo and user.role.listInfo

v4.5.0

  • 285 Add user.assignRole

v4.4.0

  • 283 [VET-2546] Breaking Change Do not flatten request body nor unflatten response body for db.options

v4.3.2

  • 281 [VET-2486] Update flat package

v4.3.1

  • 279 [VET-2486] Update flat package

v4.3.0

  • 278 [VET-1703] Data source description endpoint

v4.2.0

  • 276 [VET-2029] Stardog.js changes for automapping service

v4.1.0

  • 273 [VET-1900] Remove icv.clear and icv.convert
  • 271 [VET-1380] Add admin/status/whoami

v4.0.0

  • 268 [VET-1900] Remove ICV add/remove

v3.8.0

  • 298 Add server.properties

v3.7.0

  • 286 Add user.assignRole

v3.6.0

  • 284 [VET-2546] Breaking Change Do not flatten request body nor unflatten response body for db.options

v3.5.2

  • 282 [VET-2486] Update flat package

v3.5.1

  • 280 [VET-2486] Update flat package

v3.5.0

  • 275 [VET-1380] Add admin/status/whoami

v3.4.0

  • 270 [VET-1921] Add rename stored query to stardog.js
  • 267 [VET-1899] Deprecate ICV add/remove

v3.3.0

  • 265 [VET-1472] Implement new data source query API

v3.2.0

  • 261 Add token auth support

v3.1.0

  • 258 Expose native fetch in the browser
  • 255 Update new Buffer to Buffer.from

v3.0.0

  • 254 Remove db.versioning API (not supported in Stardog 7)
  • 253 Add support for importing namespaces from string or file
  • 252 Add dataSources API support
  • 251 Add cluster API support
  • 250 Remove db.copy (not supported in Stardog 7)
  • 217 Add support for Stardog data model endpoint
  • 214 Support updating GraphQL schemas without remove/add
  • 209 Add support for importing from file (e.g., CSV) to VG
  • 204 Add ability to send properties file on db.create

v2.0.0

  • 245 Add db.options.getAvailable and db.options.getAll
  • 244 Add additionalHandlers support to graphql execute
  • 243 Automatically set utf-8 when adding/updating stored query
  • 242 Support params in graphql query execution
  • 228 Query utils do not correctly handle commented-out prefixes
  • 220 Add support for creating/updating virtual graphs with database id
  • 210 Add support for streaming "export data" directly to disk
  • 197 Add support for new properties on stored queries
  • 195 Add support for 'list' endpoint for virtual graphs
  • 190 add stored query update method
  • 187 Missing icv.report and icv.reportInTransaction functionality
  • 186 Types for icv.violationsInTx and icv.validateInTx are wrong
  • 183 Fix tests when using Stardog 6.0.1
  • 156 Allow some methods to send back response data immediately
  • 154 Upgrade fetch-ponyfill

v1.4.0

  • 180 Update mappings call to support requesting untransformed mappings

v1.3.2

  • 178 query.executeInTransaction sends update queries to query endpoint

v1.3.1

  • 173 Upgrade CI configuration to CircleCI v2
  • 170 In-browser usage is undocumented
  • 169 Typescript problems

v1.3.0

  • 165 Add method for retrieving server status info
  • 164 Typing for role creation is incorrect

v1.2.4

  • 168 Fix documentation query.execute example

v1.2.3

  • 162 Typings bug: status type in HTTP.Body should be number, not string

1.2.2

  • 158 Resolve security vulnerability in transitive dependency (marked 0.3.6)

1.2.1

  • 152 db.add/remove not handling certain content correctly

1.2.0

  • 150 Should allow other authorization methods besides 'Basic'

1.1.1

  • 148 Typings for Connection are missing the (new) meta property

1.1.0

  • 146 Support fetch from behind proxies and/or to endpoints with self-signed certs

1.0.3

  • 144 Expose utils for use by consumers of Stardog.js

1.0.2

  • 142 Null pointer when query is unknown type

1.0.1

  • 139 mimeType issue

1.0.0

  • 135 Handle duplicate vars in paths query responses
  • 131 Stored Functions
  • 130 GraphQL
  • 125 Virtual Graph API
  • 124 BITES API
  • 123 Versioning API
  • 120 Graph store protocol

1.0.0-rc3

  • 117 Support for PATHS query
  • 115 ReadMe out of sync with npm repository
  • 112 Fix incorrect Role param for user.role functions
  • 110 Query string parameters not sending upstream
  • 109 Allow to customize accept header

1.0.0-rc2

  • 104 Check if user is valid
  • 103 ✨ - Flesh out ICV endpoint and consolidate its tests
  • 102 ✨ - Add reasoning endpoints and tests as part of #85
  • 101 Get a single user
  • 97 Function parameter documentation

1.0.0-rc1

  • 95 HTTP Body
  • 88 SPARQL Updates
  • 82 Expose More Headers
  • 78 Tests for "graph" queries
  • 75 Missing Calls
  • 70 Normalize Create Methods
  • 65 End of Life "develop" branch
  • 61 Prettier
  • 60 Changelog
  • 59 Clean up .npmignore
  • 58 Migrate to ESLint Airbnb style
  • 57 End of Life GH Pages
  • 55 End of Life Bower
  • 54 Lodash
  • 53 CI Integration
  • 52 Test Migration
  • 51 Documentation
  • 50 Typedefs
  • 49 Rollup integration
  • 48 Error handling
  • 47 isomorphic-fetch

stardog.js-0.1.2

  • 37 Call to getPrefixes is returning a fixed set of namespaces
  • 33 Implement Query Management API
  • 32 (feature req) Specifying reasoning level per-query
  • 31 problem with Running Tests in the browser
  • 30 simple test problem in browser
  • 29 browser problemswith tests on windows
  • 26 Async: false option

stardog.js-0.0.5

  • 24 Set up automated testing for the browser
  • 23 Add AMD compatibility
  • 18 Named parameters object?
  • 13 Better error reporting & exception handling

stardog.js-0.0.3

  • 6 Add doc as JSDoc in the code
  • 3 Support reasoning in query answering