governify-agreement-analyzer
v0.6.6
Published
Governify Agreement Analyzer
Downloads
8
Readme
Governify Agreement Analyzer
This is a Node.js API REST to analyze agreements defined by following the iAgree Specification.
Governify Agreement Analyzer provides some features, such as:
- An API for programmers to peform agreement analysis operations.
- An API REST to peform agreement analysis operations over a service.
Governify Agreement Analyzer executes all CSP by using the Reasoner tool defined on governify-csp-tools project, which in turn executes the CSP based on MiniZinc language.
Governify Agreement Analyzer has been developed on TypeScript and transpiled to JavaScript in order to be executed as a Node.js module. Also, it has been developed by following the project-template-nodejs development guidelines.
Install
$ npm install governify-agreement-analyzer
Basic usage
You can easily use this library in your project:
// Import
var AgreementAnalyzer = require("governify-agreement-analyzer");
// Configure analyzer
var config = {
agreement: {
file: "agreement.yaml"
},
reasoner: {
type: "api",
folder: "csp_files",
api: {
version: "v2",
server: "https://minizinc.modules.designer.governify.io/module-minizinc",
operationPath: "models/csp/operations/execute"
}
}
};
// Create an Analyzer instance
var analyzer = new AgreementAnalyzer(config);
// Execute an analysis operation
analyzer.isConsistent(function (err, sol) {
if (err) {
// manage error
console.log(err);
} else {
console.log(sol);
}
});
or deploy the analyzer as an API REST service:
// Import Agreement Analyzer API
var AgreementAnalyzerServer = require("governify-agreement-analyzer").api;
var api = new AgreementAnalyzerServer();
var app = require("connect")();
// Start API
api.initialize(app);
Once you deploy the API REST, you can now send a POST request over http://localhost:8080/api/v1/analysis/isConsistent
with the configuration of Analyzer.
You can download agreement.yaml
here.
Follow the analyzer configuration for more details.
Analyzer configuration
An example:
var configuration = {
"agreement": {
"file": "agreement.yaml" // use 'url' property for remote agreements
},
"reasoner": {
"type": "local",
"folder": "csp_files"
}
}
Please, consider:
- Reasoner can be configured for local, remote or docker execution. Please, take a look at reasoner documentation to know which are the requirements to run reasoner in each environment.
- Use
agreement.file
property to define use an local agreement file located in your project. You can also useagreement.url
to define a remote agreement file.
The JSON schema associated to analyzer configuration:
---
type: 'object'
properties:
agreement:
type: 'object'
properties:
file:
type: 'string'
url:
type: 'string'
content:
type: 'object'
reasoner:
# Reasoner configuration of governify-csp-tools project
type: 'object'
properties:
type:
enum:
- 'local'
- 'api'
- 'docker'
folder:
type: 'string'
api:
type: 'object'
properties:
version:
type: 'string'
server:
type: 'string'
operationPath:
type: 'string'
required:
- 'type'
- 'folder'
Latest release
The version 0.6.6 is the latest stable version of governify-agreement-analyzer component. see release note for details.
For running:
- Download latest version from 0.6.6