Socket
Socket
Sign inDemoInstall

@innotrade/enapso-graphdb-admin

Package Overview
Dependencies
11
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@innotrade/enapso-graphdb-admin


Version published
Maintainers
3
Created

Readme

Source

ENAPSO

ENAPSO Graph Database Admin



Website   •   Documentation   •   Discussion   •   Facebook   •   Twitter   •   LinkedIn

ENAPSO Graph Database Admin client to easily perform administrative and monitoring operations against your RDF stores, your OWL ontologies, or knowledge graphs in nodes.js applications. This client supports an easy import of existing RDF stores and ontologies to Graph Database by uploading via file, strings, or URLs as well as an export in numerous formats and also context management. You can monitor the CPU load and memory usage of Graph Database and run the garbage collector on demand to optimally trigger huge batch operations also provide user management, the creation, and listing of new repositories as well as location and cluster management of graph database.

As of now, we support the connection with three major graph databases

There will be more graph databases added to this list in the future.

You may also find these tools useful

🛠️ Installation


npm i @innotrade/enapso-graphdb-admin --save

Create a connection with graph database

const { EnapsoGraphDBClient } = require('@innotrade/enapso-graphdb-client');
const { EnapsoGraphDBAdmin } = require('@innotrade/enapso-graphdb-admin');

let graphDBEndpoint = new EnapsoGraphDBClient.Endpoint({
    baseURL: 'http://localhost:7200',
    repository: 'Test',
    prefixes: [
        {
            prefix: 'entest',
            iri: 'http://ont.enapso.com/test#'
        }
    ],
    triplestore: 'graphdb',
    version: 9,
    apiType: 'RDF4J'
});

Parameters

ParameterTypeDescriptionValues
baseURL(required)StringPass the URL in which graph database is running.
repository(required)StringPass the name of the repository or database of the graph databases with which you want to create a connection.
prefixes(required)Array of objectsPass the prefix and its IRI as an object which will be used in the SPARQL query to perform crud operations.
triplestore(optional)StringPass the name of the graph database with which you want to create a connection by default it creates a connection with Ontotext GraphDB.('graphdb' , 'stardog' , 'fuseki')
transform(optional)StringPass the type in which you want to show the result of the SPARQL query by default it shows the result in JSON format.('toJSON', 'toCSV' , 'toTSV')
version(optional)NumberPass the version of ontotext graphDB to make the tool compatible with an older version by default it works with the latest version of ontotext graphDB.
apiType(optional)StringPass the type of API which will use for importing ontology in ontotext graphDB by default it uses ontotext graphDB workbench APIs.('workbench', 'RDF4J' )

📋 Features

FeatureDescriptionOntotext GraphDBApache Jena FusekiStardog
LoginAuthenticate against the graph database
QueryTo retrieve the information from graph database using SPARQL query
UpdateTo update the triples in the graph database.
Create RepositoryCreate new repository/database in the graph database.
Delete RepositoryDelete existing repository/database from graph database.
Clear RepositoryRemove all triples from graph database repository/database.
Get RepositoriesGet list of all repsoitory from graph database.
Create UserCreate new user and asign the roles in the graph database.
Get UsersGet list of users from graph database.
Get ResourcesGet list of resources from graph database.
Update UserUpdate existing user roles from graph database.
Assign RoleAssign new roles to the existing user of the graph database.
Remove RoleRemove roles of the existing user of the graph database.
Delete UserDelete existing user of graph database.
Drop SHACL GraphDrop SHACL graph from graph database.
Get ContextsGet all context from graph database repository.
Upload From FileUpload ontology from file in the graph database.
Upload From DataUpoad ontology from data in the graph database.
Download To FileDownload ontology to file from graph database.
Download To TextDownload ontology to text from graph database.
Clear ContextClear specific named graph from graph database repository.
Get QueryGet query from graph database repository.
Get LocationsGet locations from graph database repository.
Perform Garbage CollectionPerform garbage collection in the graph database repository.
Get Saved QueriesGet saved queries from graph database.

