@interncom/diplomatic 0.7.1 → 0.8.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/dist/web/client.d.ts +31 -1
- package/dist/web/entdb/cached.d.ts +3 -1
- package/dist/web/entdb/entdb.d.ts +6 -1
- package/dist/web/entdb/idb.d.ts +2 -1
- package/dist/web/entdb/memory.d.ts +2 -1
- package/dist/web/index.d.ts +2 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/shared/checksum.d.ts +25 -0
- package/dist/web/stores/idb/msgs.d.ts +1 -0
- package/dist/web/stores/memory/msgs.d.ts +1 -0
- package/dist/web/types.d.ts +17 -0
- package/dist/web/worker/client.d.ts +11 -1
- package/dist/web/worker/protocol.d.ts +10 -0
- package/dist/web/worker/runtime.d.ts +1 -0
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Hash, ICrypto, IEntRev } from "./types.ts";
|
|
2
|
+
import { type ValStat } from "./valstat.ts";
|
|
3
|
+
/** Lexicographic compare of raw bytes (unsigned). */
|
|
4
|
+
export declare function cmpBytes(a: Uint8Array, b: Uint8Array): number;
|
|
5
|
+
/**
|
|
6
|
+
* Checksum of a set of byte records (hashes, encoded revs, …).
|
|
7
|
+
*
|
|
8
|
+
* Preimage: blake3( concat( sort_lexicographic(items) ) ).
|
|
9
|
+
* Empty set → blake3(empty). Order of the input iterable is ignored.
|
|
10
|
+
*
|
|
11
|
+
* Equal-length items: concat is trivially unambiguous.
|
|
12
|
+
* Variable-length items: only unambiguous if each item is self-delimiting
|
|
13
|
+
* (e.g. encodeEntRev) so a concat has a unique parse.
|
|
14
|
+
*/
|
|
15
|
+
export declare function checksumSet(items: Iterable<Uint8Array>, crypto: ICrypto): Promise<Hash>;
|
|
16
|
+
/**
|
|
17
|
+
* Wire preimage for one EntDB frontier row:
|
|
18
|
+
* varbytes(eid) ‖ date(updatedAt) ‖ varint(ctr). Self-delimiting.
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeEntRev(rev: IEntRev): ValStat<Uint8Array>;
|
|
21
|
+
/**
|
|
22
|
+
* Frontier checksum of live EntDB rows: encode each rev, then
|
|
23
|
+
* {@link checksumSet}.
|
|
24
|
+
*/
|
|
25
|
+
export declare function checksumEntRevs(revs: Iterable<IEntRev>, crypto: ICrypto): Promise<ValStat<Hash>>;
|
|
@@ -11,6 +11,7 @@ export declare class IDBMessageStore implements IMessageStore {
|
|
|
11
11
|
get(key: Hash): Promise<IStoredMessage | undefined>;
|
|
12
12
|
has(key: Hash): Promise<boolean>;
|
|
13
13
|
list(apld?: ApldState): Promise<IStoredMessage[]>;
|
|
14
|
+
listKeys(): Promise<Hash[]>;
|
|
14
15
|
last(eid: EntityID): Promise<IStoredMessage | undefined>;
|
|
15
16
|
markApplied(keys: Iterable<Hash>): Promise<void>;
|
|
16
17
|
markFailed(entries: Iterable<{
|
|
@@ -11,6 +11,7 @@ export declare class MemoryMessageStore implements IMessageStore {
|
|
|
11
11
|
get(key: Hash): Promise<IStoredMessage | undefined>;
|
|
12
12
|
has(key: Hash): Promise<boolean>;
|
|
13
13
|
list(apld?: ApldState): Promise<IStoredMessage[]>;
|
|
14
|
+
listKeys(): Promise<Hash[]>;
|
|
14
15
|
last(eid: EntityID): Promise<IStoredMessage | undefined>;
|
|
15
16
|
markApplied(keys: Iterable<Hash>): Promise<void>;
|
|
16
17
|
markFailed(entries: Iterable<{
|
package/dist/web/types.d.ts
CHANGED
|
@@ -159,6 +159,8 @@ export interface IMessageStore {
|
|
|
159
159
|
* diagnostics). Omit for all messages.
|
|
160
160
|
*/
|
|
161
161
|
list: (apld?: ApldState) => Promise<IStoredMessage[]>;
|
|
162
|
+
/** Archive keys only (head hashes). Prefer over {@link list} for checksums. */
|
|
163
|
+
listKeys: () => Promise<Hash[]>;
|
|
162
164
|
last: (eid: EntityID) => Promise<IStoredMessage | undefined>;
|
|
163
165
|
/** Mark archive rows as applied ({@link APLD_APPLIED}). */
|
|
164
166
|
markApplied: (keys: Iterable<Hash>) => Promise<void>;
|
|
@@ -202,6 +204,21 @@ export interface IClient<Handle extends HostHandle> {
|
|
|
202
204
|
/** Allocate an entity id (optional 8-byte id material; else random). */
|
|
203
205
|
genEID(id?: Uint8Array): Promise<ValStat<EntityID>>;
|
|
204
206
|
sync(): Promise<Status>;
|
|
207
|
+
/**
|
|
208
|
+
* Wipe application state (e.g. EntDB) and rebuild it by replaying the local
|
|
209
|
+
* message archive. By default, first peeks the full host header list (seq 0)
|
|
210
|
+
* and pulls any missing bags so the archive is complete before replay.
|
|
211
|
+
* Pass `{ checkHost: false }` to skip the host inventory (local-only).
|
|
212
|
+
*/
|
|
213
|
+
rebuild(options?: {
|
|
214
|
+
checkHost?: boolean;
|
|
215
|
+
}): Promise<Status>;
|
|
216
|
+
/**
|
|
217
|
+
* Checksum of the local msg archive as a set of head hashes.
|
|
218
|
+
* Decodes store keys to raw hashes, sorts lexicographically, blake3(concat).
|
|
219
|
+
* Key encoding (e.g. b64 in IDB) is independent of this definition.
|
|
220
|
+
*/
|
|
221
|
+
msgcheck(): Promise<Hash>;
|
|
205
222
|
wipe(): Promise<void>;
|
|
206
223
|
import(file: File): Promise<Status>;
|
|
207
224
|
export(filename: string, extension?: string): Promise<Status>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IClock } from "../shared/clock";
|
|
2
2
|
import { Status } from "../shared/consts";
|
|
3
|
-
import type { EntityID, IDeleteParams, IEntRev, IHostConnectionInfo, IInsertParams, IMessageHead, IStateManager, IUpdateParams, MasterSeed, SerializedContent } from "../shared/types";
|
|
3
|
+
import type { EntityID, Hash, IDeleteParams, IEntRev, IHostConnectionInfo, IInsertParams, IMessageHead, IStateManager, IUpdateParams, MasterSeed, SerializedContent } from "../shared/types";
|
|
4
4
|
import type { ValStat } from "../shared/valstat";
|
|
5
5
|
import type { IClient, IDiplomaticClientState, IDiplomaticClientXferState, IHostRow, IStateEmitter, IStore } from "../types";
|
|
6
6
|
/**
|
|
@@ -113,6 +113,16 @@ export declare class WorkerClient implements IClient<URL> {
|
|
|
113
113
|
delete(op: IDeleteParams): Promise<ValStat<IMessageHead>>;
|
|
114
114
|
genEID(id?: Uint8Array): Promise<ValStat<EntityID>>;
|
|
115
115
|
sync(): Promise<Status>;
|
|
116
|
+
rebuild(options?: {
|
|
117
|
+
checkHost?: boolean;
|
|
118
|
+
}): Promise<Status>;
|
|
119
|
+
/** Archive checksum via worker (listKeys + sort + blake3 off main). */
|
|
120
|
+
msgcheck(): Promise<Hash>;
|
|
121
|
+
/**
|
|
122
|
+
* EntDB frontier checksum off main (eid+upd+ctr). Not on IClient —
|
|
123
|
+
* SyncClient has no EntDB; use entDB.checksum(crypto) on the main path.
|
|
124
|
+
*/
|
|
125
|
+
entcheck(): Promise<Hash>;
|
|
116
126
|
wipe(): Promise<void>;
|
|
117
127
|
import(file: File): Promise<Status>;
|
|
118
128
|
export(filename: string, _extension?: string): Promise<Status>;
|
|
@@ -34,6 +34,16 @@ export type WorkerCmd = {
|
|
|
34
34
|
} | {
|
|
35
35
|
id: number;
|
|
36
36
|
op: "sync";
|
|
37
|
+
} | {
|
|
38
|
+
id: number;
|
|
39
|
+
op: "rebuild";
|
|
40
|
+
checkHost?: boolean;
|
|
41
|
+
} | {
|
|
42
|
+
id: number;
|
|
43
|
+
op: "msgcheck";
|
|
44
|
+
} | {
|
|
45
|
+
id: number;
|
|
46
|
+
op: "entcheck";
|
|
37
47
|
} | {
|
|
38
48
|
id: number;
|
|
39
49
|
op: "wipe";
|
|
@@ -3,6 +3,7 @@ import type { WorkerCmd, WorkerEvent } from "./protocol";
|
|
|
3
3
|
export type PostFn = (msg: WorkerEvent, transfer?: Transferable[]) => void;
|
|
4
4
|
export declare class WorkerRuntime {
|
|
5
5
|
private client;
|
|
6
|
+
private entDB;
|
|
6
7
|
private post;
|
|
7
8
|
/** Resolves when init finishes (success or failure). Cmds wait on this. */
|
|
8
9
|
private whenReady;
|