@cruba/crubal 0.0.0-stage → 0.2.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 +97 -2
- package/dist/bin/crubal.d.ts +2 -0
- package/dist/bin/crubal.js +103 -0
- package/dist/bin/crubal.js.map +1 -0
- 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/arrival.d.ts +55 -0
- package/dist/src/arrival.js +124 -0
- package/dist/src/arrival.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/bundle.d.ts +66 -0
- package/dist/src/bundle.js +753 -0
- package/dist/src/bundle.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 +28 -0
- package/dist/src/conditions.js +216 -0
- package/dist/src/conditions.js.map +1 -0
- package/dist/src/corpus.d.ts +8 -0
- package/dist/src/corpus.js +1207 -0
- package/dist/src/corpus.js.map +1 -0
- package/dist/src/defs.d.ts +151 -0
- package/dist/src/defs.js +611 -0
- package/dist/src/defs.js.map +1 -0
- package/dist/src/dictionary.d.ts +65 -0
- package/dist/src/dictionary.js +557 -0
- package/dist/src/dictionary.js.map +1 -0
- package/dist/src/exchange.d.ts +236 -0
- package/dist/src/exchange.js +1035 -0
- package/dist/src/exchange.js.map +1 -0
- 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 +27 -0
- package/dist/src/index.js +29 -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/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 +111 -0
- package/dist/src/migrate.js +286 -0
- package/dist/src/migrate.js.map +1 -0
- package/dist/src/model.d.ts +68 -0
- package/dist/src/model.js +188 -0
- package/dist/src/model.js.map +1 -0
- package/dist/src/packages.d.ts +69 -0
- package/dist/src/packages.js +232 -0
- package/dist/src/packages.js.map +1 -0
- package/dist/src/print-text.d.ts +7 -0
- package/dist/src/print-text.js +216 -0
- package/dist/src/print-text.js.map +1 -0
- 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 +10 -0
- package/dist/src/read-text.js +385 -0
- package/dist/src/read-text.js.map +1 -0
- package/dist/src/records.d.ts +31 -0
- package/dist/src/records.js +72 -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 +96 -0
- package/dist/src/rules.js +611 -0
- package/dist/src/rules.js.map +1 -0
- 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 +164 -0
- package/dist/src/store.js +538 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tree.d.ts +35 -0
- package/dist/src/tree.js +159 -0
- package/dist/src/tree.js.map +1 -0
- 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 -0
- package/dist/src/units.js +98 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/views.d.ts +216 -0
- package/dist/src/views.js +761 -0
- package/dist/src/views.js.map +1 -0
- package/package.json +60 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { type ClassLine, type Dictionary } from "./defs.ts";
|
|
2
|
+
import type { Json, JsonObject, Record, Source } from "./model.ts";
|
|
3
|
+
export declare function sha256(text: string): string;
|
|
4
|
+
/** A write's hash: SHA-256 of its canonical form; a redacted write's hash is what it carries (8.5.2). */
|
|
5
|
+
export declare function writeHash(w: Json): string;
|
|
6
|
+
/**
|
|
7
|
+
* An entry's hash (8.5): SHA-256 of its canonical form without `sig`, each write replaced by `sha256:` and
|
|
8
|
+
* its own hash, so a redacted write leaves the entry's hash where it was. A redacted entry's hash is what it
|
|
9
|
+
* carries.
|
|
10
|
+
*/
|
|
11
|
+
export declare function entryHash(entry: JsonObject): string;
|
|
12
|
+
/** Published keys by owner domain: `{ "test.example": { "alg": "Ed25519", "public": "<base64url>" } }`. */
|
|
13
|
+
/** A published signing key (11.7): with `from` and `until` when it was rotated, so it still verifies what it signed. */
|
|
14
|
+
export type Key = {
|
|
15
|
+
alg: string;
|
|
16
|
+
public: string;
|
|
17
|
+
from?: string;
|
|
18
|
+
until?: string;
|
|
19
|
+
};
|
|
20
|
+
export type Keys = {
|
|
21
|
+
[owner: string]: Key | Key[];
|
|
22
|
+
};
|
|
23
|
+
/** The owner's key in force at a moment: the one whose span holds `at`, else an undated one, else the latest. */
|
|
24
|
+
export declare function keyFor(keys: Keys, owner: string, at?: string): Key | undefined;
|
|
25
|
+
/** Does `sig` (base64url) verify over the entry's hash bytes with the owner's Ed25519 key? */
|
|
26
|
+
export declare function verifySig(entry: JsonObject, owner: string, keys: Keys): boolean;
|
|
27
|
+
/** Check a chain's links, and, when the owner's key is known, every entry's signature (8.5). */
|
|
28
|
+
export declare function verifyChain(entries: JsonObject[], keys?: Keys): {
|
|
29
|
+
valid: boolean;
|
|
30
|
+
"breaks-at"?: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
};
|
|
33
|
+
export type MapLine = {
|
|
34
|
+
from: string;
|
|
35
|
+
to: string;
|
|
36
|
+
values: [string, string][];
|
|
37
|
+
line: number;
|
|
38
|
+
valueLines: number[];
|
|
39
|
+
};
|
|
40
|
+
export type Contract = {
|
|
41
|
+
name: string;
|
|
42
|
+
kind: string;
|
|
43
|
+
origin: string;
|
|
44
|
+
prefix?: string;
|
|
45
|
+
reads: MapLine[];
|
|
46
|
+
writes: MapLine[];
|
|
47
|
+
/** A store contract's one map (7.3): `reads` and `writes` are derived from it. */
|
|
48
|
+
stores: MapLine[];
|
|
49
|
+
/** An offer's terms (7.8): reshare, expires, revocable, and what else the package names. */
|
|
50
|
+
terms: {
|
|
51
|
+
[term: string]: string;
|
|
52
|
+
};
|
|
53
|
+
ignore: string[];
|
|
54
|
+
keepRaw: string[];
|
|
55
|
+
absorb: boolean;
|
|
56
|
+
lands: string;
|
|
57
|
+
line: number;
|
|
58
|
+
/** needs: an unnamed class (7.2) */
|
|
59
|
+
needs: ClassLine[];
|
|
60
|
+
gives: string[];
|
|
61
|
+
who?: string;
|
|
62
|
+
when?: string;
|
|
63
|
+
from?: string;
|
|
64
|
+
to?: string;
|
|
65
|
+
mode?: string;
|
|
66
|
+
undo?: string;
|
|
67
|
+
/** The field of their payload that is their own ID for the thing (9.2a). */
|
|
68
|
+
ref?: string;
|
|
69
|
+
/** For a send contract that carries projection streams (12.6.2): the views. */
|
|
70
|
+
stream: string[];
|
|
71
|
+
/** Every part as written, with its line, for the publish checks. */
|
|
72
|
+
parts: {
|
|
73
|
+
[k: string]: string;
|
|
74
|
+
};
|
|
75
|
+
partLines: {
|
|
76
|
+
[k: string]: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** Read `contract:` blocks. */
|
|
80
|
+
export declare function readContracts(source: string): Contract[];
|
|
81
|
+
/** Split a field path into names: `aspects."Run Time"` → ["aspects", "Run Time"]. */
|
|
82
|
+
export declare function fieldPath(path: string): string[];
|
|
83
|
+
export type IntakeOutcome = {
|
|
84
|
+
from: string;
|
|
85
|
+
to?: string;
|
|
86
|
+
outcome: string;
|
|
87
|
+
value?: Json;
|
|
88
|
+
cites?: JsonObject;
|
|
89
|
+
};
|
|
90
|
+
export type IntakeRecord = {
|
|
91
|
+
intake: string;
|
|
92
|
+
contract: string;
|
|
93
|
+
for: string;
|
|
94
|
+
received?: string;
|
|
95
|
+
raw: {
|
|
96
|
+
type: string;
|
|
97
|
+
sha256: string;
|
|
98
|
+
body: string;
|
|
99
|
+
};
|
|
100
|
+
outcomes: IntakeOutcome[];
|
|
101
|
+
};
|
|
102
|
+
/** Keep a payload's exact bytes (3.8): as text when they are valid UTF-8, otherwise as base64. */
|
|
103
|
+
export declare function rawOf(bytes: Uint8Array, type: string): {
|
|
104
|
+
type: string;
|
|
105
|
+
sha256: string;
|
|
106
|
+
body?: string;
|
|
107
|
+
base64?: string;
|
|
108
|
+
};
|
|
109
|
+
/** Replay an intake record from its kept bytes under the current contract (9.6); earlier outcomes stay. */
|
|
110
|
+
export declare function replay(intake: IntakeRecord & {
|
|
111
|
+
replays?: JsonObject[];
|
|
112
|
+
}, c: Contract, dict: Dictionary): IntakeRecord & {
|
|
113
|
+
replays: JsonObject[];
|
|
114
|
+
};
|
|
115
|
+
/** Review by key across every intake record (9.5), and candidate facets proposed by recurrence. */
|
|
116
|
+
export declare function reviewByKey(intakes: {
|
|
117
|
+
for: string;
|
|
118
|
+
outcomes: IntakeOutcome[];
|
|
119
|
+
}[], recur?: number): {
|
|
120
|
+
"by-key": JsonObject[];
|
|
121
|
+
proposals: JsonObject[];
|
|
122
|
+
};
|
|
123
|
+
/** Receive a raw payload through a contract: every field gets exactly one outcome. The bytes are kept. */
|
|
124
|
+
export declare function receive(c: Contract, body: string, forRecord: string, dict: Dictionary, intakeId?: string): IntakeRecord;
|
|
125
|
+
/** Who a source is, for the trust order (11.3): a person, a contract, a party's domain, and its origin. */
|
|
126
|
+
export type Who = {
|
|
127
|
+
source: Source;
|
|
128
|
+
person?: boolean;
|
|
129
|
+
contract?: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Land an intake record's outcomes on a record. Absorbed and conflicting values go through the trust
|
|
133
|
+
* order: the winner is current, the loser is kept as an alternative. Equal values are agreement.
|
|
134
|
+
*/
|
|
135
|
+
export declare function land(r: Record, intake: {
|
|
136
|
+
outcomes: IntakeOutcome[];
|
|
137
|
+
contract?: string; /** a person's write through a form (11.3): ranks as `person` */
|
|
138
|
+
person?: boolean;
|
|
139
|
+
}, source: Source, trust?: string[], facetTrust?: Map<string, string[]>,
|
|
140
|
+
/** The facets declared `transitions: yes` (4.2): a later value of equal or higher trust replaces, never conflicts. */
|
|
141
|
+
transitions?: Set<string>): Record;
|
|
142
|
+
export type PartMatch = {
|
|
143
|
+
parts: JsonObject[];
|
|
144
|
+
review: JsonObject[];
|
|
145
|
+
};
|
|
146
|
+
/** Bind incoming parts to existing ones: by the slot's match child, else review, else a new row. */
|
|
147
|
+
export declare function matchParts(r: Record, incoming: {
|
|
148
|
+
slot: string;
|
|
149
|
+
[k: string]: Json;
|
|
150
|
+
}[], dict: Dictionary): PartMatch;
|
|
151
|
+
export type Observation = JsonObject & {
|
|
152
|
+
obs: string;
|
|
153
|
+
on: string;
|
|
154
|
+
address: string;
|
|
155
|
+
supports: string;
|
|
156
|
+
};
|
|
157
|
+
/** Validate a value from observations: independent witnesses for and against, vetoes, and the state. */
|
|
158
|
+
export declare function validate(r: Record, address: string, observations: Observation[], confirmAt?: number, splitAt?: number): JsonObject;
|
|
159
|
+
/**
|
|
160
|
+
* Version splits proposed (9.7.3): for each value an address's observations contradict, a cluster of at
|
|
161
|
+
* least `splitAt` instances agreeing with each other is a review item `split:<record>`; nothing splits
|
|
162
|
+
* on its own.
|
|
163
|
+
*/
|
|
164
|
+
export declare function proposeSplit(records: Record[], observations: Observation[], splitAt?: number): JsonObject[];
|