@lemmabase/lemma-engine 0.8.14 → 0.8.16
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 +6 -6
- package/lemma.bindings.js +21 -22
- package/lemma.d.ts +43 -3
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,8 +114,8 @@ A pre-wired Monaco adapter ships at `@lemmabase/lemma-engine/monaco`.
|
|
|
114
114
|
| `load(code, attribute?)` | Parse and validate a `.lemma` spec set. Resolves on success; rejects with `EngineError[]`. |
|
|
115
115
|
| `load_batch(sources, dependency?)` | Load many sources in one planning pass (see `lemma.d.ts`). |
|
|
116
116
|
| `fetch(name)` | Download registry source only; resolves with `{ source, id }`. Does not load. Rejects with `EngineError[]`. |
|
|
117
|
-
| `list()` | JSON array of `ResolvedRepository`: each has `repository` and `specs` (spec sets). Always includes embedded `lemma` / `spec
|
|
118
|
-
| `format_repository(repo)` | Canonical Lemma source for a loaded repository, formatted from the in-engine AST. Use `"lemma"` for the embedded
|
|
117
|
+
| `list()` | JSON array of `ResolvedRepository`: each has `repository` and `specs` (spec sets). Always includes embedded `lemma` / `spec units`. |
|
|
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
120
|
| `run(repo, name, ruleNames, data, effective?)` | Evaluate. `rules: []` runs everything; pass an array to filter. Returns a `Response`. |
|
|
121
121
|
| `format(code, attribute?)` | Canonical formatting; throws `EngineError` on parse error. |
|
|
@@ -139,12 +139,12 @@ In the browser, the registry must allow your origin (CORS). Use `https` or `http
|
|
|
139
139
|
|
|
140
140
|
## Status
|
|
141
141
|
|
|
142
|
-
Lemma is
|
|
142
|
+
Lemma is pre-1.0. The WASM API is stable for most use cases, but breaking changes may occur between minor versions. Pin your dependency version and review the [changelog](https://github.com/lemma/lemma/blob/main/CHANGELOG.md) before upgrading.
|
|
143
143
|
|
|
144
144
|
## Related
|
|
145
145
|
|
|
146
146
|
- [`lemmabase.com`](https://lemmabase.com): public database for Lemma Specs
|
|
147
|
-
- [`lemma
|
|
147
|
+
- [`lemma`](https://crates.io/crates/lemma): REPL, HTTP server, MCP server, formatter
|
|
148
148
|
- [`lemma-engine`](https://crates.io/crates/lemma-engine): same engine as a Rust crate
|
|
149
149
|
- [`lemma_engine` on Hex](https://hex.pm/packages/lemma_engine): Elixir bindings via Rustler
|
|
150
150
|
- VS Code / Cursor extension: search "Lemma Language" in the marketplace
|
package/lemma.bindings.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export class Engine {
|
|
|
24
24
|
* Canonical Lemma source for `repository`, formatted from the in-engine AST (e.g. `"lemma"`).
|
|
25
25
|
*/
|
|
26
26
|
format_repository(repository: string): string;
|
|
27
|
-
invert(
|
|
27
|
+
invert(spec_name: string, rule_name: string, target_json: string, provided_values_json: string): any;
|
|
28
28
|
/**
|
|
29
29
|
* Same data as [`Engine::list`]: grouped [`ResolvedRepository`] JSON without planning.
|
|
30
30
|
*/
|
|
@@ -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,
|
|
59
|
+
run(repository: string | null | undefined, spec: string, rule_names: any, data_values: any, effective?: string | 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
|
|
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;
|
|
139
139
|
readonly wasmengine_schema: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
140
|
-
readonly
|
|
141
|
-
readonly
|
|
142
|
-
readonly
|
|
140
|
+
readonly __wasm_bindgen_func_elem_12002: (a: number, b: number, c: number, d: number) => void;
|
|
141
|
+
readonly __wasm_bindgen_func_elem_2731: (a: number, b: number, c: number, d: number) => void;
|
|
142
|
+
readonly __wasm_bindgen_func_elem_12005: (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
|
@@ -80,22 +80,22 @@ export class Engine {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* @param {string}
|
|
84
|
-
* @param {string}
|
|
85
|
-
* @param {string}
|
|
86
|
-
* @param {string}
|
|
83
|
+
* @param {string} spec_name
|
|
84
|
+
* @param {string} rule_name
|
|
85
|
+
* @param {string} target_json
|
|
86
|
+
* @param {string} provided_values_json
|
|
87
87
|
* @returns {any}
|
|
88
88
|
*/
|
|
89
|
-
invert(
|
|
89
|
+
invert(spec_name, rule_name, target_json, provided_values_json) {
|
|
90
90
|
try {
|
|
91
91
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
92
|
-
const ptr0 = passStringToWasm0(
|
|
92
|
+
const ptr0 = passStringToWasm0(spec_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
93
93
|
const len0 = WASM_VECTOR_LEN;
|
|
94
|
-
const ptr1 = passStringToWasm0(
|
|
94
|
+
const ptr1 = passStringToWasm0(rule_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
95
95
|
const len1 = WASM_VECTOR_LEN;
|
|
96
|
-
const ptr2 = passStringToWasm0(
|
|
96
|
+
const ptr2 = passStringToWasm0(target_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
97
97
|
const len2 = WASM_VECTOR_LEN;
|
|
98
|
-
const ptr3 = passStringToWasm0(
|
|
98
|
+
const ptr3 = passStringToWasm0(provided_values_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
99
99
|
const len3 = WASM_VECTOR_LEN;
|
|
100
100
|
wasm.wasmengine_invert(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
101
101
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -212,11 +212,10 @@ export class Engine {
|
|
|
212
212
|
* @param {string} spec
|
|
213
213
|
* @param {any} rule_names
|
|
214
214
|
* @param {any} data_values
|
|
215
|
-
* @param {any} rule_result_units
|
|
216
215
|
* @param {string | null} [effective]
|
|
217
216
|
* @returns {any}
|
|
218
217
|
*/
|
|
219
|
-
run(repository, spec, rule_names, data_values,
|
|
218
|
+
run(repository, spec, rule_names, data_values, effective) {
|
|
220
219
|
try {
|
|
221
220
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
222
221
|
var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -225,7 +224,7 @@ export class Engine {
|
|
|
225
224
|
const len1 = WASM_VECTOR_LEN;
|
|
226
225
|
var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
227
226
|
var len2 = WASM_VECTOR_LEN;
|
|
228
|
-
wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(rule_names), addHeapObject(data_values),
|
|
227
|
+
wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(rule_names), addHeapObject(data_values), ptr2, len2);
|
|
229
228
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
230
229
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
231
230
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -715,7 +714,7 @@ function __wbg_get_imports() {
|
|
|
715
714
|
const a = state0.a;
|
|
716
715
|
state0.a = 0;
|
|
717
716
|
try {
|
|
718
|
-
return
|
|
717
|
+
return __wasm_bindgen_func_elem_12005(a, state0.b, arg0, arg1);
|
|
719
718
|
} finally {
|
|
720
719
|
state0.a = a;
|
|
721
720
|
}
|
|
@@ -874,13 +873,13 @@ function __wbg_get_imports() {
|
|
|
874
873
|
return addHeapObject(ret);
|
|
875
874
|
},
|
|
876
875
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
877
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
878
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
876
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1421, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
877
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12002);
|
|
879
878
|
return addHeapObject(ret);
|
|
880
879
|
},
|
|
881
880
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
882
881
|
// 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`.
|
|
883
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
882
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2731);
|
|
884
883
|
return addHeapObject(ret);
|
|
885
884
|
},
|
|
886
885
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -917,10 +916,10 @@ function __wbg_get_imports() {
|
|
|
917
916
|
};
|
|
918
917
|
}
|
|
919
918
|
|
|
920
|
-
function
|
|
919
|
+
function __wasm_bindgen_func_elem_12002(arg0, arg1, arg2) {
|
|
921
920
|
try {
|
|
922
921
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
923
|
-
wasm.
|
|
922
|
+
wasm.__wasm_bindgen_func_elem_12002(retptr, arg0, arg1, addHeapObject(arg2));
|
|
924
923
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
925
924
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
926
925
|
if (r1) {
|
|
@@ -931,10 +930,10 @@ function __wasm_bindgen_func_elem_11787(arg0, arg1, arg2) {
|
|
|
931
930
|
}
|
|
932
931
|
}
|
|
933
932
|
|
|
934
|
-
function
|
|
933
|
+
function __wasm_bindgen_func_elem_2731(arg0, arg1, arg2) {
|
|
935
934
|
try {
|
|
936
935
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
937
|
-
wasm.
|
|
936
|
+
wasm.__wasm_bindgen_func_elem_2731(retptr, arg0, arg1, addHeapObject(arg2));
|
|
938
937
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
939
938
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
940
939
|
if (r1) {
|
|
@@ -945,8 +944,8 @@ function __wasm_bindgen_func_elem_2722(arg0, arg1, arg2) {
|
|
|
945
944
|
}
|
|
946
945
|
}
|
|
947
946
|
|
|
948
|
-
function
|
|
949
|
-
wasm.
|
|
947
|
+
function __wasm_bindgen_func_elem_12005(arg0, arg1, arg2, arg3) {
|
|
948
|
+
wasm.__wasm_bindgen_func_elem_12005(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
950
949
|
}
|
|
951
950
|
|
|
952
951
|
|
package/lemma.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ declare module './lemma.bindings.js' {
|
|
|
35
35
|
list(): ResolvedRepositoryJson[];
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Formatted Lemma source for a loaded repository (from in-engine AST). Use `"lemma"` for embedded
|
|
38
|
+
* Formatted Lemma source for a loaded repository (from in-engine AST). Use `"lemma"` for embedded units stdlib.
|
|
39
39
|
*/
|
|
40
40
|
format_repository(repository: string): string;
|
|
41
41
|
|
|
@@ -56,9 +56,8 @@ declare module './lemma.bindings.js' {
|
|
|
56
56
|
spec: string,
|
|
57
57
|
rule_names: string[] | string,
|
|
58
58
|
data_values: Record<string, unknown>,
|
|
59
|
-
rule_result_units?: Record<string, string> | null,
|
|
60
59
|
effective?: string | null,
|
|
61
|
-
):
|
|
60
|
+
): EvaluationResponse;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
|
|
@@ -207,6 +206,47 @@ export interface DataEntry {
|
|
|
207
206
|
default?: LiteralValue;
|
|
208
207
|
}
|
|
209
208
|
|
|
209
|
+
/** Return shape of {@link Engine.run}. */
|
|
210
|
+
export interface EvaluationResponse {
|
|
211
|
+
spec: string;
|
|
212
|
+
effective: string;
|
|
213
|
+
results: Record<string, RuleResult>;
|
|
214
|
+
data: EvaluationDataEntry[];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface RuleResult {
|
|
218
|
+
vetoed: boolean;
|
|
219
|
+
display?: string | null;
|
|
220
|
+
veto_reason?: string | null;
|
|
221
|
+
rule_type: string;
|
|
222
|
+
quantity?: Record<string, string> | null;
|
|
223
|
+
ratio?: Record<string, string> | null;
|
|
224
|
+
number?: string | null;
|
|
225
|
+
boolean?: boolean | null;
|
|
226
|
+
text?: string | null;
|
|
227
|
+
date?: unknown | null;
|
|
228
|
+
time?: unknown | null;
|
|
229
|
+
calendar?: { value: string; unit: string } | null;
|
|
230
|
+
range?: { from: RuleResultPayload; to: RuleResultPayload } | null;
|
|
231
|
+
explanation?: unknown | null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface RuleResultPayload {
|
|
235
|
+
quantity?: Record<string, string> | null;
|
|
236
|
+
ratio?: Record<string, string> | null;
|
|
237
|
+
number?: string | null;
|
|
238
|
+
boolean?: boolean | null;
|
|
239
|
+
text?: string | null;
|
|
240
|
+
date?: unknown | null;
|
|
241
|
+
time?: unknown | null;
|
|
242
|
+
calendar?: { value: string; unit: string } | null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface EvaluationDataEntry {
|
|
246
|
+
path: string;
|
|
247
|
+
value: unknown;
|
|
248
|
+
}
|
|
249
|
+
|
|
210
250
|
/** Return shape of {@link Engine.schema}. */
|
|
211
251
|
export interface SpecSchema {
|
|
212
252
|
spec: string;
|