@cruba/crubal 0.0.0-stage → 0.1.0
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 +202 -0
- package/README.md +69 -2
- package/dist/bin/crubal.d.ts +2 -0
- package/dist/bin/crubal.js +37 -0
- package/dist/bin/crubal.js.map +1 -0
- package/dist/src/browser.d.ts +10 -0
- package/dist/src/browser.js +13 -0
- package/dist/src/browser.js.map +1 -0
- package/dist/src/canonical.d.ts +6 -0
- package/dist/src/canonical.js +47 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/conditions.d.ts +22 -0
- package/dist/src/conditions.js +175 -0
- package/dist/src/conditions.js.map +1 -0
- package/dist/src/corpus.d.ts +8 -0
- package/dist/src/corpus.js +673 -0
- package/dist/src/corpus.js.map +1 -0
- package/dist/src/defs.d.ts +116 -0
- package/dist/src/defs.js +530 -0
- package/dist/src/defs.js.map +1 -0
- package/dist/src/dictionary.d.ts +50 -0
- package/dist/src/dictionary.js +498 -0
- package/dist/src/dictionary.js.map +1 -0
- package/dist/src/exchange.d.ts +45 -0
- package/dist/src/exchange.js +321 -0
- package/dist/src/exchange.js.map +1 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lex.d.ts +21 -0
- package/dist/src/lex.js +142 -0
- package/dist/src/lex.js.map +1 -0
- package/dist/src/migrate.d.ts +88 -0
- package/dist/src/migrate.js +191 -0
- package/dist/src/migrate.js.map +1 -0
- package/dist/src/model.d.ts +36 -0
- package/dist/src/model.js +32 -0
- package/dist/src/model.js.map +1 -0
- package/dist/src/packages.d.ts +25 -0
- package/dist/src/packages.js +98 -0
- package/dist/src/packages.js.map +1 -0
- package/dist/src/print-text.d.ts +7 -0
- package/dist/src/print-text.js +194 -0
- package/dist/src/print-text.js.map +1 -0
- package/dist/src/read-text.d.ts +8 -0
- package/dist/src/read-text.js +317 -0
- package/dist/src/read-text.js.map +1 -0
- package/dist/src/rules.d.ts +64 -0
- package/dist/src/rules.js +486 -0
- package/dist/src/rules.js.map +1 -0
- package/dist/src/store.d.ts +133 -0
- package/dist/src/store.js +396 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tree.d.ts +32 -0
- package/dist/src/tree.js +123 -0
- package/dist/src/tree.js.map +1 -0
- package/dist/src/units.d.ts +4 -0
- package/dist/src/units.js +37 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/views.d.ts +114 -0
- package/dist/src/views.js +436 -0
- package/dist/src/views.js.map +1 -0
- package/package.json +58 -4
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
// dictionary.ts: the Dictionary level (spec chapters 4 and 5). Definitions as JSON (4.6), the publish
|
|
2
|
+
// checks on definitions and classes (4.7, 5.10), class resolution by meet (5.4), alias folding (4.3), and
|
|
3
|
+
// checking each value against its facet and the classes its record wears (4.9, 5.3, 5.5, 5.6).
|
|
4
|
+
import { evaluate, parseCondition } from "./conditions.js";
|
|
5
|
+
import { itemText } from "./print-text.js";
|
|
6
|
+
import { readUnder } from "./read-text.js";
|
|
7
|
+
import { CrubalError } from "./tree.js";
|
|
8
|
+
import { convert, unitOf } from "./units.js";
|
|
9
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
10
|
+
/** A fold key (4.3): NFC, case-folded, trimmed, inner white space made one space. */
|
|
11
|
+
export function foldKey(s) {
|
|
12
|
+
return s.normalize("NFC").toLowerCase().trim().replace(/\s+/g, " ");
|
|
13
|
+
}
|
|
14
|
+
// ─── Definitions as JSON (4.6) ────────────────────────────────────────────────
|
|
15
|
+
export function facetJson(f) {
|
|
16
|
+
const o = { facet: f.key, type: f.type };
|
|
17
|
+
const put = (k, v, skip) => {
|
|
18
|
+
if (v === undefined || v === skip)
|
|
19
|
+
return;
|
|
20
|
+
if (Array.isArray(v) && v.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
o[k] = v;
|
|
23
|
+
};
|
|
24
|
+
put("label", f.label);
|
|
25
|
+
put("ask", f.ask);
|
|
26
|
+
put("describe", f.describe);
|
|
27
|
+
put("pick", f.pick, "1");
|
|
28
|
+
put("ordered", f.ordered || undefined);
|
|
29
|
+
put("state", f.state, "active");
|
|
30
|
+
put("qualifiers", f.qualifiers);
|
|
31
|
+
put("aliases", f.aliases);
|
|
32
|
+
put("same-as", f.sameAs);
|
|
33
|
+
put("agree-by", f.agreeBy);
|
|
34
|
+
put("length", f.length === undefined ? undefined : String(f.length));
|
|
35
|
+
put("unit", f.unit);
|
|
36
|
+
put("accepts", f.accepts);
|
|
37
|
+
if (f.range)
|
|
38
|
+
o.range = { ...f.range };
|
|
39
|
+
put("places", f.places === undefined ? undefined : String(f.places));
|
|
40
|
+
put("precision", f.precision, "any");
|
|
41
|
+
if (f.words)
|
|
42
|
+
o.words = [...f.words];
|
|
43
|
+
if (f.values)
|
|
44
|
+
o.values = f.values.map((v) => (v.aliases.length ? { value: v.value, aliases: [...v.aliases] } : { value: v.value }));
|
|
45
|
+
put("open", f.open || undefined);
|
|
46
|
+
for (const k of ["fixed", "ranked", "scored", "required", "na", "unique"])
|
|
47
|
+
put(k, f[k] || undefined);
|
|
48
|
+
put("to", f.to);
|
|
49
|
+
if (f.children)
|
|
50
|
+
o.facets = [...f.children.values()].map(facetJson);
|
|
51
|
+
put("identity", f.identity);
|
|
52
|
+
put("when", f.when);
|
|
53
|
+
put("combine", f.combine);
|
|
54
|
+
put("version", f.version);
|
|
55
|
+
for (const [k, v] of Object.entries(f.extra))
|
|
56
|
+
o[k] = v;
|
|
57
|
+
return o;
|
|
58
|
+
}
|
|
59
|
+
function checkFacet(f) {
|
|
60
|
+
const line = f.line;
|
|
61
|
+
if (f.type === "choice" && !f.values?.length)
|
|
62
|
+
throw new CrubalError(`the choice facet ${f.key} has no values`, line);
|
|
63
|
+
if (f.type === "compound" && !f.children?.size)
|
|
64
|
+
throw new CrubalError(`the compound facet ${f.key} has no children`, line);
|
|
65
|
+
if (f.open && f.fixed)
|
|
66
|
+
throw new CrubalError(`the list of ${f.key} is both open and fixed`, line);
|
|
67
|
+
if ((f.ranked || f.scored || f.fixed || f.open) && f.type !== "choice") {
|
|
68
|
+
throw new CrubalError(`${f.key}: ranked, scored, fixed and open lists are for choice facets`, line);
|
|
69
|
+
}
|
|
70
|
+
if (f.ordered && !f.many)
|
|
71
|
+
throw new CrubalError(`${f.key} is ordered but holds one value`, line);
|
|
72
|
+
if (f.accepts.length && !f.unit)
|
|
73
|
+
throw new CrubalError(`${f.key} accepts other units but has no unit`, line);
|
|
74
|
+
if (f.range && Number(f.range.min) > Number(f.range.max))
|
|
75
|
+
throw new CrubalError(`${f.key}'s range runs backwards`, line);
|
|
76
|
+
if (f.identity) {
|
|
77
|
+
const child = f.children?.get(f.identity);
|
|
78
|
+
if (!child)
|
|
79
|
+
throw new CrubalError(`the identity child ${f.identity} of ${f.key} isn't one of its children`, line);
|
|
80
|
+
if (child.type !== "link")
|
|
81
|
+
throw new CrubalError(`the identity child ${f.identity} of ${f.key} is not a link`, line);
|
|
82
|
+
}
|
|
83
|
+
const seen = new Map();
|
|
84
|
+
for (const v of f.values ?? []) {
|
|
85
|
+
for (const spelling of [v.value, ...v.aliases]) {
|
|
86
|
+
const k = foldKey(spelling);
|
|
87
|
+
const owner = seen.get(k);
|
|
88
|
+
if (owner !== undefined && owner !== v.value) {
|
|
89
|
+
throw new CrubalError(`${f.key}: the spelling ${spelling} folds to the same as ${owner}`, line);
|
|
90
|
+
}
|
|
91
|
+
seen.set(k, v.value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const c of f.children?.values() ?? []) {
|
|
95
|
+
if (["row", "origin", "via", "owner"].includes(c.key))
|
|
96
|
+
throw new CrubalError(`${f.key} has a child named ${c.key}, which is reserved`, line);
|
|
97
|
+
checkFacet(c);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Run every publish check on a dictionary. Throws the first error; returns warnings. */
|
|
101
|
+
export function checkPackage(dict) {
|
|
102
|
+
const warnings = [];
|
|
103
|
+
const keys = new Map();
|
|
104
|
+
for (const f of dict.facets.values()) {
|
|
105
|
+
if (f.key.startsWith("crubal:"))
|
|
106
|
+
continue;
|
|
107
|
+
checkFacet(f);
|
|
108
|
+
for (const spelling of [f.key, ...f.aliases]) {
|
|
109
|
+
const k = foldKey(spelling);
|
|
110
|
+
const owner = keys.get(k);
|
|
111
|
+
if (owner !== undefined && owner !== f.key) {
|
|
112
|
+
const what = spelling === f.key ? `the key ${f.key}` : `the alias ${spelling} of ${f.key}`;
|
|
113
|
+
throw new CrubalError(`${what} folds to ${owner === k ? "the key" : "an alias"} of ${owner}`, f.line);
|
|
114
|
+
}
|
|
115
|
+
keys.set(k, f.key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const c of dict.classes.values()) {
|
|
119
|
+
for (const l of c.lines)
|
|
120
|
+
checkClassLine(c, l, dict);
|
|
121
|
+
for (const slot of c.parts) {
|
|
122
|
+
if (!dict.classes.has(slot.wears))
|
|
123
|
+
throw new CrubalError(`the part slot ${slot.slot} wears ${slot.wears}, which isn't a class`, slot.line);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const c of dict.classes.values()) {
|
|
127
|
+
findCycle(c.name, dict, []);
|
|
128
|
+
resolve(dict, [c.name], c.line);
|
|
129
|
+
warnings.push(...redundantLines(c, dict));
|
|
130
|
+
}
|
|
131
|
+
return warnings;
|
|
132
|
+
}
|
|
133
|
+
function checkClassLine(c, l, dict) {
|
|
134
|
+
const f = dict.facets.get(l.facet);
|
|
135
|
+
if (!f)
|
|
136
|
+
throw new CrubalError(`the class line ${l.text} names a facet that isn't defined`, l.line);
|
|
137
|
+
if (f.state === "candidate")
|
|
138
|
+
throw new CrubalError(`${f.key} is a candidate; a class line can only name an active facet`, l.line);
|
|
139
|
+
if (f.state === "retired")
|
|
140
|
+
throw new CrubalError(`${f.key} is retired; a class line can only name an active facet`, l.line);
|
|
141
|
+
const type = l.type;
|
|
142
|
+
if (type && type !== f.type)
|
|
143
|
+
throw new CrubalError(`the class line ${l.text} marks ${f.key} as ${type}, but it is ${f.type}`, l.line);
|
|
144
|
+
if (l.values) {
|
|
145
|
+
const real = new Set((f.values ?? []).map((v) => v.value));
|
|
146
|
+
const extra = l.values.filter((v) => !real.has(v));
|
|
147
|
+
if (extra.length)
|
|
148
|
+
throw new CrubalError(`the class line ${l.text} widens ${f.key}: ${extra.join(", ")} is not one of its values`, l.line);
|
|
149
|
+
}
|
|
150
|
+
if (l.length !== undefined && f.length !== undefined && l.length > f.length)
|
|
151
|
+
throw new CrubalError(`the class line ${l.text} widens ${f.key}'s length`, l.line);
|
|
152
|
+
if (l.pick && f.pick !== "any" && (l.pick === "any" || Number(l.pick) > Number(f.pick)))
|
|
153
|
+
throw new CrubalError(`the class line ${l.text} widens ${f.key}'s pick`, l.line);
|
|
154
|
+
if (l.range && f.range && (Number(l.range.min) < Number(f.range.min) || Number(l.range.max) > Number(f.range.max))) {
|
|
155
|
+
throw new CrubalError(`the class line ${l.text} widens ${f.key}'s range`, l.line);
|
|
156
|
+
}
|
|
157
|
+
if (l.when)
|
|
158
|
+
parseCondition(l.when, l.line);
|
|
159
|
+
void c;
|
|
160
|
+
}
|
|
161
|
+
function findCycle(name, dict, path) {
|
|
162
|
+
if (path.includes(name)) {
|
|
163
|
+
const loop = path.slice(path.indexOf(name));
|
|
164
|
+
const first = dict.classes.get(loop[0]);
|
|
165
|
+
throw new CrubalError(`the classes ${loop.join(" and ")} use each other`, first?.line);
|
|
166
|
+
}
|
|
167
|
+
const c = dict.classes.get(name);
|
|
168
|
+
if (!c)
|
|
169
|
+
return;
|
|
170
|
+
for (const u of c.uses) {
|
|
171
|
+
if (!dict.classes.has(u))
|
|
172
|
+
throw new CrubalError(`${name} uses ${u}, which isn't a class`, c.line);
|
|
173
|
+
findCycle(u, dict, [...path, name]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function order(dict, names, seen = new Set()) {
|
|
177
|
+
const out = [];
|
|
178
|
+
for (const n of names) {
|
|
179
|
+
if (seen.has(n))
|
|
180
|
+
continue;
|
|
181
|
+
const c = dict.classes.get(n);
|
|
182
|
+
if (!c)
|
|
183
|
+
continue;
|
|
184
|
+
seen.add(n);
|
|
185
|
+
out.push(...order(dict, c.uses, seen), c);
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
/** Resolve the meet of classes (a class with its uses, or everything a record wears). */
|
|
190
|
+
export function resolve(dict, names, line) {
|
|
191
|
+
const lines = new Map();
|
|
192
|
+
for (const c of order(dict, names)) {
|
|
193
|
+
for (const l of c.lines) {
|
|
194
|
+
const f = dict.facets.get(l.facet);
|
|
195
|
+
let r = lines.get(l.facet);
|
|
196
|
+
if (!r) {
|
|
197
|
+
r = { facet: l.facet, levels: [], from: [] };
|
|
198
|
+
if (l.section)
|
|
199
|
+
r.section = l.section;
|
|
200
|
+
lines.set(l.facet, r);
|
|
201
|
+
}
|
|
202
|
+
r.from.push({ cls: c.name, line: l });
|
|
203
|
+
if (l.required)
|
|
204
|
+
r.required = true;
|
|
205
|
+
if (l.level && !r.levels.includes(l.level))
|
|
206
|
+
r.levels.push(l.level);
|
|
207
|
+
if (l.when)
|
|
208
|
+
r.when = r.when ? `(${r.when}) and (${l.when})` : l.when;
|
|
209
|
+
if (l.values) {
|
|
210
|
+
const base = r.values ?? (f?.values ?? []).map((v) => v.value);
|
|
211
|
+
const next = base.filter((v) => l.values?.includes(v));
|
|
212
|
+
if (!next.length) {
|
|
213
|
+
const others = r.from.filter((x) => x.line.values && x.cls !== c.name).map((x) => x.cls);
|
|
214
|
+
throw new CrubalError(`${names.join(", ")} allows no value of ${l.facet}: ${[...new Set([...others, c.name])].join(" and ")} have nothing in common`, line ?? l.line);
|
|
215
|
+
}
|
|
216
|
+
r.values = next;
|
|
217
|
+
}
|
|
218
|
+
if (l.length !== undefined)
|
|
219
|
+
r.length = Math.min(r.length ?? Number.POSITIVE_INFINITY, l.length);
|
|
220
|
+
if (l.pick)
|
|
221
|
+
r.pick = r.pick && r.pick !== "any" && (l.pick === "any" || Number(r.pick) < Number(l.pick)) ? r.pick : l.pick;
|
|
222
|
+
if (l.range) {
|
|
223
|
+
const min = r.range ? String(Math.max(Number(r.range.min), Number(l.range.min))) : l.range.min;
|
|
224
|
+
const max = r.range ? String(Math.min(Number(r.range.max), Number(l.range.max))) : l.range.max;
|
|
225
|
+
r.range = { min, max };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return [...lines.values()];
|
|
230
|
+
}
|
|
231
|
+
/** A resolved class as JSON, as the corpus states it. */
|
|
232
|
+
export function resolvedJson(lines) {
|
|
233
|
+
return lines.map((r) => {
|
|
234
|
+
const o = { facet: r.facet };
|
|
235
|
+
if (r.required)
|
|
236
|
+
o.required = true;
|
|
237
|
+
if (r.values)
|
|
238
|
+
o.values = r.values;
|
|
239
|
+
if (r.length !== undefined)
|
|
240
|
+
o.length = String(r.length);
|
|
241
|
+
if (r.pick)
|
|
242
|
+
o.pick = r.pick;
|
|
243
|
+
if (r.range)
|
|
244
|
+
o.range = r.range;
|
|
245
|
+
if (r.levels.length === 1)
|
|
246
|
+
o.level = r.levels[0];
|
|
247
|
+
else if (r.levels.length > 1)
|
|
248
|
+
o.levels = r.levels;
|
|
249
|
+
if (r.when)
|
|
250
|
+
o.when = r.when;
|
|
251
|
+
return o;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function redundantLines(c, dict) {
|
|
255
|
+
const inherited = new Map(resolve(dict, c.uses).map((r) => [r.facet, r]));
|
|
256
|
+
const out = [];
|
|
257
|
+
for (const l of c.lines) {
|
|
258
|
+
if (!inherited.has(l.facet))
|
|
259
|
+
continue;
|
|
260
|
+
const narrows = l.required || l.values || l.length !== undefined || l.pick || l.range || l.level || l.when;
|
|
261
|
+
if (!narrows)
|
|
262
|
+
out.push({ line: l.line, message: `${c.name} restates ${l.facet}, which a used class already asks for` });
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
// ─── Folding (4.3) ───────────────────────────────────────────────────────────
|
|
267
|
+
function keyIndex(dict) {
|
|
268
|
+
const idx = new Map();
|
|
269
|
+
for (const f of dict.facets.values()) {
|
|
270
|
+
for (const s of [f.key, ...f.aliases])
|
|
271
|
+
idx.set(foldKey(s), f.key);
|
|
272
|
+
}
|
|
273
|
+
return idx;
|
|
274
|
+
}
|
|
275
|
+
function foldChoice(f, v) {
|
|
276
|
+
if (typeof v === "string" && f.values) {
|
|
277
|
+
const k = foldKey(v);
|
|
278
|
+
for (const cv of f.values)
|
|
279
|
+
if ([cv.value, ...cv.aliases].some((s) => foldKey(s) === k))
|
|
280
|
+
return cv.value;
|
|
281
|
+
return v;
|
|
282
|
+
}
|
|
283
|
+
if (isObj(v) && "$value" in v)
|
|
284
|
+
return { ...v, $value: foldChoice(f, v.$value) };
|
|
285
|
+
return v;
|
|
286
|
+
}
|
|
287
|
+
function foldQuantity(f, v) {
|
|
288
|
+
if (!isObj(v) || !("$qty" in v) || !f.unit)
|
|
289
|
+
return v;
|
|
290
|
+
const from = unitOf(String(v.unit)) ?? String(v.unit);
|
|
291
|
+
if (from === f.unit)
|
|
292
|
+
return from === v.unit ? v : { $qty: v.$qty, unit: from };
|
|
293
|
+
if (!f.accepts.includes(from) && !f.accepts.includes(String(v.unit)))
|
|
294
|
+
return v;
|
|
295
|
+
const amount = convert(String(v.$qty), from, f.unit, f.places);
|
|
296
|
+
return amount === null ? v : { $qty: amount, unit: f.unit };
|
|
297
|
+
}
|
|
298
|
+
export function foldValue(f, v, dict) {
|
|
299
|
+
if (Array.isArray(v))
|
|
300
|
+
return v.map((x) => foldValue(f, x, dict));
|
|
301
|
+
if (f.type === "choice")
|
|
302
|
+
return foldChoice(f, v);
|
|
303
|
+
if (f.type === "number")
|
|
304
|
+
return foldQuantity(f, v);
|
|
305
|
+
if (f.type === "compound" && isObj(v))
|
|
306
|
+
return foldFields(v, f.children ?? new Map(), dict);
|
|
307
|
+
return v;
|
|
308
|
+
}
|
|
309
|
+
function foldFields(obj, within, dict) {
|
|
310
|
+
const idx = within ? new Map([...within.keys()].map((k) => [foldKey(k), k])) : keyIndex(dict);
|
|
311
|
+
const out = {};
|
|
312
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
313
|
+
const lookup = within ?? dict.facets;
|
|
314
|
+
let key = k;
|
|
315
|
+
let value = v;
|
|
316
|
+
let f = lookup.get(k);
|
|
317
|
+
if (!f) {
|
|
318
|
+
const real = idx.get(foldKey(k));
|
|
319
|
+
const rf = real ? lookup.get(real) : undefined;
|
|
320
|
+
if (real && rf && typeof v === "string") {
|
|
321
|
+
key = real;
|
|
322
|
+
f = rf;
|
|
323
|
+
value = readUnder(rf, v, dict) ?? v;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
out[key] = f ? foldValue(f, value, dict) : value;
|
|
327
|
+
}
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
/** Fold a record: key aliases, value aliases and accepted units become real names (chapter 4.3). */
|
|
331
|
+
export function foldRecord(r, dict) {
|
|
332
|
+
const out = { ...r, values: foldFields(r.values, null, dict) };
|
|
333
|
+
if (r.parts) {
|
|
334
|
+
out.parts = r.parts.map((p) => (isObj(p) && isObj(p.values) ? { ...p, values: foldFields(p.values, null, dict) } : p));
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
const NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?$/;
|
|
339
|
+
const DATE = /^\d{4}(-\d{2}(-\d{2})?)?$/;
|
|
340
|
+
function core(v) {
|
|
341
|
+
return isObj(v) && "$value" in v ? v.$value : v;
|
|
342
|
+
}
|
|
343
|
+
function precisionOf(d) {
|
|
344
|
+
return d.length === 4 ? "year" : d.length === 7 ? "month" : "day";
|
|
345
|
+
}
|
|
346
|
+
/** Check one scalar against its facet: an outcome and an optional flag. */
|
|
347
|
+
export function checkScalar(f, v) {
|
|
348
|
+
const c = core(v);
|
|
349
|
+
if (isObj(c) && "$empty" in c)
|
|
350
|
+
return { outcome: "absorbed" };
|
|
351
|
+
switch (f.type) {
|
|
352
|
+
case "number": {
|
|
353
|
+
let amount = null;
|
|
354
|
+
if (typeof c === "string" && NUMBER.test(c) && !f.unit)
|
|
355
|
+
amount = c;
|
|
356
|
+
if (isObj(c) && "$qty" in c && c.unit === f.unit)
|
|
357
|
+
amount = String(c.$qty);
|
|
358
|
+
if (isObj(c) && "$money" in c && (f.unit === "currency" || c.currency === f.unit))
|
|
359
|
+
amount = String(c.$money);
|
|
360
|
+
if (amount === null)
|
|
361
|
+
return { outcome: "contradiction" };
|
|
362
|
+
if (f.range && (Number(amount) < Number(f.range.min) || Number(amount) > Number(f.range.max)))
|
|
363
|
+
return { outcome: "absorbed", flag: "range" };
|
|
364
|
+
return { outcome: "absorbed" };
|
|
365
|
+
}
|
|
366
|
+
case "date": {
|
|
367
|
+
if (typeof c !== "string" || !DATE.test(c))
|
|
368
|
+
return { outcome: "contradiction" };
|
|
369
|
+
const want = f.precision ?? "any";
|
|
370
|
+
const rank = { year: 0, month: 1, day: 2 };
|
|
371
|
+
if (want !== "any" && rank[precisionOf(c)] < rank[want])
|
|
372
|
+
return { outcome: "absorbed", flag: "precision" };
|
|
373
|
+
return { outcome: "absorbed" };
|
|
374
|
+
}
|
|
375
|
+
case "yes-no":
|
|
376
|
+
return typeof c === "boolean" ? { outcome: "absorbed" } : { outcome: "contradiction" };
|
|
377
|
+
case "link":
|
|
378
|
+
return isObj(c) && "$link" in c ? { outcome: "absorbed" } : { outcome: "contradiction" };
|
|
379
|
+
case "image":
|
|
380
|
+
return isObj(c) && "$image" in c ? { outcome: "absorbed" } : { outcome: "contradiction" };
|
|
381
|
+
case "choice": {
|
|
382
|
+
if (typeof c !== "string")
|
|
383
|
+
return { outcome: "contradiction" };
|
|
384
|
+
if ((f.values ?? []).some((x) => x.value === c))
|
|
385
|
+
return { outcome: "absorbed" };
|
|
386
|
+
return f.fixed ? { outcome: "contradiction" } : { outcome: "new" };
|
|
387
|
+
}
|
|
388
|
+
case "compound":
|
|
389
|
+
return isObj(c) ? { outcome: "absorbed" } : { outcome: "contradiction" };
|
|
390
|
+
default: {
|
|
391
|
+
if (typeof c !== "string")
|
|
392
|
+
return { outcome: "contradiction" };
|
|
393
|
+
if (f.length !== undefined && [...c].length > f.length)
|
|
394
|
+
return { outcome: "absorbed", flag: "length" };
|
|
395
|
+
return { outcome: "absorbed" };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function outcome(record, address, r, cites) {
|
|
400
|
+
const o = { record, address, outcome: r.outcome };
|
|
401
|
+
if (r.flag)
|
|
402
|
+
o.flag = r.flag;
|
|
403
|
+
if (cites)
|
|
404
|
+
o.cites = cites;
|
|
405
|
+
else if (r.outcome === "contradiction")
|
|
406
|
+
o.cites = { type: address.replace(/\[.*$/, "").split(".").at(-1) };
|
|
407
|
+
return o;
|
|
408
|
+
}
|
|
409
|
+
function checkValue(record, f, key, v, address, narrow) {
|
|
410
|
+
const items = Array.isArray(v) ? v : null;
|
|
411
|
+
const pickLimit = narrow?.pick ?? f.pick;
|
|
412
|
+
if (items) {
|
|
413
|
+
if (pickLimit !== "any" && items.length > Number(pickLimit)) {
|
|
414
|
+
return [{ record, address, outcome: "contradiction", cites: { type: f.key } }];
|
|
415
|
+
}
|
|
416
|
+
return items.map((item) => itemOutcome(record, f, key, item, `${address}[${JSON.stringify(itemText(f, item))}]`, narrow));
|
|
417
|
+
}
|
|
418
|
+
return [itemOutcome(record, f, key, v, address, narrow)];
|
|
419
|
+
}
|
|
420
|
+
function citeLine(cls, l) {
|
|
421
|
+
return `${cls}: ${l.text}`;
|
|
422
|
+
}
|
|
423
|
+
function itemOutcome(record, f, _key, v, address, narrow) {
|
|
424
|
+
const base = checkScalar(f, v);
|
|
425
|
+
const c = core(v);
|
|
426
|
+
if (narrow?.values && typeof c === "string" && !(isObj(c) && "$empty" in c) && !narrow.values.includes(c)) {
|
|
427
|
+
const by = narrow.from.find((x) => x.line.values && !x.line.values.includes(c));
|
|
428
|
+
return outcome(record, address, { outcome: "contradiction" }, { rule: by ? citeLine(by.cls, by.line) : f.key });
|
|
429
|
+
}
|
|
430
|
+
return outcome(record, address, base);
|
|
431
|
+
}
|
|
432
|
+
function isEmptyValue(v) {
|
|
433
|
+
return v === undefined || (isObj(v) && v.$empty === "unknown");
|
|
434
|
+
}
|
|
435
|
+
/** Check a record: every value against its facet and worn classes, required facets, and parts. */
|
|
436
|
+
export function checkRecord(r, dict) {
|
|
437
|
+
const outcomes = [];
|
|
438
|
+
const worn = (r.wears ?? []).filter((w) => dict.classes.has(w));
|
|
439
|
+
const resolved = resolve(dict, worn);
|
|
440
|
+
const byFacet = new Map(resolved.map((l) => [l.facet, l]));
|
|
441
|
+
const asked = [];
|
|
442
|
+
const missing = [];
|
|
443
|
+
for (const l of resolved) {
|
|
444
|
+
let holds = true;
|
|
445
|
+
if (l.when)
|
|
446
|
+
holds = evaluate(parseCondition(l.when), r.values);
|
|
447
|
+
if (holds !== true)
|
|
448
|
+
continue;
|
|
449
|
+
asked.push(l.facet);
|
|
450
|
+
if (l.required && isEmptyValue(r.values[l.facet])) {
|
|
451
|
+
missing.push(l.facet);
|
|
452
|
+
const by = l.from.find((x) => x.line.required);
|
|
453
|
+
outcomes.push({ record: r.id, address: l.facet, outcome: "incomplete", cites: { rule: by ? citeLine(by.cls, by.line) : l.facet } });
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
for (const [key, v] of Object.entries(r.values)) {
|
|
457
|
+
const f = dict.facets.get(key);
|
|
458
|
+
if (!f) {
|
|
459
|
+
outcomes.push({ record: r.id, address: key, outcome: "unknown" });
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
outcomes.push(...checkValue(r.id, f, key, v, key, byFacet.get(key)));
|
|
463
|
+
}
|
|
464
|
+
const slots = worn.flatMap((w) => (dict.classes.get(w)?.parts ?? []).map((s) => ({ cls: w, s })));
|
|
465
|
+
for (const p of r.parts ?? []) {
|
|
466
|
+
if (!isObj(p))
|
|
467
|
+
continue;
|
|
468
|
+
const row = String(p.$row);
|
|
469
|
+
const wears = Array.isArray(p.wears) ? p.wears.map(String) : [];
|
|
470
|
+
const slot = slots.find((x) => wears.includes(x.s.wears));
|
|
471
|
+
const at = `parts[${row}]`;
|
|
472
|
+
const cite = slot ? { type: `${slot.cls}: ${slot.s.slot}` } : undefined;
|
|
473
|
+
if (slot && !slot.s.fungible && (row === `${slot.s.slot}s` || row === `${slot.s.slot}es`)) {
|
|
474
|
+
outcomes.push({ record: r.id, address: at, outcome: "contradiction", cites: cite, reason: "plural of a non-fungible slot" });
|
|
475
|
+
}
|
|
476
|
+
const values = isObj(p.values) ? p.values : {};
|
|
477
|
+
for (const [key, v] of Object.entries(values)) {
|
|
478
|
+
const address = `${at}.${key}`;
|
|
479
|
+
if (key === "crubal:count") {
|
|
480
|
+
if (slot && !slot.s.fungible) {
|
|
481
|
+
outcomes.push({ record: r.id, address, outcome: "contradiction", cites: cite, reason: "count on a non-fungible slot" });
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const f = dict.facets.get(key);
|
|
486
|
+
if (!f) {
|
|
487
|
+
outcomes.push({ record: r.id, address, outcome: "unknown" });
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
outcomes.push(...checkValue(r.id, f, key, v, address, undefined));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const summary = { record: r.id, asked, outcome: missing.length ? "incomplete" : "complete" };
|
|
494
|
+
if (missing.length)
|
|
495
|
+
summary.missing = missing;
|
|
496
|
+
return { outcomes, summary };
|
|
497
|
+
}
|
|
498
|
+
//# sourceMappingURL=dictionary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../src/dictionary.ts"],"names":[],"mappings":"A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oBACtI,SAAS;gBACX,CAAC;YACH,CAAC;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,CAAC,CAAC,EAAE,CAAC;gBACP,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7D,SAAS;YACX,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACtG,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Dictionary } from "./defs.ts";
|
|
2
|
+
import type { Json, JsonObject, Record } from "./model.ts";
|
|
3
|
+
import { type Contract, type Keys } from "./store.ts";
|
|
4
|
+
export type Role = {
|
|
5
|
+
name: string;
|
|
6
|
+
audience: string;
|
|
7
|
+
may: {
|
|
8
|
+
[verb: string]: string[];
|
|
9
|
+
};
|
|
10
|
+
line: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function readRoles(source: string): Role[];
|
|
13
|
+
/** Check contracts against a dictionary (7.10). Throws the first problem. */
|
|
14
|
+
export declare function checkContracts(contracts: Contract[], dict: Dictionary, ownPrefix?: string): void;
|
|
15
|
+
export type RunResult = {
|
|
16
|
+
[k: string]: Json;
|
|
17
|
+
};
|
|
18
|
+
export declare class Exchange {
|
|
19
|
+
readonly dict: Dictionary;
|
|
20
|
+
readonly contracts: Map<string, Contract>;
|
|
21
|
+
readonly roles: Role[];
|
|
22
|
+
private records;
|
|
23
|
+
private sent;
|
|
24
|
+
private runs;
|
|
25
|
+
constructor(dict: Dictionary, contracts: Contract[], roles?: Role[]);
|
|
26
|
+
put(r: Record): void;
|
|
27
|
+
get(id: string): Record | undefined;
|
|
28
|
+
/** A record's values with everything above it read through (1.7). */
|
|
29
|
+
effective(r: Record): JsonObject;
|
|
30
|
+
/** The value an address names from a record, with a level prefix reading that level. */
|
|
31
|
+
private read;
|
|
32
|
+
private nextLog;
|
|
33
|
+
/** Steps 1–4 of a send (or form) contract: permission, needs, map out, act once. */
|
|
34
|
+
run(name: string, recordId: string, callerId?: string): RunResult;
|
|
35
|
+
private needsOf;
|
|
36
|
+
/** Steps 5–6 for a receive contract: map the answer back, compare with the record, and land it. */
|
|
37
|
+
receiveRun(name: string, recordId: string, body: string): RunResult;
|
|
38
|
+
/** Offer and take (7.8): only what the offer gives and the take reads flows. */
|
|
39
|
+
take(takeName: string, offerName: string, recordId: string, presenter: Record): RunResult;
|
|
40
|
+
}
|
|
41
|
+
/** Verify a border wrapper from another owner: its log against the owner's key, and its values against the log. */
|
|
42
|
+
export declare function verifyBorder(w: {
|
|
43
|
+
records: Record[];
|
|
44
|
+
log?: JsonObject[];
|
|
45
|
+
}, keys: Keys): JsonObject;
|