@lemmabase/lemma-engine 0.9.0 → 0.9.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 +4 -4
- package/lemma.bindings.d.ts +16 -14
- package/lemma.bindings.js +148 -149
- package/lemma.d.ts +192 -116
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +13 -13
- 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.lemma': pricing });
|
|
32
32
|
|
|
33
|
-
const response = engine.run(
|
|
33
|
+
const response = engine.run({ spec: 'pricing', data: { quantity: 50, is_vip: false } });
|
|
34
34
|
// response.results.unit_price → 16 eur
|
|
35
35
|
// response.results.total → 800 eur
|
|
36
36
|
```
|
|
@@ -40,7 +40,7 @@ The `Response` carries every rule's value (or `veto` if no result could be compu
|
|
|
40
40
|
## Why use it from JavaScript?
|
|
41
41
|
|
|
42
42
|
- **Deterministic.** `(spec, data, effective_date) → result`. No DB, no clock, no ambient state. Same inputs → same outputs, every time.
|
|
43
|
-
- **Explainable.** Pass `explain: true`
|
|
43
|
+
- **Explainable.** Pass `explain: true` in your `run()` options to get a per-rule explanation tree; see [api.v1.json](https://github.com/lemma/lemma/blob/main/documentation/schemas/api.v1.json). Pair with the [CLI](https://github.com/lemma/lemma) for human reasoning tables.
|
|
44
44
|
- **Time-aware.** Multiple versions of the same spec coexist. Pass an `effective` date and the engine resolves the version in force on that day.
|
|
45
45
|
- **Statically checked.** Type errors, missing data, cycles, measure-family mismatches - all caught at `load()` time. Bad specs never reach `run()`.
|
|
46
46
|
- **Runs anywhere JavaScript does.** ~2 MB package, no native binary, no postinstall script.
|
|
@@ -112,12 +112,12 @@ A pre-wired Monaco adapter ships at `@lemmabase/lemma-engine/monaco`.
|
|
|
112
112
|
| Method | Description |
|
|
113
113
|
|--------|-------------|
|
|
114
114
|
| `load(code)` | Load inline Lemma source as a volatile workspace source |
|
|
115
|
-
| `load(sources)` | Load multiple sources in one planning pass (`Record<label, text>` or `[label, code][]`; `@org/pkg` keys tag dependencies) |
|
|
115
|
+
| `load(sources)` | Load multiple sources in one planning pass (`Record<label, text>` or `[label, code][]`; object keys keep insertion order; `@org/pkg` keys tag dependencies) |
|
|
116
116
|
| `fetch(name)` | Download registry source only; resolves with `{ source, id }`. Does not load. Rejects with `EngineError[]`. |
|
|
117
117
|
| `list()` | Slim catalog: `ResolvedRepository[]` with `repository` and temporal `specs` rows. Always includes embedded `lemma` / `spec units`. |
|
|
118
118
|
| `show(repo, name, effective?)` | Spec interface + temporal window; `repo` null for workspace. |
|
|
119
119
|
| `source(repo, spec?, effective?)` | Canonical Lemma source text. Omit `spec` for whole repository. |
|
|
120
|
-
| `run(
|
|
120
|
+
| `run({ spec, repository?, effective?, data?, rules?, explain? })` | Evaluate. Omit `rules` for all rules; pass a non-empty array to scope. `[]` errors. Returns a `Response`. `explain: true` adds per-rule explanation trees. |
|
|
121
121
|
| `remove(repo, name, effective?)` | Remove a temporal spec slice. |
|
|
122
122
|
| `limits()` | Resource limits for this engine. |
|
|
123
123
|
| `format(code, attribute?)` | Canonical formatting; throws `EngineError` on parse error. |
|
package/lemma.bindings.d.ts
CHANGED
|
@@ -44,8 +44,10 @@ export class Engine {
|
|
|
44
44
|
remove(repository: string | null | undefined, spec: string, effective?: string | null): void;
|
|
45
45
|
/**
|
|
46
46
|
* Evaluate spec. Returns [`crate::evaluation::Response`] as a JS object. Throws on planning/runtime error.
|
|
47
|
+
*
|
|
48
|
+
* Accepts an options object: `{ spec, repository?, effective?, data?, rules?, explain? }`.
|
|
47
49
|
*/
|
|
48
|
-
run(
|
|
50
|
+
run(options: any): any;
|
|
49
51
|
/**
|
|
50
52
|
* Spec interface and temporal window at `effective`. Lemma text is [`Self::source`].
|
|
51
53
|
*/
|
|
@@ -117,19 +119,19 @@ export interface InitOutput {
|
|
|
117
119
|
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
118
120
|
readonly intounderlyingsource_pull: (a: number, b: number) => number;
|
|
119
121
|
readonly __wbg_engine_free: (a: number, b: number) => void;
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly
|
|
123
|
-
readonly
|
|
124
|
-
readonly
|
|
125
|
-
readonly
|
|
126
|
-
readonly
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
readonly
|
|
130
|
-
readonly
|
|
131
|
-
readonly
|
|
132
|
-
readonly
|
|
122
|
+
readonly engine_fetch: (a: number, b: number, c: number) => number;
|
|
123
|
+
readonly engine_format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
124
|
+
readonly engine_limits: (a: number, b: number) => void;
|
|
125
|
+
readonly engine_list: (a: number, b: number) => void;
|
|
126
|
+
readonly engine_load: (a: number, b: number, c: number) => void;
|
|
127
|
+
readonly engine_new: () => number;
|
|
128
|
+
readonly engine_remove: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
129
|
+
readonly engine_run: (a: number, b: number, c: number) => void;
|
|
130
|
+
readonly engine_show: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
131
|
+
readonly engine_source: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
132
|
+
readonly __wasm_bindgen_func_elem_12433: (a: number, b: number, c: number, d: number) => void;
|
|
133
|
+
readonly __wasm_bindgen_func_elem_2735: (a: number, b: number, c: number, d: number) => void;
|
|
134
|
+
readonly __wasm_bindgen_func_elem_12440: (a: number, b: number, c: number, d: number) => void;
|
|
133
135
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
134
136
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
135
137
|
readonly __wbindgen_export3: (a: number) => void;
|