@rkmodules/rules 0.0.156 → 0.0.157
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/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rkmodules/rules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.157",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
|
-
"module": "dist/index.esm.
|
|
5
|
+
"module": "dist/index.esm.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"files": [
|
|
8
|
-
"dist/index.esm.
|
|
9
|
+
"dist/index.esm.mjs",
|
|
9
10
|
"dist/index.cjs.js",
|
|
10
|
-
"dist/index.esm.
|
|
11
|
+
"dist/index.esm.mjs.map",
|
|
11
12
|
"dist/index.cjs.js.map",
|
|
12
13
|
"dist/index.d.ts",
|
|
13
14
|
"dist/index.esm.css",
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
],
|
|
18
19
|
"exports": {
|
|
19
20
|
".": {
|
|
20
|
-
"import": "./dist/index.esm.
|
|
21
|
+
"import": "./dist/index.esm.mjs",
|
|
21
22
|
"require": "./dist/index.cjs.js",
|
|
22
23
|
"types": "./dist/index.d.ts"
|
|
23
24
|
},
|
package/readme.md
CHANGED
|
@@ -15,6 +15,8 @@ A function definition is just a json object. It can be assembled together via co
|
|
|
15
15
|
```ts
|
|
16
16
|
const testFunction: GraphedFunction = {
|
|
17
17
|
name: "test",
|
|
18
|
+
label: "optional label",
|
|
19
|
+
description: "optional description",
|
|
18
20
|
body: {
|
|
19
21
|
myVal: {
|
|
20
22
|
name: "value",
|
|
@@ -32,12 +34,20 @@ const testFunction: GraphedFunction = {
|
|
|
32
34
|
};
|
|
33
35
|
```
|
|
34
36
|
|
|
37
|
+
### Inputs, params and outputs
|
|
38
|
+
|
|
39
|
+
A function may also define `params`, `inputs` and `outputs` to indicate how to call the function and what it returns. This allows to create custom functions and to use them in others
|
|
40
|
+
|
|
41
|
+
## Specifying primitives
|
|
42
|
+
|
|
43
|
+
A primitive is a function definition that also had code
|
|
44
|
+
|
|
35
45
|
We get back to function definitions later
|
|
36
46
|
|
|
37
47
|
## Running the function
|
|
38
48
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
49
|
+
- build all the custom functions
|
|
50
|
+
- run the one you need
|
|
41
51
|
|
|
42
52
|
## use in react
|
|
43
53
|
|
|
@@ -45,9 +55,9 @@ We get back to function definitions later
|
|
|
45
55
|
|
|
46
56
|
## editor
|
|
47
57
|
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
58
|
+
- Create an instance of the rules engine
|
|
59
|
+
- create a function to work with
|
|
60
|
+
- use the `<Flow>` component to create the editor
|
|
51
61
|
|
|
52
62
|
```tsx
|
|
53
63
|
const engine = new Engine({
|
|
@@ -74,33 +84,33 @@ export default function MyComponent() {
|
|
|
74
84
|
|
|
75
85
|
TODO:
|
|
76
86
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
87
|
+
- [ ] filtering of lists
|
|
88
|
+
- document grasshopper nodes
|
|
89
|
+
- build them
|
|
90
|
+
- [ ] set value
|
|
91
|
+
- [ ] inspection
|
|
92
|
+
- run time
|
|
93
|
+
- running flag
|
|
94
|
+
- intermediate results
|
|
85
95
|
|
|
86
96
|
Components / functions
|
|
87
97
|
|
|
88
98
|
List
|
|
89
99
|
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
100
|
+
- [x] listItem
|
|
101
|
+
- [x] listLength
|
|
102
|
+
- [x] graftTree
|
|
103
|
+
- [x] trimTree
|
|
94
104
|
|
|
95
105
|
Math
|
|
96
106
|
|
|
97
|
-
-
|
|
98
|
-
-
|
|
107
|
+
- [x] lessThan
|
|
108
|
+
- [x] greaterThan
|
|
99
109
|
|
|
100
110
|
Text
|
|
101
111
|
|
|
102
|
-
-
|
|
103
|
-
-
|
|
112
|
+
- formatting
|
|
113
|
+
- text replacement
|
|
104
114
|
|
|
105
115
|
grasshopper investigation
|
|
106
116
|
|
|
@@ -110,31 +120,30 @@ value
|
|
|
110
120
|
|
|
111
121
|
in React context
|
|
112
122
|
|
|
113
|
-
-
|
|
123
|
+
- use useFunction. This will build the function, mount it if needed and provides a run function.
|
|
114
124
|
|
|
115
125
|
in Vanilla context
|
|
116
126
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
127
|
+
- use engine.build(fn) to build the function
|
|
128
|
+
- use engine.mount(fn) to mount the function (if it has a mount function)
|
|
129
|
+
- use engine.run(fn, inputs) to run the function
|
|
120
130
|
|
|
121
131
|
# considerations
|
|
122
132
|
|
|
123
133
|
For Supa Lipu we have quite a lot of functions that need to be called on various events
|
|
124
134
|
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
- in useObjectMutation, we fire an event such that mounted eventlisteners can react
|
|
135
|
+
- when propobjects are updated / created / deleted.
|
|
136
|
+
- currently, each propobject has its own engine and 1 single rule. This is fired when the object is mutated
|
|
137
|
+
- all functions need to be propobjects as well, then referenced in various places
|
|
138
|
+
- the engine needs to be global, so that functions can reference each other
|
|
139
|
+
- for these references, we need propobject refs, to that dependency functions are loaded
|
|
140
|
+
- in useObjectMutation, we fire an event such that mounted eventlisteners can react
|
|
132
141
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
142
|
+
- we need deep references. On change, oldProps and changedProps are passed in as an object. So we need
|
|
143
|
+
- primitives to getValue and setValue
|
|
144
|
+
- [x] reference strings that can directly reference deeper objects to eliminate the need for getValue
|
|
145
|
+
- [x] also need to think about data tree handling for outputs
|
|
137
146
|
|
|
138
147
|
# Entries
|
|
139
148
|
|
|
140
|
-
-
|
|
149
|
+
- in finance I had filterLine(on, match) function that filters return a boolean if any of the lines match. This is a hardcoded solition, which is ok for finance. But we might come up with something more generic
|