@cruba/crubal 0.1.0 → 0.3.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/README.md +30 -2
- package/dist/bin/crubal.js +70 -4
- package/dist/bin/crubal.js.map +1 -1
- package/dist/src/access.d.ts +126 -0
- package/dist/src/access.js +517 -0
- package/dist/src/access.js.map +1 -0
- package/dist/src/address.d.ts +29 -0
- package/dist/src/address.js +59 -0
- package/dist/src/address.js.map +1 -0
- package/dist/src/arrival.d.ts +55 -0
- package/dist/src/arrival.js +124 -0
- package/dist/src/arrival.js.map +1 -0
- package/dist/src/bundle.d.ts +66 -0
- package/dist/src/bundle.js +753 -0
- package/dist/src/bundle.js.map +1 -0
- package/dist/src/conditions.d.ts +7 -1
- package/dist/src/conditions.js +52 -11
- package/dist/src/conditions.js.map +1 -1
- package/dist/src/corpus.js +568 -34
- package/dist/src/corpus.js.map +1 -1
- package/dist/src/defs.d.ts +37 -2
- package/dist/src/defs.js +95 -14
- package/dist/src/defs.js.map +1 -1
- package/dist/src/dictionary.d.ts +15 -0
- package/dist/src/dictionary.js +72 -13
- package/dist/src/dictionary.js.map +1 -1
- package/dist/src/exchange.d.ts +204 -11
- package/dist/src/exchange.js +762 -45
- package/dist/src/exchange.js.map +1 -1
- package/dist/src/forms.d.ts +16 -0
- package/dist/src/forms.js +169 -0
- package/dist/src/forms.js.map +1 -0
- package/dist/src/index.d.ts +19 -6
- package/dist/src/index.js +18 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/lifecycle.d.ts +84 -0
- package/dist/src/lifecycle.js +415 -0
- package/dist/src/lifecycle.js.map +1 -0
- package/dist/src/log.d.ts +78 -0
- package/dist/src/log.js +506 -0
- package/dist/src/log.js.map +1 -0
- package/dist/src/migrate.d.ts +24 -1
- package/dist/src/migrate.js +104 -9
- package/dist/src/migrate.js.map +1 -1
- package/dist/src/model.d.ts +33 -1
- package/dist/src/model.js +158 -2
- package/dist/src/model.js.map +1 -1
- package/dist/src/packages.d.ts +44 -0
- package/dist/src/packages.js +137 -3
- package/dist/src/packages.js.map +1 -1
- package/dist/src/print-text.js +22 -0
- package/dist/src/print-text.js.map +1 -1
- package/dist/src/publish.d.ts +27 -0
- package/dist/src/publish.js +275 -0
- package/dist/src/publish.js.map +1 -0
- package/dist/src/read-text.d.ts +2 -0
- package/dist/src/read-text.js +72 -4
- package/dist/src/read-text.js.map +1 -1
- package/dist/src/records.d.ts +32 -0
- package/dist/src/records.js +104 -0
- package/dist/src/records.js.map +1 -0
- package/dist/src/review.d.ts +22 -0
- package/dist/src/review.js +198 -0
- package/dist/src/review.js.map +1 -0
- package/dist/src/rules.d.ts +38 -3
- package/dist/src/rules.js +184 -30
- package/dist/src/rules.js.map +1 -1
- package/dist/src/schedule.d.ts +24 -0
- package/dist/src/schedule.js +126 -0
- package/dist/src/schedule.js.map +1 -0
- package/dist/src/std-packages.d.ts +9 -0
- package/dist/src/std-packages.js +268 -0
- package/dist/src/std-packages.js.map +1 -0
- package/dist/src/store.d.ts +38 -7
- package/dist/src/store.js +166 -24
- package/dist/src/store.js.map +1 -1
- package/dist/src/tree.d.ts +3 -0
- package/dist/src/tree.js +36 -0
- package/dist/src/tree.js.map +1 -1
- package/dist/src/units-table.d.ts +1 -0
- package/dist/src/units-table.js +200 -0
- package/dist/src/units-table.js.map +1 -0
- package/dist/src/units.d.ts +42 -4
- package/dist/src/units.js +91 -30
- package/dist/src/units.js.map +1 -1
- package/dist/src/views.d.ts +116 -6
- package/dist/src/views.js +484 -74
- package/dist/src/views.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAMA,4GAA4G;AAC5G,MAAM,CAAC,MAAM,SAAS,GAAG,8FAA8F,CAAC;AAExH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,S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AE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAW,EAAE,IAAI,CAAC,CAAC;IAC5G,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,MAAM,CAAC,OAAe,EAAE,IAAiC;IACvE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACjD,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,CAAC;IAC/C,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAW,EAAE,IAAI,CAAC,CAAC;IACzE,IAAI,KAAK,EAAE,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAY,CAAC;IACvI,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Dictionary } from "./defs.ts";
|
|
2
|
+
import type { Record, Source } from "./model.ts";
|
|
3
|
+
import type { RecordSet } from "./records.ts";
|
|
4
|
+
import { type Contract, type IntakeRecord } from "./store.ts";
|
|
5
|
+
export type Arrival = {
|
|
6
|
+
outcome: "bound" | "matched" | "held" | "new";
|
|
7
|
+
record?: string;
|
|
8
|
+
candidates?: string[];
|
|
9
|
+
/** The candidates that are archived (9.2a). */
|
|
10
|
+
archived?: string[];
|
|
11
|
+
/** How it was found: `binding`, `identify:<key>`, `match:<keys>`. */
|
|
12
|
+
by?: string;
|
|
13
|
+
ref?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ArrivalStore = {
|
|
16
|
+
records: RecordSet;
|
|
17
|
+
bindings: Map<string, string>;
|
|
18
|
+
};
|
|
19
|
+
/** Follow a merged record to its survivor (1.12). */
|
|
20
|
+
export declare function surviving(store: ArrivalStore, id: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve where a payload lands, fold it there (or hold it), and keep the binding. `mint` names a new
|
|
23
|
+
* record. The caller supplies the level the payload arrives at and, when known, its parent.
|
|
24
|
+
*/
|
|
25
|
+
export declare function arrive(c: Contract, body: string, level: string, store: ArrivalStore, dict: Dictionary, opts: {
|
|
26
|
+
mint: () => string;
|
|
27
|
+
owner: string;
|
|
28
|
+
of?: string;
|
|
29
|
+
within?: string;
|
|
30
|
+
source?: Source;
|
|
31
|
+
intakeId?: string;
|
|
32
|
+
}): {
|
|
33
|
+
arrival: Arrival;
|
|
34
|
+
intake: IntakeRecord;
|
|
35
|
+
record?: Record;
|
|
36
|
+
};
|
|
37
|
+
/** A review decision for a held arrival (9.2a): bind the reference to a record, or to a new one. */
|
|
38
|
+
export declare function decide(c: Contract, held: {
|
|
39
|
+
intake: IntakeRecord;
|
|
40
|
+
ref?: string;
|
|
41
|
+
}, choice: {
|
|
42
|
+
record: string;
|
|
43
|
+
} | {
|
|
44
|
+
new: true;
|
|
45
|
+
}, store: ArrivalStore, dict: Dictionary, opts: {
|
|
46
|
+
mint: () => string;
|
|
47
|
+
owner: string;
|
|
48
|
+
level: string;
|
|
49
|
+
of?: string;
|
|
50
|
+
within?: string;
|
|
51
|
+
source?: Source;
|
|
52
|
+
}): {
|
|
53
|
+
arrival: Arrival;
|
|
54
|
+
record: Record;
|
|
55
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// arrival.ts: finding the record a payload is for (spec 9.2a). A receive or take contract names the field
|
|
2
|
+
// that is the other side's own ID (`ref`); the store keeps a binding for every (contract, ref) it has
|
|
3
|
+
// decided. Resolution runs in order: bound, matched by a strong key, held with candidates, new. A review
|
|
4
|
+
// decision is a binding, so nothing is decided twice; a record is minted only when the arrival commits.
|
|
5
|
+
import { serialize } from "./canonical.js";
|
|
6
|
+
import { fieldPath, land, receive } from "./store.js";
|
|
7
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
8
|
+
/** The value at a payload field path, or undefined. */
|
|
9
|
+
function fieldValue(payload, path) {
|
|
10
|
+
let at = payload;
|
|
11
|
+
for (const name of fieldPath(path)) {
|
|
12
|
+
if (!isObj(at))
|
|
13
|
+
return undefined;
|
|
14
|
+
at = at[name];
|
|
15
|
+
}
|
|
16
|
+
return at;
|
|
17
|
+
}
|
|
18
|
+
/** Follow a merged record to its survivor (1.12). */
|
|
19
|
+
export function surviving(store, id) {
|
|
20
|
+
let cur = id;
|
|
21
|
+
for (let i = 0; i < 100; i++) {
|
|
22
|
+
const r = store.records.get(cur);
|
|
23
|
+
if (!r || r.status?.reason !== "merged" || !r.status.into)
|
|
24
|
+
return cur;
|
|
25
|
+
cur = r.status.into;
|
|
26
|
+
}
|
|
27
|
+
return cur;
|
|
28
|
+
}
|
|
29
|
+
const same = (a, b) => a !== undefined && b !== undefined && serialize(a) === serialize(b);
|
|
30
|
+
/**
|
|
31
|
+
* Resolve where a payload lands, fold it there (or hold it), and keep the binding. `mint` names a new
|
|
32
|
+
* record. The caller supplies the level the payload arrives at and, when known, its parent.
|
|
33
|
+
*/
|
|
34
|
+
export function arrive(c, body, level, store, dict, opts) {
|
|
35
|
+
const intake = receive(c, body, "", dict, opts.intakeId);
|
|
36
|
+
const payload = JSON.parse(body);
|
|
37
|
+
const values = {};
|
|
38
|
+
for (const o of intake.outcomes)
|
|
39
|
+
if (o.to && o.value !== undefined && (o.outcome === "absorbed" || o.outcome === "new"))
|
|
40
|
+
values[o.to] = o.value;
|
|
41
|
+
const ref = c.ref ? fieldValue(payload, c.ref) : undefined;
|
|
42
|
+
const refText = ref === undefined ? undefined : typeof ref === "string" ? ref : serialize(ref);
|
|
43
|
+
const bindKey = refText === undefined ? undefined : `${c.name}|${refText}`;
|
|
44
|
+
const source = opts.source ?? { origin: c.origin, via: intake.intake };
|
|
45
|
+
const atLevel = store.records.atLevel(level);
|
|
46
|
+
const active = (r) => !r.status || r.status.state === "active";
|
|
47
|
+
const finish = (arrival, record) => {
|
|
48
|
+
if (record) {
|
|
49
|
+
const landed = land(record, { outcomes: intake.outcomes, contract: c.name }, source, dict.trust, dict.facetTrust);
|
|
50
|
+
store.records.set(landed.id, landed);
|
|
51
|
+
if (bindKey)
|
|
52
|
+
store.bindings.set(bindKey, landed.id);
|
|
53
|
+
return { arrival: { ...arrival, record: landed.id, ...(refText !== undefined ? { ref: refText } : {}) }, intake: { ...intake, for: landed.id }, record: landed };
|
|
54
|
+
}
|
|
55
|
+
return { arrival: { ...arrival, ...(refText !== undefined ? { ref: refText } : {}) }, intake };
|
|
56
|
+
};
|
|
57
|
+
// 1. Already bound: it goes to that record, whatever its status; a merged one resolves through `into`.
|
|
58
|
+
if (bindKey && store.bindings.has(bindKey)) {
|
|
59
|
+
const id = surviving(store, store.bindings.get(bindKey));
|
|
60
|
+
return finish({ outcome: "bound", by: "binding" }, store.records.get(id));
|
|
61
|
+
}
|
|
62
|
+
// 2. A strong key matches one record, active or archived; a merged one resolves through `into`.
|
|
63
|
+
for (const key of dict.identify.get(level) ?? []) {
|
|
64
|
+
if (values[key] === undefined)
|
|
65
|
+
continue;
|
|
66
|
+
const hits = [...new Set(atLevel.filter((r) => same(r.values[key], values[key])).map((r) => surviving(store, r.id)))];
|
|
67
|
+
if (hits.length === 1)
|
|
68
|
+
return finish({ outcome: "matched", by: `identify:${key}` }, store.records.get(hits[0]));
|
|
69
|
+
if (hits.length > 1)
|
|
70
|
+
return finish({ outcome: "held", candidates: hits.sort(), by: `identify:${key}` }, undefined);
|
|
71
|
+
}
|
|
72
|
+
// 3. Weak keys find candidates: held, nothing minted. An archived candidate is proposed too, flagged, so
|
|
73
|
+
// a discontinued thing coming back under a new reference isn't minted twice; review decides.
|
|
74
|
+
const candidates = new Set();
|
|
75
|
+
const archived = new Set();
|
|
76
|
+
const hows = [];
|
|
77
|
+
for (const group of dict.match.get(level) ?? []) {
|
|
78
|
+
if (group.some((k) => values[k] === undefined))
|
|
79
|
+
continue;
|
|
80
|
+
const hits = atLevel.filter((r) => r.status?.reason !== "merged" && group.every((k) => same(r.values[k], values[k])));
|
|
81
|
+
if (hits.length) {
|
|
82
|
+
for (const h of hits) {
|
|
83
|
+
candidates.add(h.id);
|
|
84
|
+
if (!active(h))
|
|
85
|
+
archived.add(h.id);
|
|
86
|
+
}
|
|
87
|
+
hows.push(group.join("+"));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (candidates.size)
|
|
91
|
+
return finish({ outcome: "held", candidates: [...candidates].sort(), by: `match:${hows.join(";")}`, ...(archived.size ? { archived: [...archived].sort() } : {}) }, undefined);
|
|
92
|
+
// 4. New: minted at commit, and bound.
|
|
93
|
+
const id = opts.mint();
|
|
94
|
+
const rec = { id, kind: dict.levels.get(level) ?? level, level, owner: opts.owner, values: {} };
|
|
95
|
+
if (opts.of)
|
|
96
|
+
rec.of = opts.of;
|
|
97
|
+
if (opts.within)
|
|
98
|
+
rec.within = opts.within;
|
|
99
|
+
return finish({ outcome: "new" }, rec);
|
|
100
|
+
}
|
|
101
|
+
/** A review decision for a held arrival (9.2a): bind the reference to a record, or to a new one. */
|
|
102
|
+
export function decide(c, held, choice, store, dict, opts) {
|
|
103
|
+
const source = opts.source ?? { origin: c.origin, via: held.intake.intake };
|
|
104
|
+
let target;
|
|
105
|
+
if ("record" in choice) {
|
|
106
|
+
const r = store.records.get(surviving(store, choice.record));
|
|
107
|
+
if (!r)
|
|
108
|
+
throw new Error(`no record ${choice.record}`);
|
|
109
|
+
target = r;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
target = { id: opts.mint(), kind: dict.levels.get(opts.level) ?? opts.level, level: opts.level, owner: opts.owner, values: {} };
|
|
113
|
+
if (opts.of)
|
|
114
|
+
target.of = opts.of;
|
|
115
|
+
if (opts.within)
|
|
116
|
+
target.within = opts.within;
|
|
117
|
+
}
|
|
118
|
+
const landed = land(target, { outcomes: held.intake.outcomes, contract: c.name }, source, dict.trust, dict.facetTrust);
|
|
119
|
+
store.records.set(landed.id, landed);
|
|
120
|
+
if (held.ref !== undefined)
|
|
121
|
+
store.bindings.set(`${c.name}|${held.ref}`, landed.id);
|
|
122
|
+
return { arrival: { outcome: "record" in choice ? "bound" : "new", record: landed.id, by: "review", ...(held.ref !== undefined ? { ref: held.ref } : {}) }, record: landed };
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=arrival.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrival.js","sourceRoot":"","sources":["../../src/arrival.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,sGAAsG;AACtG,yGAAyG;AACzG,wGAAwG;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,OAAO,EAAiB,SAAS,EAAqB,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,KAAK,GAAG,CAAC,CAAmB,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAejH,uDAAuD;AACvD,SAAS,UAAU,CAAC,OAAa,EAAE,IAAY;IAC7C,IAAI,EAAE,GAAqB,OAAO,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK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,EAAE;YAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/C,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvH,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;QAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACnF,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC/K,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Instruction } from "./lifecycle.ts";
|
|
2
|
+
import { type Edge, type Permissions } from "./access.ts";
|
|
3
|
+
import { type ClassDef, type ClassLine, type Dictionary, type KindDef } from "./defs.ts";
|
|
4
|
+
import { type Recipe } from "./migrate.ts";
|
|
5
|
+
import type { JsonObject } from "./model.ts";
|
|
6
|
+
import { type PackageInfo, type Utility } from "./packages.ts";
|
|
7
|
+
import { type Rule } from "./rules.ts";
|
|
8
|
+
import { type Contract, type Keys } from "./store.ts";
|
|
9
|
+
import { type Filter, type Shape, type View, type ViewSet } from "./views.ts";
|
|
10
|
+
/** Everything the readers make of one package's text. */
|
|
11
|
+
export type Parsed = {
|
|
12
|
+
info: PackageInfo;
|
|
13
|
+
dict: Dictionary;
|
|
14
|
+
rules: Rule[];
|
|
15
|
+
contracts: Contract[];
|
|
16
|
+
views: ViewSet;
|
|
17
|
+
perms: Permissions;
|
|
18
|
+
edges: Edge[];
|
|
19
|
+
recipes: Recipe[]; /** The instruction blocks a version carries (10.7): issuer → its instructions. */
|
|
20
|
+
instructions: Map<string, Instruction[]>;
|
|
21
|
+
};
|
|
22
|
+
/** Read a package's text with every reader. */
|
|
23
|
+
export declare function parsePackage(source: string): Parsed;
|
|
24
|
+
export declare function kindJson(dict: Dictionary, k: KindDef): JsonObject;
|
|
25
|
+
export declare function classLineJson(l: ClassLine): JsonObject;
|
|
26
|
+
export declare function classJson(c: ClassDef): JsonObject;
|
|
27
|
+
export declare function ruleJson(r: Rule): JsonObject;
|
|
28
|
+
export declare function contractJson(c: Contract): JsonObject;
|
|
29
|
+
export declare function recipeJson(r: Recipe): JsonObject;
|
|
30
|
+
export declare function shapeJson(s: Shape): JsonObject;
|
|
31
|
+
export declare function filterJson(f: Filter): JsonObject;
|
|
32
|
+
export declare function viewJson(v: View): JsonObject;
|
|
33
|
+
/** The `role:` blocks, from the presets and menu items the access reader made of them (12.4). */
|
|
34
|
+
export declare function rolesJson(perms: Permissions): JsonObject[];
|
|
35
|
+
export declare function permissionsJson(perms: Permissions): JsonObject | undefined;
|
|
36
|
+
/** A utility block's JSON form (11.6). */
|
|
37
|
+
export declare function utilityJson(u: Utility): JsonObject;
|
|
38
|
+
/** The whole package as the JSON document, without `hash` and `sig`. */
|
|
39
|
+
export declare function bundleOf(p: Parsed): JsonObject;
|
|
40
|
+
/** Quote a value when the text form would otherwise misread it (2.5). */
|
|
41
|
+
export declare function q(s: string): string;
|
|
42
|
+
/** A class line's text from its settings (5.3), the shorthand marks in their order (4.5). */
|
|
43
|
+
export declare function lineText(l: JsonObject, type?: string): string;
|
|
44
|
+
/** The text form of a bundle: the package header, then every member, in the long form. */
|
|
45
|
+
export declare function printBundle(b: JsonObject): string;
|
|
46
|
+
/** Read a bundle: print it to text and read the text, so there is one parser. */
|
|
47
|
+
export declare function readBundle(b: JsonObject): Parsed & {
|
|
48
|
+
text: string;
|
|
49
|
+
};
|
|
50
|
+
/** Read a bundle's definitions into a dictionary that already holds what the package extends. */
|
|
51
|
+
export declare function readBundleInto(b: JsonObject, into?: Dictionary): Dictionary;
|
|
52
|
+
/** An empty Parsed to read packages onto, in order. */
|
|
53
|
+
export declare function emptyParsed(): Parsed;
|
|
54
|
+
/**
|
|
55
|
+
* Read a bundle onto what is already read (the packages it extends, or the installed packages before the
|
|
56
|
+
* owner's own definitions): the dictionary grows, and a member of the same name replaces the earlier one.
|
|
57
|
+
*/
|
|
58
|
+
export declare function readBundleOnto(bundle: JsonObject, base: Parsed): Parsed;
|
|
59
|
+
export declare function bundleHash(b: JsonObject): string;
|
|
60
|
+
/** Sign a bundle with the owner's Ed25519 private key (the JWK `d`, base64url); sets `hash` and `sig`. */
|
|
61
|
+
export declare function signBundle(b: JsonObject, privateD: string, publicX: string): JsonObject;
|
|
62
|
+
/** Check a bundle's hash and, with the owner's published key, its signature. */
|
|
63
|
+
export declare function verifyBundle(b: JsonObject, keys?: Keys): {
|
|
64
|
+
valid: boolean;
|
|
65
|
+
reason?: string;
|
|
66
|
+
};
|