@rkmodules/rules 0.0.79 → 0.0.81

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.
@@ -34,7 +34,8 @@ export declare class Engine {
34
34
  private listeners;
35
35
  private cache;
36
36
  private cacheMiss;
37
- constructor(morePrimitives?: Record<string, PrimitiveFunction>);
37
+ env: Record<string, any>;
38
+ constructor(morePrimitives?: Record<string, PrimitiveFunction>, env?: Record<string, any>);
38
39
  private checkCache;
39
40
  private runGraph;
40
41
  /**
@@ -1,3 +1,4 @@
1
+ import { Engine } from ".";
1
2
  import { Tree } from "../DataTree";
2
3
  /**
3
4
  * type definition of rule inputs and outputs
@@ -32,7 +33,7 @@ export type PrimitiveFunction = {
32
33
  params?: Record<string, VarDef>;
33
34
  inputs?: Record<string, VarDef>;
34
35
  outputs?: Record<string, VarDef>;
35
- impl: (inputs: RecOfTrees, params: Record<string, any>) => Promise<RecOfTrees>;
36
+ impl: (inputs: RecOfTrees, params: Record<string, any>, engine: Engine) => Promise<RecOfTrees>;
36
37
  mount?: (trigger: () => void) => (() => void) | void;
37
38
  };
38
39
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rkmodules/rules",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
package/readme.md CHANGED
@@ -45,7 +45,32 @@ We get back to function definitions later
45
45
 
46
46
  ## editor
47
47
 
48
- `<Flow>`
48
+ - Create an instance of the rules engine
49
+ - create a function to work with
50
+ - use the `<Flow>` component to create the editor
51
+
52
+ ```tsx
53
+ const engine = new Engine({
54
+ // map of custom rules
55
+ });
56
+
57
+ const emptyFunction: GraphedFunction = {
58
+ name: "test",
59
+ body: {},
60
+ outputs: {
61
+ documents: "",
62
+ },
63
+ };
64
+
65
+ export default function MyComponent() {
66
+ const [fn, setFn] = React.useState(emptyFunction);
67
+ return (
68
+ <div>
69
+ <Flow function={fn} engine={engine} onChange={setFn} />
70
+ <div>
71
+ );
72
+ }
73
+ ```
49
74
 
50
75
  TODO:
51
76