@lemmabase/lemma-engine 0.9.4 → 0.9.5
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 +4 -4
- package/lemma.bindings.d.ts +2 -2
- package/lemma.bindings.js +7 -7
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lemmabase/lemma-engine
|
|
2
2
|
|
|
3
|
-
> [Lemma](https://github.com/lemma/lemma) is a declarative language for business rules. **This package is the Lemma engine for JavaScript and TypeScript
|
|
3
|
+
> [Lemma](https://github.com/lemma/lemma) is a declarative language for business rules. **This package is the Lemma engine for JavaScript and TypeScript**: browser, Node, Bun, Deno, Cloudflare Workers, Vercel Edge, etc.
|
|
4
4
|
|
|
5
5
|
Pricing tiers, tax brackets, leave entitlement, eligibility checks, discount stacks: the rules that change, that auditors ask about, that legal writes in PDFs and engineers re-implement in operational code... Lemma is a language built specifically for your business rules. It is readable by stakeholders, executable anywhere, and impossible to drift out of sync.
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ const response = engine.run({ spec: 'pricing', data: { quantity: 50, is_vip: fal
|
|
|
35
35
|
// response.results.total → 800 eur
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
The `Response` carries every rule's value (or `veto` if no result could be computed). When inputs are still unbound, that rule includes `missing_data` (`string[]` input keys). Types, prefilled literals, and suggestions are on `engine.show(...)` (`Show.data`) only
|
|
38
|
+
The `Response` carries every rule's value (or `veto` if no result could be computed). When inputs are still unbound, that rule includes `missing_data` (`string[]` input keys). Types, prefilled literals, and suggestions are on `engine.show(...)` (`Show.data`) only, not on the evaluate response.
|
|
39
39
|
|
|
40
40
|
## Why use it from JavaScript?
|
|
41
41
|
|
|
@@ -62,7 +62,7 @@ const engine = await Lemma();
|
|
|
62
62
|
|
|
63
63
|
`Lemma()` initializes the engine once and returns an `Engine`. Serve over **http(s)**, not `file://`. For manual control: `init()` then `new Engine()`.
|
|
64
64
|
|
|
65
|
-
If your bundler emits IIFE, can't resolve `import.meta.url`, or refuses to ship the engine module as a separate asset, use the inlined entry
|
|
65
|
+
If your bundler emits IIFE, can't resolve `import.meta.url`, or refuses to ship the engine module as a separate asset, use the inlined entry. Everything ships in one JS bundle:
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
68
|
import { Lemma } from '@lemmabase/lemma-engine/iife';
|
|
@@ -145,7 +145,7 @@ Lemma is pre-1.0. The JavaScript API is stable for most use cases, but breaking
|
|
|
145
145
|
|
|
146
146
|
### Runtime traps (internal bugs)
|
|
147
147
|
|
|
148
|
-
An internal invariant violation (a bug in the engine) traps the runtime. The call throws a `RuntimeError` which you can catch with `try/catch`, but the loaded module is poisoned
|
|
148
|
+
An internal invariant violation (a bug in the engine) traps the runtime. The call throws a `RuntimeError` which you can catch with `try/catch`, but the loaded module is poisoned: constructing a new `Engine()` from the same initialization is not safe. To recover, call `init()` again or run the engine in a Web Worker and respawn the worker on trap. Domain failures (invalid specs, bad data, impossible rules) are reported as `EngineError[]` or vetoes and never cause traps.
|
|
149
149
|
|
|
150
150
|
## Related
|
|
151
151
|
|
package/lemma.bindings.d.ts
CHANGED
|
@@ -148,9 +148,9 @@ export interface InitOutput {
|
|
|
148
148
|
readonly engine_source: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
149
149
|
readonly engine_update: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
150
150
|
readonly engine_withLimits: (a: number, b: number) => void;
|
|
151
|
-
readonly
|
|
151
|
+
readonly __wasm_bindgen_func_elem_12529: (a: number, b: number, c: number, d: number) => void;
|
|
152
152
|
readonly __wasm_bindgen_func_elem_2733: (a: number, b: number, c: number, d: number) => void;
|
|
153
|
-
readonly
|
|
153
|
+
readonly __wasm_bindgen_func_elem_12537: (a: number, b: number, c: number, d: number) => void;
|
|
154
154
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
155
155
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
156
156
|
readonly __wbindgen_export3: (a: number) => void;
|
package/lemma.bindings.js
CHANGED
|
@@ -770,7 +770,7 @@ function __wbg_get_imports() {
|
|
|
770
770
|
const a = state0.a;
|
|
771
771
|
state0.a = 0;
|
|
772
772
|
try {
|
|
773
|
-
return
|
|
773
|
+
return __wasm_bindgen_func_elem_12537(a, state0.b, arg0, arg1);
|
|
774
774
|
} finally {
|
|
775
775
|
state0.a = a;
|
|
776
776
|
}
|
|
@@ -929,8 +929,8 @@ function __wbg_get_imports() {
|
|
|
929
929
|
return addHeapObject(ret);
|
|
930
930
|
},
|
|
931
931
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
932
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
933
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
932
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1414, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
933
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12529);
|
|
934
934
|
return addHeapObject(ret);
|
|
935
935
|
},
|
|
936
936
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
@@ -972,10 +972,10 @@ function __wbg_get_imports() {
|
|
|
972
972
|
};
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
-
function
|
|
975
|
+
function __wasm_bindgen_func_elem_12529(arg0, arg1, arg2) {
|
|
976
976
|
try {
|
|
977
977
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
978
|
-
wasm.
|
|
978
|
+
wasm.__wasm_bindgen_func_elem_12529(retptr, arg0, arg1, addHeapObject(arg2));
|
|
979
979
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
980
980
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
981
981
|
if (r1) {
|
|
@@ -1000,8 +1000,8 @@ function __wasm_bindgen_func_elem_2733(arg0, arg1, arg2) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
|
-
function
|
|
1004
|
-
wasm.
|
|
1003
|
+
function __wasm_bindgen_func_elem_12537(arg0, arg1, arg2, arg3) {
|
|
1004
|
+
wasm.__wasm_bindgen_func_elem_12537(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1005
1005
|
}
|
|
1006
1006
|
|
|
1007
1007
|
|