@lemmabase/lemma-engine 0.8.11
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/LICENSE +191 -0
- package/README.md +83 -0
- package/esbuild.js +21 -0
- package/lemma.bindings.d.ts +150 -0
- package/lemma.bindings.js +1198 -0
- package/lemma.d.ts +127 -0
- package/lemma.iife.js +45 -0
- package/lemma.js +23 -0
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +36 -0
- package/lsp-client.js +325 -0
- package/lsp.d.ts +1 -0
- package/lsp.js +4 -0
- package/monaco.js +80 -0
- package/package.json +56 -0
package/lemma.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Engine } from './lemma.bindings.js';
|
|
2
|
+
export { Engine, initSync } from './lemma.bindings.js';
|
|
3
|
+
export declare function init(): Promise<void>;
|
|
4
|
+
export declare function Lemma(): Promise<Engine>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Source location attached to an {@link EngineError}. Line and column are
|
|
8
|
+
* 1-based; `length` is the UTF-8 byte length of the offending span.
|
|
9
|
+
*/
|
|
10
|
+
export interface EngineErrorSource {
|
|
11
|
+
attribute: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
length: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Structured error thrown by {@link Engine.run}, {@link Engine.schema},
|
|
19
|
+
* {@link Engine.format}, and rejected from {@link Engine.load} (as an array).
|
|
20
|
+
*
|
|
21
|
+
* - `kind` classifies the failure ("parsing" for syntax, "validation" for
|
|
22
|
+
* semantic/planning including bad data values, "request" for bad API input,
|
|
23
|
+
* etc.).
|
|
24
|
+
* - `message` is the inner reason only. Callers that previously parsed
|
|
25
|
+
* `"Failed to parse data 'X' as Y: ..."` strings should now use `related_data`
|
|
26
|
+
* for attribution and `message` for the reason.
|
|
27
|
+
* - `related_data` is non-null when the error is attributable to a specific data
|
|
28
|
+
* input declared by the spec (e.g. a field-level form validation failure).
|
|
29
|
+
* - `source` points at the offending range in the original Lemma source.
|
|
30
|
+
*/
|
|
31
|
+
export interface EngineError {
|
|
32
|
+
kind: "parsing" | "validation" | "inversion" | "registry" | "request" | "resource_limit";
|
|
33
|
+
message: string;
|
|
34
|
+
related_data: string | null;
|
|
35
|
+
spec: string | null;
|
|
36
|
+
related_spec: string | null;
|
|
37
|
+
source: EngineErrorSource | null;
|
|
38
|
+
suggestion: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Schema envelope (return shape of Engine.schema and Engine.list entries)
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
/** Literal value produced by `JSON.stringify` on a Lemma `LiteralValue`. */
|
|
46
|
+
export type LiteralValue = unknown;
|
|
47
|
+
|
|
48
|
+
/** Extension classification serialized on every {@link LemmaType}. */
|
|
49
|
+
export type TypeExtends =
|
|
50
|
+
| "primitive"
|
|
51
|
+
| {
|
|
52
|
+
parent: string;
|
|
53
|
+
family: string;
|
|
54
|
+
defining_spec: unknown;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface UnitDef { name: string; value: string }
|
|
58
|
+
export interface RatioUnitDef { name: string; value: string }
|
|
59
|
+
|
|
60
|
+
/** Discriminated union over the 10 Lemma type kinds. Field `kind` is the
|
|
61
|
+
* serde tag; kind-specific fields sit at the top level next to `kind`,
|
|
62
|
+
* `name`, and `extends`. */
|
|
63
|
+
export type LemmaType =
|
|
64
|
+
& { name: string | null; extends: TypeExtends }
|
|
65
|
+
& (
|
|
66
|
+
| { kind: "boolean"; help: string }
|
|
67
|
+
| {
|
|
68
|
+
kind: "scale";
|
|
69
|
+
minimum: string | null;
|
|
70
|
+
maximum: string | null;
|
|
71
|
+
decimals: number | null;
|
|
72
|
+
precision: string | null;
|
|
73
|
+
units: UnitDef[];
|
|
74
|
+
help: string;
|
|
75
|
+
}
|
|
76
|
+
| {
|
|
77
|
+
kind: "number";
|
|
78
|
+
minimum: string | null;
|
|
79
|
+
maximum: string | null;
|
|
80
|
+
decimals: number | null;
|
|
81
|
+
precision: string | null;
|
|
82
|
+
help: string;
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
kind: "ratio";
|
|
86
|
+
minimum: string | null;
|
|
87
|
+
maximum: string | null;
|
|
88
|
+
decimals: number | null;
|
|
89
|
+
units: RatioUnitDef[];
|
|
90
|
+
help: string;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
kind: "text";
|
|
94
|
+
minimum: number | null;
|
|
95
|
+
maximum: number | null;
|
|
96
|
+
length: number | null;
|
|
97
|
+
options: string[];
|
|
98
|
+
help: string;
|
|
99
|
+
}
|
|
100
|
+
| { kind: "date"; minimum: string | null; maximum: string | null; help: string }
|
|
101
|
+
| { kind: "time"; minimum: string | null; maximum: string | null; help: string }
|
|
102
|
+
| { kind: "duration"; help: string }
|
|
103
|
+
| { kind: "veto"; message: string | null }
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/** One input on a spec. `default` is omitted (not `null`) when absent. */
|
|
107
|
+
export interface DataEntry {
|
|
108
|
+
type: LemmaType;
|
|
109
|
+
default?: LiteralValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Return shape of {@link Engine.schema}. */
|
|
113
|
+
export interface SpecSchema {
|
|
114
|
+
spec: string;
|
|
115
|
+
data: Record<string, DataEntry>;
|
|
116
|
+
rules: Record<string, LemmaType>;
|
|
117
|
+
meta: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** One row of {@link Engine.list}. The schema is always inlined so callers
|
|
121
|
+
* never need a second `engine.schema(name, effective_from)` round-trip. */
|
|
122
|
+
export interface SpecListEntry {
|
|
123
|
+
name: string;
|
|
124
|
+
effective_from: string | null;
|
|
125
|
+
effective_to: string | null;
|
|
126
|
+
schema: SpecSchema;
|
|
127
|
+
}
|