@gorules/zen-engine 0.17.0 → 0.19.1
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/README.md +2 -0
- package/index.d.ts +11 -2
- package/index.js +2 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ import fs from 'fs/promises';
|
|
|
40
40
|
|
|
41
41
|
const decision = engine.createDecision(content);
|
|
42
42
|
const result = await decision.evaluate({ input: 15 });
|
|
43
|
+
engine.dispose();
|
|
43
44
|
})();
|
|
44
45
|
```
|
|
45
46
|
|
|
@@ -58,6 +59,7 @@ const loader = async (key: string) => fs.readFile(path.join(testDataRoot, key))(
|
|
|
58
59
|
const engine = new ZenEngine({ loader });
|
|
59
60
|
|
|
60
61
|
const result = await engine.evaluate('jdm_graph1.json', { input: 5 });
|
|
62
|
+
engine.dispose();
|
|
61
63
|
})();
|
|
62
64
|
```
|
|
63
65
|
|
package/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ZenEvaluateOptions {
|
|
|
8
8
|
trace?: boolean
|
|
9
9
|
}
|
|
10
10
|
export interface ZenEngineOptions {
|
|
11
|
-
loader?: (key: string) => Promise<Buffer>
|
|
11
|
+
loader?: (key: string) => Promise<Buffer | ZenDecisionContent>
|
|
12
12
|
customHandler?: (request: ZenEngineHandlerRequest) => Promise<ZenEngineHandlerResponse>
|
|
13
13
|
}
|
|
14
14
|
export function evaluateExpressionSync(expression: string, context?: any | undefined | null): any
|
|
@@ -40,6 +40,10 @@ export interface DecisionNode {
|
|
|
40
40
|
kind: string
|
|
41
41
|
config: any
|
|
42
42
|
}
|
|
43
|
+
export class ZenDecisionContent {
|
|
44
|
+
constructor(content: Buffer | object)
|
|
45
|
+
toBuffer(): Buffer
|
|
46
|
+
}
|
|
43
47
|
export class ZenDecision {
|
|
44
48
|
constructor()
|
|
45
49
|
evaluate(context: any, opts?: ZenEvaluateOptions | undefined | null): Promise<ZenEngineResponse>
|
|
@@ -48,8 +52,13 @@ export class ZenDecision {
|
|
|
48
52
|
export class ZenEngine {
|
|
49
53
|
constructor(options?: ZenEngineOptions | undefined | null)
|
|
50
54
|
evaluate(key: string, context: any, opts?: ZenEvaluateOptions | undefined | null): Promise<ZenEngineResponse>
|
|
51
|
-
createDecision(content: Buffer): ZenDecision
|
|
55
|
+
createDecision(content: ZenDecisionContent | Buffer | object): ZenDecision
|
|
52
56
|
getDecision(key: string): Promise<ZenDecision>
|
|
57
|
+
/**
|
|
58
|
+
* Function used to dispose memory allocated for loaders
|
|
59
|
+
* In the future, it will likely be removed and made automatic
|
|
60
|
+
*/
|
|
61
|
+
dispose(): void
|
|
53
62
|
}
|
|
54
63
|
export class ZenEngineHandlerRequest {
|
|
55
64
|
input: any
|
package/index.js
CHANGED
|
@@ -281,8 +281,9 @@ if (!nativeBinding) {
|
|
|
281
281
|
throw new Error(`Failed to load native binding`)
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
const { ZenDecision, ZenEngine, evaluateExpressionSync, evaluateUnaryExpressionSync, renderTemplateSync, evaluateExpression, evaluateUnaryExpression, renderTemplate, ZenEngineHandlerRequest } = nativeBinding
|
|
284
|
+
const { ZenDecisionContent, ZenDecision, ZenEngine, evaluateExpressionSync, evaluateUnaryExpressionSync, renderTemplateSync, evaluateExpression, evaluateUnaryExpression, renderTemplate, ZenEngineHandlerRequest } = nativeBinding
|
|
285
285
|
|
|
286
|
+
module.exports.ZenDecisionContent = ZenDecisionContent
|
|
286
287
|
module.exports.ZenDecision = ZenDecision
|
|
287
288
|
module.exports.ZenEngine = ZenEngine
|
|
288
289
|
module.exports.evaluateExpressionSync = evaluateExpressionSync
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gorules/zen-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"prepublishOnly": "napi prepublish",
|
|
80
80
|
"version": "napi version"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "b876578312816e65923805af506fbf8824d625f6",
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@gorules/zen-engine-darwin-x64": "0.
|
|
85
|
-
"@gorules/zen-engine-linux-x64-gnu": "0.
|
|
86
|
-
"@gorules/zen-engine-win32-x64-msvc": "0.
|
|
87
|
-
"@gorules/zen-engine-linux-arm64-gnu": "0.
|
|
88
|
-
"@gorules/zen-engine-darwin-arm64": "0.
|
|
84
|
+
"@gorules/zen-engine-darwin-x64": "0.19.1",
|
|
85
|
+
"@gorules/zen-engine-linux-x64-gnu": "0.19.1",
|
|
86
|
+
"@gorules/zen-engine-win32-x64-msvc": "0.19.1",
|
|
87
|
+
"@gorules/zen-engine-linux-arm64-gnu": "0.19.1",
|
|
88
|
+
"@gorules/zen-engine-darwin-arm64": "0.19.1"
|
|
89
89
|
}
|
|
90
90
|
}
|