This package has been deprecated

Author message:

This package is deprecated and no longer maintained. Please use our new library https://www.npmjs.com/package/@decisionrules/decisionrules

@decisionrules/decisionrules-js
TypeScript icon, indicating that this package has built-in type declarations

3.0.4 • Public • Published

Summary

Decisionrules.io library that allows you to integrate DecisionRules Solver and Management API to you application as easily as possible. SDK allow you to solve all rule types that are available, CRUD operations on all rule types, rules status management and rule tags management.

VERSION 3 IS NEW MAJOR VERSION OF THIS SDK AND IT IS STRONGLY RECOMMENDED, DUE TO DEPRECATION OF OLDER VERSIONS.

Installation

You can simply integrate SDK to your project via NPM package manager.

Defining Custom domain

Custom domain is special class that is designed for those who uses DecisionRules in private cloud or as on-premise. Class takes up to 3 arguments.

Domain argument is name of desired domain, protocol is HTTP or HTTPS and port is TCP/IP port. If port is not defined in the class constructor it is set to default value by protocol value, 80 for HTTP and 443 for HTTPS.

let customDomain = new CustomDomain("api.mydomain.com", Protocol.HTTPS, 443); 

Using Solver API

Solver class takes up to 2 arguments that are api key(can be generated on dashboard), custom domain object. Class exposes two async methods: SolveRule and SolveRuleFlow.

public async amazingRuleSolver(): Promise<any> 
{
	let solver = new Solver("myApiKey");
	
	let itemId = "id of a rule that is being solved";
	let itemId2 = "id of a ruleflow that is being solved";
	
	var resultForRule = await solver.SolveRule(itemId, data);
	var resultForRuleFlow = await solver.SolverRuleFlow(itemId2, data);
	
	return resultForRule;
}

Using Management API

Management class takes on argument, management api key. Class exposes number of methods listed below.

  • getRule - get rule by itemId and version*
  • createRule - create rule by spaceId and ruleData
  • updateRule - updates rule by itemId, newRuleData and version*
  • deleteRule - deletes rule by itemId and version
  • getSpaceItems - get space items that belongs to management api key
  • getRuleFlow - get rule by itemId and version*
  • createRuleFlow - create ruleflow in space that belongs to management api key
  • updateRuleFlow - updates ruleflowby itemId, newRuleflowData and version*
  • deleteRuleFlow - deletes ruleflow by itemId and version
  • exportRuleFlow - exports ruleflow by itemId and version*
  • importRuleFlow - import ruleflow as a new ruleflow or new version of existing ruleflow or override existing ruleflow.
  • changeRuleStatus - changes rule status
  • changeRuleFlowStatus - changes ruleflow status
  • getRulesByTags - gets rule by tag.
  • updateTags - update tags on rule or ruleflow
  • deleteTags - delete tags on rule or ruleflow

* = optional argument

Example usage

public async manageRules(): Promise<any>
{
	var manager = new Management("management_key");
	
	var itemId = "some rule or ruleflow id"

	return await manager.getRule(itemId);
} 

Package Sidebar

Install

npm i @decisionrules/decisionrules-js

Weekly Downloads

93

Version

3.0.4

License

MIT

Unpacked Size

78 kB

Total Files

52

Last publish

Collaborators

  • decisionrules