1.5.5 โ€ข Published 1 month ago

@innotrade/enapso-graphdb-admin v1.5.5

Weekly downloads
15
License
Apache-2.0
Repository
github
Last release
1 month ago

ENAPSO

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 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...');
    });

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);
    });

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 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 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 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 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 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 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 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 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 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 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);
    });

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 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);
    });

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 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 from graph database:

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

List all named graphs inside a given repository:

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

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 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);
    });
graphDBEndpoint
    .getSavedQueries()
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    });

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

1.5.5

1 month ago

1.5.4

5 months ago

1.5.3

7 months ago

1.5.2

10 months ago

1.5.1

10 months ago

1.4.26

11 months ago

1.4.25

11 months ago

1.5.0

11 months ago

1.4.22

1 year ago

1.4.21

1 year ago

1.4.24

1 year ago

1.4.23

1 year ago

1.4.20

1 year ago

1.4.17

1 year ago

1.4.16

1 year ago

1.4.19

1 year ago

1.4.18

1 year ago

1.4.9

2 years ago

1.4.11

2 years ago

1.4.8

2 years ago

1.4.10

2 years ago

1.4.13

2 years ago

1.4.12

2 years ago

1.4.15

2 years ago

1.4.14

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.7

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago