exframe-rules

2.0.1 • Public • Published

exframe-rules

A lightweight module to handle fetching and evaluating rules

Constructor arguments:

  • db object The database object
  • cacheTimeout number (optional, default 60) The time in seconds to cache the rules

evaluate() arguments:

  • context object The context object
  • rule object The rule object
    • companyCode string
    • state string
    • product string
    • code string
  • document object The document object

Based on the 'condition' of the fetch rule, returns either the default 'onTrue' or 'onFalse' output value. See the test/index.test.js file for examples.

Example usage:

import { Rules } from 'exframe-rules';
const rules = new Rules(db);

const { companyCode, state, product } = document.csp;
const result = await rules.evaluate(
    context,
    {
        companyCode,
        state,
        product,
        code: shortRated
    },
    document
);

Readme

Keywords

none

Package Sidebar

Install

npm i exframe-rules

Weekly Downloads

69

Version

2.0.1

License

ISC

Unpacked Size

12.8 kB

Total Files

10

Last publish

Collaborators

  • exzeodevops