@lemmabase/lemma-engine 0.8.16 → 0.8.17
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 -2
- package/lemma.bindings.d.ts +4 -4
- package/lemma.bindings.js +10 -9
- package/lemma.d.ts +1 -0
- 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
|
@@ -30,7 +30,7 @@ import { Lemma } from '@lemmabase/lemma-engine';
|
|
|
30
30
|
const engine = await Lemma();
|
|
31
31
|
await engine.load(pricing, 'pricing.lemma');
|
|
32
32
|
|
|
33
|
-
const response = engine.run(null, 'pricing',
|
|
33
|
+
const response = engine.run(null, 'pricing', null, { quantity: 50, is_vip: false }, null);
|
|
34
34
|
// response.results.unit_price → 16 eur
|
|
35
35
|
// response.results.total → 800 eur
|
|
36
36
|
```
|
|
@@ -117,7 +117,7 @@ A pre-wired Monaco adapter ships at `@lemmabase/lemma-engine/monaco`.
|
|
|
117
117
|
| `list()` | JSON array of `ResolvedRepository`: each has `repository` and `specs` (spec sets). Always includes embedded `lemma` / `spec units`. |
|
|
118
118
|
| `format_repository(repo)` | Canonical Lemma source for a loaded repository, formatted from the in-engine AST. Use `"lemma"` for the embedded units stdlib. |
|
|
119
119
|
| `schema(repo, name, effective?)` | `SpecSchema`; `repo` null for workspace. |
|
|
120
|
-
| `run(repo, name, ruleNames, data, effective?)` | Evaluate. `
|
|
120
|
+
| `run(repo, name, ruleNames, data, effective?, explain?)` | Evaluate. Omit/`null` `ruleNames` for all rules; pass a non-empty array to scope. `[]` errors. Returns a `Response`. |
|
|
121
121
|
| `format(code, attribute?)` | Canonical formatting; throws `EngineError` on parse error. |
|
|
122
122
|
|
|
123
123
|
Full TypeScript types are bundled - see `lemma.d.ts`.
|
package/lemma.bindings.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export class Engine {
|
|
|
56
56
|
* `repository`: repository qualifier (`@org/pkg`), or `null`/empty for workspace (same as
|
|
57
57
|
* [`Engine::run`] `repo: None`).
|
|
58
58
|
*/
|
|
59
|
-
run(repository: string | null | undefined, spec: string, rule_names: any, data_values: any, effective?: string | null): any;
|
|
59
|
+
run(repository: string | null | undefined, spec: string, rule_names: any, data_values: any, effective?: string | null, explain?: boolean | null): any;
|
|
60
60
|
/**
|
|
61
61
|
* Planning schema for the spec ([`crate::planning::execution_plan::SpecSchema`]). Throws on error.
|
|
62
62
|
*
|
|
@@ -135,11 +135,11 @@ export interface InitOutput {
|
|
|
135
135
|
readonly wasmengine_load_batch: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
136
136
|
readonly wasmengine_new: () => number;
|
|
137
137
|
readonly wasmengine_repositories: (a: number, b: number) => void;
|
|
138
|
-
readonly wasmengine_run: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
138
|
+
readonly wasmengine_run: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
139
139
|
readonly wasmengine_schema: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
140
|
-
readonly
|
|
140
|
+
readonly __wasm_bindgen_func_elem_12158: (a: number, b: number, c: number, d: number) => void;
|
|
141
141
|
readonly __wasm_bindgen_func_elem_2731: (a: number, b: number, c: number, d: number) => void;
|
|
142
|
-
readonly
|
|
142
|
+
readonly __wasm_bindgen_func_elem_12161: (a: number, b: number, c: number, d: number) => void;
|
|
143
143
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
144
144
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
145
145
|
readonly __wbindgen_export3: (a: number) => void;
|
package/lemma.bindings.js
CHANGED
|
@@ -213,9 +213,10 @@ export class Engine {
|
|
|
213
213
|
* @param {any} rule_names
|
|
214
214
|
* @param {any} data_values
|
|
215
215
|
* @param {string | null} [effective]
|
|
216
|
+
* @param {boolean | null} [explain]
|
|
216
217
|
* @returns {any}
|
|
217
218
|
*/
|
|
218
|
-
run(repository, spec, rule_names, data_values, effective) {
|
|
219
|
+
run(repository, spec, rule_names, data_values, effective, explain) {
|
|
219
220
|
try {
|
|
220
221
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
221
222
|
var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -224,7 +225,7 @@ export class Engine {
|
|
|
224
225
|
const len1 = WASM_VECTOR_LEN;
|
|
225
226
|
var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
226
227
|
var len2 = WASM_VECTOR_LEN;
|
|
227
|
-
wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(rule_names), addHeapObject(data_values), ptr2, len2);
|
|
228
|
+
wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(rule_names), addHeapObject(data_values), ptr2, len2, isLikeNone(explain) ? 0xFFFFFF : explain ? 1 : 0);
|
|
228
229
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
229
230
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
230
231
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -714,7 +715,7 @@ function __wbg_get_imports() {
|
|
|
714
715
|
const a = state0.a;
|
|
715
716
|
state0.a = 0;
|
|
716
717
|
try {
|
|
717
|
-
return
|
|
718
|
+
return __wasm_bindgen_func_elem_12161(a, state0.b, arg0, arg1);
|
|
718
719
|
} finally {
|
|
719
720
|
state0.a = a;
|
|
720
721
|
}
|
|
@@ -873,8 +874,8 @@ function __wbg_get_imports() {
|
|
|
873
874
|
return addHeapObject(ret);
|
|
874
875
|
},
|
|
875
876
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
876
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
877
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
877
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1412, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
878
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12158);
|
|
878
879
|
return addHeapObject(ret);
|
|
879
880
|
},
|
|
880
881
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
@@ -916,10 +917,10 @@ function __wbg_get_imports() {
|
|
|
916
917
|
};
|
|
917
918
|
}
|
|
918
919
|
|
|
919
|
-
function
|
|
920
|
+
function __wasm_bindgen_func_elem_12158(arg0, arg1, arg2) {
|
|
920
921
|
try {
|
|
921
922
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
922
|
-
wasm.
|
|
923
|
+
wasm.__wasm_bindgen_func_elem_12158(retptr, arg0, arg1, addHeapObject(arg2));
|
|
923
924
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
924
925
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
925
926
|
if (r1) {
|
|
@@ -944,8 +945,8 @@ function __wasm_bindgen_func_elem_2731(arg0, arg1, arg2) {
|
|
|
944
945
|
}
|
|
945
946
|
}
|
|
946
947
|
|
|
947
|
-
function
|
|
948
|
-
wasm.
|
|
948
|
+
function __wasm_bindgen_func_elem_12161(arg0, arg1, arg2, arg3) {
|
|
949
|
+
wasm.__wasm_bindgen_func_elem_12161(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
949
950
|
}
|
|
950
951
|
|
|
951
952
|
|