@interncom/diplomatic 0.19.0 → 0.19.1
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 +10 -4
- package/dist/web/entdb/cached.d.ts +16 -5
- package/dist/web/entdb/manager.d.ts +3 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/react/useClient.d.ts +5 -0
- package/dist/web/state.d.ts +3 -2
- package/dist/web/worker/client.d.ts +1 -1
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
package/dist/web/client.d.ts
CHANGED
|
@@ -61,10 +61,14 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
61
61
|
/**
|
|
62
62
|
* Persist msgs (APLD_PENDING), exec into app state, then optionally enq upload.
|
|
63
63
|
*
|
|
64
|
-
* Order (
|
|
65
|
-
* 1)
|
|
66
|
-
*
|
|
67
|
-
*
|
|
64
|
+
* Order (do not invert — UI notify depends on it):
|
|
65
|
+
* 1) Kick off state.apply (CachedEntDB emits in the sync prefix of apply;
|
|
66
|
+
* the returned Promise is durable EntDB + reconcile).
|
|
67
|
+
* 2) Durable archive (messages.add).
|
|
68
|
+
* 3) Await apply + mark APLD_APPLIED/APLD_ERROR.
|
|
69
|
+
* 4) Upload queue.
|
|
70
|
+
* Crash between 2–3 → drainApplyQueue recovers.
|
|
71
|
+
* Awaiting apply before archive makes the UI wait on EntDB IDB.
|
|
68
72
|
*
|
|
69
73
|
* Serialized on applyChain (with local mutates).
|
|
70
74
|
*/
|
|
@@ -95,6 +99,8 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
95
99
|
* without validating length alignment.
|
|
96
100
|
*/
|
|
97
101
|
private applyStored;
|
|
102
|
+
/** Mark archive rows APPLIED / ERROR from apply stats (aligned with keys). */
|
|
103
|
+
private markApplyStats;
|
|
98
104
|
insertRaw(bod: EncodedMessage): Promise<ValStat<IMessageHead>>;
|
|
99
105
|
/**
|
|
100
106
|
* Build the next update/delete msg from prior. Pure: no archive I/O.
|
|
@@ -15,14 +15,23 @@ export type OpenEntDBOptions = {
|
|
|
15
15
|
* Ignored when `cache` is false.
|
|
16
16
|
*/
|
|
17
17
|
indexes?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Notify UI as soon as mem is patched, before durable IDB (default true).
|
|
20
|
+
* Set false to notify only after durable commit. Ignored when `cache` is false.
|
|
21
|
+
*/
|
|
22
|
+
optimistic?: boolean;
|
|
18
23
|
};
|
|
19
24
|
export type CachedEntDBOptions = {
|
|
20
25
|
/** Secondary mem indexes (default true). See {@link OpenEntDBOptions.indexes}. */
|
|
21
26
|
indexes?: boolean;
|
|
27
|
+
/** Immediate mem notify (default true). See {@link OpenEntDBOptions.optimistic}. */
|
|
28
|
+
optimistic?: boolean;
|
|
22
29
|
};
|
|
23
30
|
/**
|
|
24
31
|
* Open EntDB for the app (or worker). Single entry point.
|
|
25
|
-
* Default: cached with mem indexes
|
|
32
|
+
* Default: cached with mem indexes and optimistic notify.
|
|
33
|
+
* Pass `{ cache: false }` for durable IDB only.
|
|
34
|
+
* Pass `{ optimistic: false }` to notify only after durable commit.
|
|
26
35
|
*/
|
|
27
36
|
export declare function openEntDB(opts?: OpenEntDBOptions): Promise<IEntDB>;
|
|
28
37
|
export declare class CachedEntDB implements IEntDB {
|
|
@@ -31,6 +40,7 @@ export declare class CachedEntDB implements IEntDB {
|
|
|
31
40
|
private warmed;
|
|
32
41
|
private listeners;
|
|
33
42
|
private chain;
|
|
43
|
+
private optimistic;
|
|
34
44
|
constructor(durable: IEntDB, init?: IEntity[], opts?: CachedEntDBOptions);
|
|
35
45
|
/** UI / StateManager: fired when mem changes (immediate apply or durable ingest). */
|
|
36
46
|
subscribe(listener: EntChangeListener): () => void;
|
|
@@ -39,8 +49,8 @@ export declare class CachedEntDB implements IEntDB {
|
|
|
39
49
|
/**
|
|
40
50
|
* Fan-out write: mem (immediate notify) + durable, then reconcile mem
|
|
41
51
|
* from durable for the ops' eids (second notify only if something moved).
|
|
42
|
-
*
|
|
43
|
-
*
|
|
52
|
+
* Not `async`: the mem patch+emit below must run before any await.
|
|
53
|
+
* `{ optimistic: false }`: skip the sync prefix; notify after durable.
|
|
44
54
|
*/
|
|
45
55
|
apply(ops: IOp[]): Promise<import("./entdb").ApplyResult>;
|
|
46
56
|
clear(): Promise<Status>;
|
|
@@ -52,8 +62,9 @@ export declare class CachedEntDB implements IEntDB {
|
|
|
52
62
|
/**
|
|
53
63
|
* Install durable truth for each eid into mem (live or tombstone).
|
|
54
64
|
* When `snap` is set (post-apply reconcile), skip eids whose mem stamp
|
|
55
|
-
* moved — a later apply owns them.
|
|
56
|
-
* a newer in-flight
|
|
65
|
+
* moved — a later apply owns them. Always skip if mem is newer than
|
|
66
|
+
* durable (overlapping optimistic apply). Never replace a newer in-flight
|
|
67
|
+
* mem row with older durable truth.
|
|
57
68
|
*/
|
|
58
69
|
private pullEids;
|
|
59
70
|
private warmType;
|
|
@@ -3,6 +3,8 @@ import type { IEntDB } from "./entdb";
|
|
|
3
3
|
/**
|
|
4
4
|
* Build a StateManager for an EntDB.
|
|
5
5
|
* When `edb` is a {@link CachedEntDB}, type notifies come from the cache
|
|
6
|
-
* (
|
|
6
|
+
* subscribe path (optimistic apply + durable reconcile / peer ingest).
|
|
7
|
+
* cacheDriven: StateManager.apply must not emit after the applier Promise
|
|
8
|
+
* settles — that would delay UI until durable IDB. Subscribe is the notify.
|
|
7
9
|
*/
|
|
8
10
|
export declare function entStateManager(edb: IEntDB): StateManager;
|