@interncom/diplomatic 0.8.3 → 0.9.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 +7 -8
- package/dist/web/entdb/cached.d.ts +5 -4
- package/dist/web/entdb/entdb.d.ts +29 -4
- package/dist/web/entdb/idb.d.ts +2 -1
- package/dist/web/entdb/memory.d.ts +6 -4
- package/dist/web/hlc.d.ts +3 -3
- package/dist/web/index.d.ts +4 -4
- package/dist/web/index.mjs +1 -1
- package/dist/web/stores/memory/hosts.d.ts +0 -2
- package/dist/web/sync.d.ts +4 -4
- package/dist/web/types.d.ts +23 -44
- package/dist/web/worker/client.d.ts +3 -3
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,6 @@ import { HostHandle, IHostConnectionInfo, IHostMetadata } from "../../shared/typ
|
|
|
3
3
|
import type { HostStatsUpdate, IHostRow, IHostStore } from "../../types";
|
|
4
4
|
export declare class MemoryHostStore<Handle extends HostHandle> implements IHostStore<Handle> {
|
|
5
5
|
hosts: Map<string, IHostRow<Handle>>;
|
|
6
|
-
/** Serializes recordStats so concurrent peeks do not drop bag/dupe deltas. */
|
|
7
|
-
private statsChain;
|
|
8
6
|
add(info: IHostConnectionInfo<Handle>): Promise<void>;
|
|
9
7
|
touch(label: string, seq: number): Promise<void>;
|
|
10
8
|
recordStats(label: string, u: HostStatsUpdate): Promise<void>;
|
package/dist/web/sync.d.ts
CHANGED
|
@@ -83,10 +83,10 @@ export declare function msg2StoredMsgData({ head, body }: IMsgParts): IStoredMes
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function handleNotif<Handle extends HostHandle>(bytes: Uint8Array, { conn, store, enclave, host, crypto, onProgress, }: ISyncParams<Handle>, scheduleSync: () => void): Promise<void>;
|
|
85
85
|
/**
|
|
86
|
-
* Full host inventory (PEEK from seq 0): set
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* peek — caller should sync() to drain queues.
|
|
86
|
+
* Full host inventory (PEEK from seq 0): set lastSeq; optionally enqueue
|
|
87
|
+
* downloads (msgs on host missing locally) and/or uploads (local msgs missing
|
|
88
|
+
* on host). Returns ephemeral bag tallies + msgcheck (not persisted). Does not
|
|
89
|
+
* pull/push beyond peek — caller should sync() to drain queues.
|
|
90
90
|
*
|
|
91
91
|
* lastSeq is set to the max bag seq in the inventory (0 if empty), including
|
|
92
92
|
* rewind when the host has fewer bags than a prior cursor believed.
|
package/dist/web/types.d.ts
CHANGED
|
@@ -36,38 +36,16 @@ export interface ISeedStore {
|
|
|
36
36
|
}
|
|
37
37
|
export interface IHostRow<Handle extends HostHandle> extends IHostConnectionInfo<Handle>, Partial<IHostMetadata> {
|
|
38
38
|
lastSeq: number;
|
|
39
|
-
/**
|
|
40
|
-
* Bags known on this host (full reconcile sets absolute; incremental peek
|
|
41
|
-
* adds newly seen seqs).
|
|
42
|
-
*/
|
|
43
|
-
numBags: number;
|
|
44
|
-
/**
|
|
45
|
-
* Extra bags beyond one per msg (`Σ max(0, bags_for_msg − 1)`). Absolute on
|
|
46
|
-
* reconcile; +delta on peek when a new duplicate bag for a known msg is seen.
|
|
47
|
-
*/
|
|
48
|
-
numDupes: number;
|
|
49
39
|
}
|
|
50
40
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* `setLastSeq` for a full-inventory absolute cursor (reconcile).
|
|
41
|
+
* Host row cursor write (one store transaction).
|
|
42
|
+
* `lastSeq` only advances unless `setLastSeq` is set.
|
|
54
43
|
*/
|
|
55
44
|
export type HostStatsUpdate = {
|
|
56
45
|
/** New lastSeq if greater than current (incremental peek/push). */
|
|
57
46
|
lastSeq?: number;
|
|
58
47
|
/** Absolute lastSeq, including rewind (full inventory). */
|
|
59
48
|
setLastSeq?: number;
|
|
60
|
-
/** Absolute bag count (full inventory). */
|
|
61
|
-
numBags?: number;
|
|
62
|
-
/** Absolute dupe count (full inventory). */
|
|
63
|
-
numDupes?: number;
|
|
64
|
-
/** Count of newly peeked bags to add to numBags. */
|
|
65
|
-
bagDelta?: number;
|
|
66
|
-
/**
|
|
67
|
-
* Count of newly seen extra bags for a msg already on the host (duplicate
|
|
68
|
-
* bags for the same msg) to add to numDupes.
|
|
69
|
-
*/
|
|
70
|
-
dupeDelta?: number;
|
|
71
49
|
};
|
|
72
50
|
export interface IHostStore<Handle extends HostHandle> {
|
|
73
51
|
add: (host: IHostConnectionInfo<Handle>) => Promise<void>;
|
|
@@ -77,10 +55,7 @@ export interface IHostStore<Handle extends HostHandle> {
|
|
|
77
55
|
list: () => Promise<Iterable<IHostRow<Handle>>>;
|
|
78
56
|
wipe: () => Promise<void>;
|
|
79
57
|
touch: (label: string, seq: number) => Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Apply lastSeq / numBags / numDupes in one transaction so counts do not
|
|
82
|
-
* drift vs the cursor under concurrent peek/push.
|
|
83
|
-
*/
|
|
58
|
+
/** Apply lastSeq updates in one transaction. */
|
|
84
59
|
recordStats: (label: string, u: HostStatsUpdate) => Promise<void>;
|
|
85
60
|
}
|
|
86
61
|
/** Options for {@link IClient.reconcile}. */
|
|
@@ -91,21 +66,26 @@ export type ReconcileOpts = {
|
|
|
91
66
|
push?: boolean;
|
|
92
67
|
/**
|
|
93
68
|
* After inventory, run {@link IClient.sync} to drain upload/download queues.
|
|
94
|
-
* Default true. Pass false for inventory-only
|
|
69
|
+
* Default true. Pass false for inventory-only.
|
|
95
70
|
*/
|
|
96
71
|
sync?: boolean;
|
|
97
72
|
};
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Result of {@link IClient.reconcile}: host msg checksum and bag tallies from
|
|
75
|
+
* the (post-drain) full inventory. Ephemeral — not persisted.
|
|
76
|
+
*/
|
|
77
|
+
export type ReconcileReport = {
|
|
78
|
+
/** Distinct msgs on host (same construction as {@link IClient.msgcheck}). */
|
|
104
79
|
msgcheck: Hash;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
/** Total bags on host (includes duplicate bags for the same msg). */
|
|
81
|
+
numBags: number;
|
|
82
|
+
/** Extra bags beyond one per msg. */
|
|
108
83
|
numDupes: number;
|
|
84
|
+
};
|
|
85
|
+
/** Full inventory details (internal; includes set-diff counts). */
|
|
86
|
+
export type ReconcileResult = ReconcileReport & {
|
|
87
|
+
/** Distinct msgs among bags. */
|
|
88
|
+
uniqueMsgs: number;
|
|
109
89
|
/** Msgs on host not in local archive. */
|
|
110
90
|
missingLocal: number;
|
|
111
91
|
/** Local archive msgs not seen on host. */
|
|
@@ -312,13 +292,12 @@ export interface IClient<Handle extends HostHandle> {
|
|
|
312
292
|
*/
|
|
313
293
|
countMsgs(apld?: ApldState): Promise<number>;
|
|
314
294
|
/**
|
|
315
|
-
* Full host inventory (peek from seq 0)
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* {@link msgcheck}). Read counts via {@link hosts}.
|
|
295
|
+
* Full host inventory (peek from seq 0); optionally enqueue pull/push.
|
|
296
|
+
* Default drains via {@link sync}, then re-inventories. Returns ephemeral
|
|
297
|
+
* host msgcheck + numBags + numDupes (not persisted). Advances lastSeq only
|
|
298
|
+
* on the host row.
|
|
320
299
|
*/
|
|
321
|
-
reconcile(hostLabel: string, opts?: ReconcileOpts): Promise<ValStat<
|
|
300
|
+
reconcile(hostLabel: string, opts?: ReconcileOpts): Promise<ValStat<ReconcileReport>>;
|
|
322
301
|
wipe(): Promise<void>;
|
|
323
302
|
import(file: File): Promise<Status>;
|
|
324
303
|
export(filename: string, extension?: string): Promise<Status>;
|
|
@@ -2,7 +2,7 @@ import { IClock } from "../shared/clock";
|
|
|
2
2
|
import { Status } from "../shared/consts";
|
|
3
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
|
-
import type { ApldState, IClient, IDiplomaticClientState, IDiplomaticClientXferState, IHostRow, IStateEmitter, IStore, IStoredMessage, ListMsgsOpts, ReconcileOpts } from "../types";
|
|
5
|
+
import type { ApldState, IClient, IDiplomaticClientState, IDiplomaticClientXferState, IHostRow, IStateEmitter, IStore, IStoredMessage, ListMsgsOpts, ReconcileOpts, ReconcileReport } from "../types";
|
|
6
6
|
/**
|
|
7
7
|
* Options for attaching to an app-owned sync Worker.
|
|
8
8
|
*
|
|
@@ -121,9 +121,9 @@ export declare class WorkerClient implements IClient<URL> {
|
|
|
121
121
|
countMsgs(apld?: ApldState): Promise<number>;
|
|
122
122
|
/**
|
|
123
123
|
* Full host inventory on the worker (network + crypto off main).
|
|
124
|
-
* Returns ephemeral
|
|
124
|
+
* Returns ephemeral msgcheck + bag counts (not persisted).
|
|
125
125
|
*/
|
|
126
|
-
reconcile(hostLabel: string, opts?: ReconcileOpts): Promise<ValStat<
|
|
126
|
+
reconcile(hostLabel: string, opts?: ReconcileOpts): Promise<ValStat<ReconcileReport>>;
|
|
127
127
|
/** Archive checksum via worker (listKeys + sort + blake3 off main). */
|
|
128
128
|
msgcheck(): Promise<Hash>;
|
|
129
129
|
/**
|