Skip to content

Conversation

@alverdal
Copy link

@alverdal alverdal commented Oct 9, 2023

Explicit export of api types to allow for a more flexible use of rule definitions and this library.
Currently, only RuleEngine is exported in the dist/index.d.ts but it would be nice to have the other types exported as well.

For instance, to be able to define rules as re-useable functions and defining rules as separate variable.

const rules: Rule[] = [
   myReuseableFunction(api, fact)
  ,{
    name: 'ageOfDog',
    priority: 1,
    condition: (api: API, fact: Fact) => {
      api.when(fact.age > 5)
    },
    consequence: (R: API, fact: Fact) => {
      fact.result = false
      fact.reason = 'The dog is older than 5 years.'
      R.stop()
    }
  }
]

eng.register(rules)

@miccheng
Copy link

@mithunsatheesh Would you want to merge this in?

@mithunsatheesh mithunsatheesh merged commit 1277067 into mithunsatheesh:main Aug 10, 2025
@mithunsatheesh
Copy link
Owner

done

@mithunsatheesh
Copy link
Owner

mithunsatheesh commented Aug 10, 2025

closes #143

@mithunsatheesh
Copy link
Owner

mithunsatheesh commented Aug 10, 2025

closes #142

@miccheng
Copy link

Thanks for doing this! And releasing a new version. Really helped reduce the TypeScript issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants