@nodora/js 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -9,9 +9,9 @@ export type EvaluationResult = {
9
9
  };
10
10
 
11
11
  /**
12
- * A compiled Nodora program, as returned by compile().
12
+ * A compiled Nodora ruleset, as returned by compile().
13
13
  */
14
- export type Program = Record<string, any>;
14
+ export type Ruleset = Record<string, any>;
15
15
 
16
16
  export interface Evaluator {
17
17
  /**
@@ -54,18 +54,18 @@ export interface Evaluator {
54
54
 
55
55
  /**
56
56
  * Create a new evaluator
57
- * @param program - The compiled program, either as the object returned by
57
+ * @param ruleset - The compiled ruleset, either as the object returned by
58
58
  * compile() or as a JSON string
59
59
  * @returns Promise resolving to an Evaluator instance
60
60
  */
61
- export function createEvaluator(program: Program | string): Promise<Evaluator>;
61
+ export function createEvaluator(ruleset: Ruleset | string): Promise<Evaluator>;
62
62
 
63
63
  /**
64
- * Compile a rule
64
+ * Compile a ruleset
65
65
  * @param src - Source code
66
- * @returns Promise resolving to the compiled program
66
+ * @returns Promise resolving to the compiled ruleset
67
67
  */
68
- export function compile(src: string): Promise<Program>;
68
+ export function compile(src: string): Promise<Ruleset>;
69
69
 
70
70
  type BaseType = "string" | "number" | "bool" | "object" | "any";
71
71
  type ArrayType = `array<${string}>`;
package/lib/index.js CHANGED
@@ -67,15 +67,15 @@ class Evaluator {
67
67
  }
68
68
  }
69
69
 
70
- async function createEvaluator(program) {
70
+ async function createEvaluator(ruleset) {
71
71
  if (!wasmInstance) {
72
72
  await init();
73
73
  }
74
74
 
75
- const programJSON =
76
- typeof program === "string" ? program : JSON.stringify(program);
75
+ const rulesetJSON =
76
+ typeof ruleset === "string" ? ruleset : JSON.stringify(ruleset);
77
77
 
78
- const result = globalThis.__nodoraCreateEvaluator(programJSON);
78
+ const result = globalThis.__nodoraCreateEvaluator(rulesetJSON);
79
79
  if (result.error) {
80
80
  throw new Error(result.error);
81
81
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodora/js",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "JS bindings for Nodora rule engine",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",