Login

Login to authenticate the user against graph database and authorize the user according to his roles:

graphDBEndpoint
    .login('admin', 'root')
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Query

Querying against the graph database

graphDBEndpoint
    .query(
        'select *
where {
    ?class rdf:type owl:Class
    filter(regex(str(?class), "http://ont.enapso.com/test#TestClass", "i")) .
}',
        { transform: 'toJSON' }
    )
    .then((result) => {
        console.log(
            'Read the classes name:\n' + JSON.stringify(result, null, 2)
        );
    })
    .catch((err) => {
        console.log(err);
    });

Update

Updating Triples in graph database

graphDBEndpoint
    .update(
        `insert data {
	   graph <http://ont.enapso.com/test> {
             entest:TestClass rdf:type owl:Class}
           }`
    )
    .then((result) => {
        console.log('inserted a class :\n' + JSON.stringify(result, null, 2));
    })
    .catch((err) => {
        `console.log(err);
    });

Upload From File

Upload an ontology and import it into the graph database repository automatically if the upload was successful. context (graph) and baseIRI parameters are optional :

graphDBEndpoint
    .uploadFromFile({
        filename: '../ontologies/EnapsoTest.owl',
        format: 'application/rdf+xml',
        baseIRI: 'http://ont.enapso.com/test#',
        context: 'http://ont.enapso.com/test'
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Upload From Data

Upload data (rather than a file) and automatically import the data into a graph database repository and context (graph) is an optional parameter:

fsPromises
    .readFile('../ontologies/EnapsoTest.owl', 'utf-8')
    .then((data) => {
        graphDBEndpoint
            .uploadFromData({
                data: data,
                context: 'http://ont.enapso.com/test',
                format: 'application/rdf+xml'
            })
            .then((result) => {
                console.log(result);
            })
            .catch((err) => {
                console.log(err, 'process error here...');
            });
    })
    .catch((err) => {
        console.log(err);
    });

Download To Text

Download a Graph from graph database to a Text Variable. For the available export formats, please refer to the EnapsoGraphDBClient.FORMAT_xxx constants. The context (graph) is optional. If you do not pass a context (graph), the entire repository is exported.

graphDBEndpoint
    .downloadToText({
        format: EnapsoGraphDBClient.FORMAT_TURTLE.type
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Download To File

Download a graph from graph database directly to a Local File. For the available export formats, please refer to the EnapsoGraphDBClient.FORMAT_xxx constants. The context is optional. If you do not pass a context, the entire repository is exported.

let lFormat = EnapsoGraphDBClient.FORMAT_TURTLE;
graphDBEndpoint
    .downloadToFile({
        format: lFormat.type,
        filename:
            '../ontologies/' +
            graphDBEndpoint.getRepository() +
            lFormat.extension
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Perform Garbage Collection

Perform the garbage collection on the server side to release allocated resources: if security is on then the Garbage Collection user role needs to be Administrator else operation is not performed

graphDBEndpoint
    .performGarbageCollection()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Get Resources

Get resource details of the repository current connected to the endpoint:

graphDBEndpoint
    .getResources()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Create User

Create a new user and provide a user with read/write access to certain repositories in a graph database instance: if security is on then for Creating a new User, the user role needs to be Administrator else operation is not performed

graphDBEndpoint
    .createUser({
        authorities: [
            'WRITE_REPO_Test', // Writing excess wrote WRITE_ and in last name of Repository which excess provided like REPO_Test
            'READ_REPO_Test', // Reading excess wrote READ_ and in last name of Repository which excess provided like REPO_Test
            'READ_REPO_EnapsoDotNetProDemo',
            'ROLE_USER' // Role of the user
        ],
        username: 'TestUser2', // Username
        password: 'TestUser2' // Password for the user
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Update User

Update the user's roles (read/write rights) for certain repositories: if security is on then for Updating Existing User, the user role needs to be Administrator else operation is not performed

graphDBEndpoint
    .updateUser({
        authorities: [
            // Writing excess wrote WRITE_ and in the last name of Repository which excess provided like REPO_Test
            'READ_REPO_Test', // Reading excess wrote READ_ and in the last name of Repository which excess provided like REPO_Test
            'WRITE_REPO_EnapsoDotNetProDemo',
            'READ_REPO_EnapsoDotNetProDemo',
            'ROLE_USER' // Role of the user
        ],
        username: 'TestUser' // Username
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Assign Role

Assign new roles to the user of the graph database instance

graphDBEndpoint
    .assignRoles({
        userName: 'ashesh',
        authorities: [
            {
                action: 'READ',
                resource_type: 'db',
                resource: ['Test']
            },
            {
                action: 'WRITE',
                resource_type: 'db',
                resource: ['Test']
            }
        ]
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Remove Role

Remove existing roles of a user in the graph database instance

graphDBEndpoint
    .removeRoles({
        username: 'TestUser',
        authorities: [
            {
                action: 'READ',
                resource_type: 'db',
                resource: ['Test']
            },
            {
                action: 'WRITE',
                resource_type: 'db',
                resource: ['Test']
            }
        ]
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Delete User

Caution! This deletes the user including all assigned authorities (roles)! This operation cannot be undone! Deletes a user from the graph database instance: if security is on then for Deleting User, the user role needs to be Administrator else operation is not performed

graphDBEndpoint
    .deleteUser({
        user: 'TestUser2' // username which you want to delete
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Get Repositories

Get details of all repositories of the graph database repositories operated on the connected host:

graphDBEndpoint
    .getRepositories()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Clear Repository

Caution! This removes ALL triples of the given repository! This operation cannot be undone! The entire repository will be emptied, i.e. all data of this repository will be removed. The repository remains active.

graphDBEndpoint
    .clearRepository()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Get Users

Get all details of all users of a certain graph database instance:

graphDBEndpoint
    .getUsers()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Get Query

Get Query from graph database:

graphDBEndpoint
    .getQuery()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Get Contexts

List all named graphs inside a given repository:

graphDBEndpoint
    .getContexts()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Clear Context

Caution! This removes ALL triples of the given context! This operation cannot be undone! The entire context will be emptied, i.e. all data from this context will be removed. The repository and other contexts remain active.

graphDBEndpoint
    .clearContext('http://ont.enapso.com/test')
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err, 'process error here...');
    });

Get Locations

Get details of all locations which are associated with the connected graph database instance:

graphDBEndpoint
    .getLocations()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Get Saved Queries

Get details of all queries which are saved in a graph database instance:
graphDBEndpoint
    .getSavedQueries()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Create Repository

Create a new repository in the graph database instance, isShacl parameter is optional by default it is false. if security is on then for creating a repository, the user role needs to be Repository Manager else operation is not performed

graphDBEndpoint
    .createRepository({
        id: 'AutomatedTest4',
        title: 'enapso Automated Test Repository',
        location: '',
        isShacl: true
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Delete Repository

Delete a repository in the connected graph database instance: if security is on then for deleting the repository, the user role needs to be Repository Manager else operation is not performed

graphDBEndpoint
    .deleteRepository({
        id: 'AutomatedTest'
    })
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

Drop SHACL Graph

Drop a shacl Shape from graph database to remove all validations:

graphDBEndpoint
    .dropShaclGraph()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });
 

📖 Documentation

View the documentation for further usage examples.

 

🧪 Testing

Tutorial to run the Test suite against the graph database.

 

😎 Contributing

Contributing is more than just coding. You can help the project in many ways, and we will be very happy to accept your contribution to our project.

Details of how you can help the project are described in the CONTRIBUTING.md document.

🧑‍🏫 Contributors

 

💬 Bugs and Feature Requests

Do you have a bug report or a feature request?

Please feel free to add a new issue or write to us in discussion: Any questions and suggestions are welcome.

 

🧾 License

This project is licensed under the Apache 2.0 License. See the LICENSE file for more details.

Keywords

FAQs

Last updated on 31 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc