Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript #388

Open
wants to merge 3 commits into
base: v8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Deploy Package

on:
push:
branches: [ master, v6, v8 ]
branches: [master, v6, v8]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Node.js CI

on:
pull_request:
branches: [ master, v6, v8 ]
branches: [master, v6, v8]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion examples/01-hello-world.mts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function start() {
// engine.run() evaluates the rule using the facts provided
const { events } = await engine.run(facts);

events.map((event) => console.log(event.params!.data.green));
events.map((event) => console.log(`${event.params!.data}`.green));
}

start();
Expand Down
2 changes: 1 addition & 1 deletion examples/02-nested-boolean-logic.mts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function start() {

const { events } = await engine.run(facts);

events.map((event) => console.log(event.params!.message.red));
events.map((event) => console.log(`${event.params!.message}`.red));
}
start();
/*
Expand Down
19 changes: 13 additions & 6 deletions examples/09-rule-results.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
* DEBUG=json-rules-engine node ./examples/09-rule-results.js
*/
import "colors";
import { Engine, NestedCondition, RuleResult } from "json-rules-engine";
import {
Engine,
NestedCondition,

Check failure on line 13 in examples/09-rule-results.mts

View workflow job for this annotation

GitHub Actions / build (18.x)

'NestedCondition' is defined but never used

Check failure on line 13 in examples/09-rule-results.mts

View workflow job for this annotation

GitHub Actions / build (20.x)

'NestedCondition' is defined but never used

Check failure on line 13 in examples/09-rule-results.mts

View workflow job for this annotation

GitHub Actions / build (22.x)

'NestedCondition' is defined but never used
NestedConditionResult,
RuleResult,
} from "json-rules-engine";

async function start() {
/**
Expand Down Expand Up @@ -48,14 +53,16 @@
return console.log(`${message}`.green);
}
// if rule failed, iterate over each failed condition to determine why the student didn't qualify for athletics honor roll
const detail = (ruleResult.conditions as { all: NestedCondition[] }).all
.filter((condition) => !(condition as { result?: boolean }).result)
const detail = (
ruleResult.conditions as { all: NestedConditionResult[] }
).all
.filter(({ result }) => !result)
.map((condition) => {
switch ((condition as { operator?: string }).operator) {
switch (condition.operator) {
case "equal":
return `was not an ${(condition as { fact?: string }).fact}`;
return `was not an ${condition.fact}`;
case "greaterThanInclusive":
return `${(condition as { fact: string }).fact} of ${(condition as { factResult?: unknown }).factResult} was too low`;
return `${condition.fact} of ${condition.factResult} was too low`;
default:
return "";
}
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Rules Engine expressed in simple json",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "types/index.d.ts",
"types": "dist/index.d.ts",
"type": "module",
"engines": {
"node": ">=18.0.0"
Expand Down Expand Up @@ -40,6 +40,7 @@
"homepage": "https://github.com/cachecontrol/json-rules-engine",
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/node": "^22.8.2",
"eslint": "^9.13.0",
"globals": "^15.11.0",
"lodash": "4.17.21",
Expand All @@ -52,8 +53,6 @@
"vitest": "^2.1.3"
},
"dependencies": {
"clone": "^2.1.2",
"eventemitter2": "^6.4.4",
"hash-it": "^6.0.0",
"jsonpath-plus": "^10.0.0"
}
Expand Down
200 changes: 0 additions & 200 deletions src/almanac.mjs

This file was deleted.

Loading
Loading