@lemmabase/lemma-engine 0.9.7 → 0.9.9
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 +21 -8
- package/lemma.bindings.d.ts +24 -13
- package/lemma.bindings.js +124 -94
- package/lemma.d.ts +24 -20
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +8 -5
- package/package.json +1 -1
package/lemma.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { Engine, initSync } from './lemma.bindings.js';
|
|
|
3
3
|
export declare function init(): Promise<void>;
|
|
4
4
|
export declare function Lemma(): Promise<Engine>;
|
|
5
5
|
|
|
6
|
-
/** Resolved shape of {@link Engine.
|
|
7
|
-
export interface
|
|
6
|
+
/** Resolved shape of {@link Engine.install}. */
|
|
7
|
+
export interface RepositoryInstallResult {
|
|
8
8
|
source: string;
|
|
9
9
|
id: string;
|
|
10
10
|
}
|
|
@@ -13,6 +13,8 @@ declare module './lemma.bindings.js' {
|
|
|
13
13
|
namespace Engine {
|
|
14
14
|
/** Create engine with named limit overrides. Unknown keys throw. */
|
|
15
15
|
function withLimits(limits: Record<string, number>): Engine;
|
|
16
|
+
/** Restore an engine from {@link Engine.snapshot} bytes. */
|
|
17
|
+
function fromSnapshot(bytes: Uint8Array): Engine;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
interface Engine {
|
|
@@ -26,10 +28,11 @@ declare module './lemma.bindings.js' {
|
|
|
26
28
|
load(sources: Record<string, string> | Array<[string, string]>): void;
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
* Download Lemma source from
|
|
30
|
-
* `{ source, id }`; does not load the engine
|
|
31
|
+
* Download Lemma source from LemmaBase for `name` (e.g. `@org/pkg`). Resolves with
|
|
32
|
+
* `{ source, id }`; does not load the engine and does not write `lemma_deps/`.
|
|
33
|
+
* Rejects with `EngineError[]` like `load`.
|
|
31
34
|
*/
|
|
32
|
-
|
|
35
|
+
install(name: string): Promise<RepositoryInstallResult>;
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* JSON serialization of `Vec<ResolvedRepository>` from [`Engine::list`]:
|
|
@@ -66,13 +69,11 @@ declare module './lemma.bindings.js' {
|
|
|
66
69
|
): void;
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
|
-
* Replace
|
|
72
|
+
* Replace identities in `code` (atomic upsert; Path/Dependency prune siblings).
|
|
70
73
|
* `attribute` is the source label (path or `@owner/repo`); omit for volatile.
|
|
71
74
|
*/
|
|
72
75
|
update(
|
|
73
76
|
repository: string | null | undefined,
|
|
74
|
-
spec: string,
|
|
75
|
-
effective: string | null | undefined,
|
|
76
77
|
code: string,
|
|
77
78
|
attribute?: string | null,
|
|
78
79
|
): void;
|
|
@@ -80,6 +81,12 @@ declare module './lemma.bindings.js' {
|
|
|
80
81
|
/** Resource limits configured for this engine. */
|
|
81
82
|
limits(): ResourceLimits;
|
|
82
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Persist parsed specs + plans + limits as opaque bytes.
|
|
86
|
+
* Restore with {@link Engine.fromSnapshot}.
|
|
87
|
+
*/
|
|
88
|
+
snapshot(): Uint8Array;
|
|
89
|
+
|
|
83
90
|
/**
|
|
84
91
|
* Canonical formatting of Lemma source. Throws `EngineError` on parse error.
|
|
85
92
|
* `attribute` is an optional path label used in error messages.
|
|
@@ -127,8 +134,8 @@ export interface EngineErrorSource {
|
|
|
127
134
|
|
|
128
135
|
/**
|
|
129
136
|
* Structured error thrown by {@link Engine.run}, {@link Engine.show},
|
|
130
|
-
* {@link Engine.load}, and {@link Engine.
|
|
131
|
-
* (as an array), and rejected from {@link Engine.
|
|
137
|
+
* {@link Engine.load}, and {@link Engine.install}
|
|
138
|
+
* (as an array), and rejected from {@link Engine.install} (as an array).
|
|
132
139
|
*
|
|
133
140
|
* - `kind` classifies the failure ("parsing" for syntax, "validation" for
|
|
134
141
|
* semantic/planning including bad data values, "missing_repository" when a
|
|
@@ -179,7 +186,7 @@ export interface EngineError {
|
|
|
179
186
|
|
|
180
187
|
/**
|
|
181
188
|
* API value fields shared by `RuleResult` (flattened into its top-level fields),
|
|
182
|
-
* `ShowData.
|
|
189
|
+
* `ShowData.fill`, `ShowData.suggestion`, and range endpoints.
|
|
183
190
|
* A `None` field is absent (not `null`) per Rust `skip_serializing_if`.
|
|
184
191
|
* When present: always `display`, plus exactly one typed field.
|
|
185
192
|
*/
|
|
@@ -200,7 +207,7 @@ export interface RuleResultValueEndpoint {
|
|
|
200
207
|
|
|
201
208
|
/**
|
|
202
209
|
* API value shared by `RuleResult` (flattened into its top-level fields),
|
|
203
|
-
* `ShowData.
|
|
210
|
+
* `ShowData.fill`, and `ShowData.suggestion`. When present: always `display`,
|
|
204
211
|
* plus exactly one typed field for a non-range value; `range` is set instead for a
|
|
205
212
|
* range value. A range endpoint (`range.from`/`range.to`) never itself carries a
|
|
206
213
|
* `range` field.
|
|
@@ -339,10 +346,10 @@ export type LemmaType =
|
|
|
339
346
|
export interface ShowData {
|
|
340
347
|
type: LemmaType;
|
|
341
348
|
/** Spec literal or literal `with` binding; UIs may skip review. */
|
|
342
|
-
|
|
349
|
+
fill?: RuleResultValue;
|
|
343
350
|
/** `-> suggest ...` suggestion; prompt with prefill in interactive UIs. */
|
|
344
351
|
suggestion?: RuleResultValue;
|
|
345
|
-
/** Local rule names that transitively need this data
|
|
352
|
+
/** Local rule names that transitively need this data after normalize. Empty = reuse catalog only. */
|
|
346
353
|
needed_by_rules: string[];
|
|
347
354
|
}
|
|
348
355
|
|
|
@@ -365,7 +372,7 @@ export type RuleResult = RuleResultValue & {
|
|
|
365
372
|
vetoed: boolean;
|
|
366
373
|
veto_reason?: string;
|
|
367
374
|
rule_type: string;
|
|
368
|
-
/** Input keys still unbound for this rule (run-data-aware;
|
|
375
|
+
/** Input keys still unbound for this rule (run-data-aware; subset of Show.data with non-empty needed_by_rules). */
|
|
369
376
|
missing_data?: string[];
|
|
370
377
|
/** Present when `run(..., explain: true)`. Shape: engine/schemas/api.v1.json (`RuleResult.explanation`). */
|
|
371
378
|
explanation?: Explanation;
|
|
@@ -438,7 +445,7 @@ export interface ShowVersion {
|
|
|
438
445
|
* is the bare string `"volatile"`. */
|
|
439
446
|
export type SourceType = "volatile" | { path: string } | { dependency: string };
|
|
440
447
|
|
|
441
|
-
/** Parsed literal value
|
|
448
|
+
/** Parsed literal value. Externally tagged. */
|
|
442
449
|
export type LiteralValue =
|
|
443
450
|
| { number: string }
|
|
444
451
|
| { number_with_unit: [string, string] }
|
|
@@ -448,9 +455,6 @@ export type LiteralValue =
|
|
|
448
455
|
| { boolean: "true" | "false" | "yes" | "no" }
|
|
449
456
|
| { range: [LiteralValue, LiteralValue] };
|
|
450
457
|
|
|
451
|
-
/** Spec `meta` field value. Externally tagged. */
|
|
452
|
-
export type MetaValue = { literal: LiteralValue } | { unquoted: string };
|
|
453
|
-
|
|
454
458
|
/** Return shape of {@link Engine.show}. */
|
|
455
459
|
export interface Show {
|
|
456
460
|
spec: string;
|
|
@@ -463,7 +467,7 @@ export interface Show {
|
|
|
463
467
|
data: Record<string, ShowData>;
|
|
464
468
|
/** Rule result types; measure and ratio entries expose `units[]` like their data counterparts. */
|
|
465
469
|
rules: Record<string, LemmaType>;
|
|
466
|
-
meta: Record<string,
|
|
470
|
+
meta: Record<string, LiteralValue>;
|
|
467
471
|
}
|
|
468
472
|
|
|
469
473
|
/** Slim listed spec row (engine `list`). */
|