@lemmabase/lemma-engine 0.9.4 → 0.9.6
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 +5 -5
- package/lemma.bindings.d.ts +3 -3
- package/lemma.bindings.js +10 -10
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +3 -3
- 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
|
|
|
@@ -8,7 +8,7 @@ Pricing tiers, tax brackets, leave entitlement, eligibility checks, discount sta
|
|
|
8
8
|
spec pricing 2026-01-01
|
|
9
9
|
|
|
10
10
|
data money: measure
|
|
11
|
-
-> unit eur 1.00
|
|
11
|
+
-> unit eur: 1.00
|
|
12
12
|
-> decimals 2
|
|
13
13
|
|
|
14
14
|
data quantity : number
|
|
@@ -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
|
|
152
|
-
readonly
|
|
153
|
-
readonly
|
|
151
|
+
readonly __wasm_bindgen_func_elem_12566: (a: number, b: number, c: number, d: number) => void;
|
|
152
|
+
readonly __wasm_bindgen_func_elem_2732: (a: number, b: number, c: number, d: number) => void;
|
|
153
|
+
readonly __wasm_bindgen_func_elem_12574: (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_12574(a, state0.b, arg0, arg1);
|
|
774
774
|
} finally {
|
|
775
775
|
state0.a = a;
|
|
776
776
|
}
|
|
@@ -929,13 +929,13 @@ 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: 1415, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
933
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12566);
|
|
934
934
|
return addHeapObject(ret);
|
|
935
935
|
},
|
|
936
936
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
937
937
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IteratorResult<any>")], shim_idx: 7, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
938
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
938
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2732);
|
|
939
939
|
return addHeapObject(ret);
|
|
940
940
|
},
|
|
941
941
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -972,10 +972,10 @@ function __wbg_get_imports() {
|
|
|
972
972
|
};
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
-
function
|
|
975
|
+
function __wasm_bindgen_func_elem_12566(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_12566(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) {
|
|
@@ -986,10 +986,10 @@ function __wasm_bindgen_func_elem_12532(arg0, arg1, arg2) {
|
|
|
986
986
|
}
|
|
987
987
|
}
|
|
988
988
|
|
|
989
|
-
function
|
|
989
|
+
function __wasm_bindgen_func_elem_2732(arg0, arg1, arg2) {
|
|
990
990
|
try {
|
|
991
991
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
992
|
-
wasm.
|
|
992
|
+
wasm.__wasm_bindgen_func_elem_2732(retptr, arg0, arg1, addHeapObject(arg2));
|
|
993
993
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
994
994
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
995
995
|
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_12574(arg0, arg1, arg2, arg3) {
|
|
1004
|
+
wasm.__wasm_bindgen_func_elem_12574(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1005
1005
|
}
|
|
1006
1006
|
|
|
1007
1007
|
|