@lemmabase/lemma-engine 0.8.13 → 0.8.14

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/lemma.d.ts CHANGED
@@ -34,6 +34,11 @@ declare module './lemma.bindings.js' {
34
34
  */
35
35
  list(): ResolvedRepositoryJson[];
36
36
 
37
+ /**
38
+ * Formatted Lemma source for a loaded repository (from in-engine AST). Use `"lemma"` for embedded SI stdlib.
39
+ */
40
+ format_repository(repository: string): string;
41
+
37
42
  /**
38
43
  * `repository`: qualifier or `null`/omit for workspace — same as `Engine::schema` `repo`.
39
44
  */
@@ -51,6 +56,7 @@ declare module './lemma.bindings.js' {
51
56
  spec: string,
52
57
  rule_names: string[] | string,
53
58
  data_values: Record<string, unknown>,
59
+ rule_result_units?: Record<string, string> | null,
54
60
  effective?: string | null,
55
61
  ): any;
56
62
  }
@@ -117,8 +123,21 @@ export type TypeExtends =
117
123
  defining_spec: unknown;
118
124
  };
119
125
 
120
- export interface UnitDef { name: string; value: string }
121
- export interface RatioUnitDef { name: string; value: string }
126
+ export interface UnitDef {
127
+ name: string;
128
+ factor: { numer: string; denom: string };
129
+ minimum?: string | null;
130
+ maximum?: string | null;
131
+ default?: string | null;
132
+ }
133
+
134
+ export interface RatioUnitDef {
135
+ name: string;
136
+ value: { numer: string; denom: string };
137
+ minimum?: string | null;
138
+ maximum?: string | null;
139
+ default?: string | null;
140
+ }
122
141
 
123
142
  /** Discriminated union over the 10 Lemma type kinds. Field `kind` is the
124
143
  * serde tag; kind-specific fields sit at the top level next to `kind`,
@@ -128,11 +147,18 @@ export type LemmaType =
128
147
  & (
129
148
  | { kind: "boolean"; help: string }
130
149
  | {
131
- kind: "scale";
150
+ kind: "quantity";
151
+ minimum: string | null;
152
+ maximum: string | null;
153
+ decimals: number | null;
154
+ units: UnitDef[];
155
+ help: string;
156
+ }
157
+ | {
158
+ kind: "quantity range";
132
159
  minimum: string | null;
133
160
  maximum: string | null;
134
161
  decimals: number | null;
135
- precision: string | null;
136
162
  units: UnitDef[];
137
163
  help: string;
138
164
  }
@@ -141,7 +167,6 @@ export type LemmaType =
141
167
  minimum: string | null;
142
168
  maximum: string | null;
143
169
  decimals: number | null;
144
- precision: string | null;
145
170
  help: string;
146
171
  }
147
172
  | {
@@ -152,6 +177,14 @@ export type LemmaType =
152
177
  units: RatioUnitDef[];
153
178
  help: string;
154
179
  }
180
+ | {
181
+ kind: "ratio range";
182
+ minimum: string | null;
183
+ maximum: string | null;
184
+ decimals: number | null;
185
+ units: RatioUnitDef[];
186
+ help: string;
187
+ }
155
188
  | {
156
189
  kind: "text";
157
190
  minimum: number | null;
@@ -162,7 +195,6 @@ export type LemmaType =
162
195
  }
163
196
  | { kind: "date"; minimum: string | null; maximum: string | null; help: string }
164
197
  | { kind: "time"; minimum: string | null; maximum: string | null; help: string }
165
- | { kind: "duration"; help: string }
166
198
  | { kind: "veto"; message: string | null }
167
199
  );
168
200
 
@@ -179,6 +211,7 @@ export interface DataEntry {
179
211
  export interface SpecSchema {
180
212
  spec: string;
181
213
  data: Record<string, DataEntry>;
214
+ /** Rule result types; quantity and ratio entries expose `units[]` like their data counterparts. */
182
215
  rules: Record<string, LemmaType>;
183
216
  meta: Record<string, unknown>;
184
217
  }