@interncom/diplomatic 0.19.2 → 0.21.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/cli/index.mjs +2 -2
- package/dist/cli/shared/codecs/messageHead.d.ts +2 -8
- package/dist/cli/shared/crypto/enclave.d.ts +8 -1
- package/dist/cli/shared/crypto/noble.d.ts +2 -2
- package/dist/cli/shared/message.d.ts +8 -5
- package/dist/cli/shared/types.d.ts +13 -3
- package/dist/web/client.d.ts +16 -15
- package/dist/web/entdb/cached.d.ts +19 -2
- package/dist/web/entdb/entdb.d.ts +1 -0
- package/dist/web/entdb/manager.d.ts +3 -3
- package/dist/web/index.mjs +1 -1
- package/dist/web/openClient.d.ts +5 -0
- package/dist/web/react/useClient.d.ts +5 -0
- package/dist/web/shared/codecs/messageHead.d.ts +2 -8
- package/dist/web/shared/crypto/enclave.d.ts +8 -1
- package/dist/web/shared/crypto/noble.d.ts +2 -2
- package/dist/web/shared/exim.d.ts +4 -1
- package/dist/web/shared/message.d.ts +8 -5
- package/dist/web/shared/types.d.ts +13 -3
- package/dist/web/types.d.ts +6 -4
- package/dist/web/verbose.d.ts +4 -0
- package/dist/web/worker/client.d.ts +2 -2
- package/dist/web/worker.mjs +1 -1
- package/package.json +2 -1
package/dist/web/client.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
20
20
|
private onScheduleSync?;
|
|
21
21
|
connections: Map<string, DiplomaticClientAPI<Handle>>;
|
|
22
22
|
/**
|
|
23
|
-
* Serializes
|
|
24
|
-
* not interleave
|
|
23
|
+
* Serializes archive + markApplied so concurrent drainApplyQueue / apply
|
|
24
|
+
* do not interleave those IDB writes. Mem notify is kicked before this
|
|
25
|
+
* chain so a prior persist cannot delay the list.
|
|
25
26
|
*/
|
|
26
27
|
private applyChain;
|
|
27
28
|
/**
|
|
@@ -62,20 +63,20 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
62
63
|
* Persist msgs (APLD_PENDING), exec into app state, then optionally enq upload.
|
|
63
64
|
*
|
|
64
65
|
* Order (do not invert — UI notify depends on it):
|
|
65
|
-
* 1) Kick
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* Awaiting apply before archive
|
|
72
|
-
*
|
|
73
|
-
* Serialized on applyChain (with local mutates).
|
|
66
|
+
* 1) Kick state.apply *before* applyChain. CachedEntDB patches mem and
|
|
67
|
+
* notifies after the next paint. A prior job's
|
|
68
|
+
* archive / persist / markApplied must not delay the list.
|
|
69
|
+
* 2) Serialize archive (messages.add) + await apply + markApplied on
|
|
70
|
+
* applyChain (crash between archive and mark → drainApplyQueue).
|
|
71
|
+
* 3) Upload queue.
|
|
72
|
+
* Awaiting apply before archive, or waiting on applyChain before kicking
|
|
73
|
+
* apply, makes the UI wait on IndexedDB.
|
|
74
74
|
*/
|
|
75
75
|
private apply;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
77
|
+
* Archive + await a pre-kicked state.apply + markApplied.
|
|
78
|
+
* Caller must already hold applyChain. `applyP` is kicked first so mem
|
|
79
|
+
* notify is not serialized behind a prior job's IDB.
|
|
79
80
|
*/
|
|
80
81
|
private doApply;
|
|
81
82
|
private enqueueApplyJob;
|
|
@@ -101,7 +102,7 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
101
102
|
private applyStored;
|
|
102
103
|
/** Mark archive rows APPLIED / ERROR from apply stats (aligned with keys). */
|
|
103
104
|
private markApplyStats;
|
|
104
|
-
insertRaw(bod: EncodedMessage): Promise<ValStat<IMessageHead>>;
|
|
105
|
+
insertRaw(bod: EncodedMessage, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
105
106
|
/**
|
|
106
107
|
* Build the next update/delete msg from prior. Pure: no archive I/O.
|
|
107
108
|
* Returns ClockOutOfSync if prior is in the future (caller handles force).
|
|
@@ -119,7 +120,7 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
|
|
|
119
120
|
* Replacement keeps the same id bytes with a new created-at of now.
|
|
120
121
|
*/
|
|
121
122
|
private updateWithSkew;
|
|
122
|
-
updateRaw(prior: IEntRev, bod: EncodedMessage | undefined, force?: boolean): Promise<ValStat<IMessageHead>>;
|
|
123
|
+
updateRaw(prior: IEntRev, bod: EncodedMessage | undefined, force?: boolean, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
123
124
|
insert<T = unknown>(op: IInsertParams<T>): Promise<ValStat<IMessageHead>>;
|
|
124
125
|
update<T = unknown>(op: IUpdateParams<T>): Promise<ValStat<IMessageHead>>;
|
|
125
126
|
/**
|
|
@@ -20,6 +20,11 @@ export type OpenEntDBOptions = {
|
|
|
20
20
|
* Set false to notify only after durable commit. Ignored when `cache` is false.
|
|
21
21
|
*/
|
|
22
22
|
optimistic?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Timed `[dip]` traces for apply / list / persist (default false).
|
|
25
|
+
* Process-wide; also accepted on openDiplomaticClient / useClient.
|
|
26
|
+
*/
|
|
27
|
+
verbose?: boolean;
|
|
23
28
|
};
|
|
24
29
|
export type CachedEntDBOptions = {
|
|
25
30
|
/** Secondary mem indexes (default true). See {@link OpenEntDBOptions.indexes}. */
|
|
@@ -32,6 +37,7 @@ export type CachedEntDBOptions = {
|
|
|
32
37
|
* Default: cached with mem indexes and optimistic notify.
|
|
33
38
|
* Pass `{ cache: false }` for durable IDB only.
|
|
34
39
|
* Pass `{ optimistic: false }` to notify only after durable commit.
|
|
40
|
+
* Pass `{ verbose: true }` for `[dip]` timings (apply, list, persist).
|
|
35
41
|
*/
|
|
36
42
|
export declare function openEntDB(opts?: OpenEntDBOptions): Promise<IEntDB>;
|
|
37
43
|
export declare class CachedEntDB implements IEntDB {
|
|
@@ -41,14 +47,18 @@ export declare class CachedEntDB implements IEntDB {
|
|
|
41
47
|
private listeners;
|
|
42
48
|
private chain;
|
|
43
49
|
private optimistic;
|
|
50
|
+
/** Optimistic applies whose durable persist has not finished. */
|
|
51
|
+
private inflight;
|
|
52
|
+
/** In-flight warmType per type (not on the persist/ingest chain). */
|
|
53
|
+
private warmP;
|
|
44
54
|
constructor(durable: IEntDB, init?: IEntity[], opts?: CachedEntDBOptions);
|
|
45
55
|
/** UI / StateManager: fired when mem changes (immediate apply or durable ingest). */
|
|
46
56
|
subscribe(listener: EntChangeListener): () => void;
|
|
47
57
|
private emit;
|
|
48
58
|
private run;
|
|
49
59
|
/**
|
|
50
|
-
* Fan-out write: patch mem, queue durable, notify UI
|
|
51
|
-
*
|
|
60
|
+
* Fan-out write: patch mem, queue durable, notify UI after the next paint.
|
|
61
|
+
* Not `async`: mem patch must run before any await.
|
|
52
62
|
* `{ optimistic: false }`: skip the mem prefix; notify after durable.
|
|
53
63
|
*/
|
|
54
64
|
apply(ops: IOp[]): Promise<import("./entdb").ApplyResult>;
|
|
@@ -67,6 +77,13 @@ export declare class CachedEntDB implements IEntDB {
|
|
|
67
77
|
*/
|
|
68
78
|
private pullEids;
|
|
69
79
|
private warmType;
|
|
80
|
+
/**
|
|
81
|
+
* Load a type from durable into mem. Not on the persist/ingest chain —
|
|
82
|
+
* first UI list must not wait for dirty-eid pull after worker sync.
|
|
83
|
+
*/
|
|
84
|
+
private beginWarm;
|
|
85
|
+
/** Background warm + notify. Does not block the caller. */
|
|
86
|
+
private ensureWarm;
|
|
70
87
|
getRow<T>(eid: EntityID): Promise<ValStat<IEntRow<T> | undefined>>;
|
|
71
88
|
getEnt<T>(eid: EntityID): Promise<ValStat<IEntity<T> | undefined>>;
|
|
72
89
|
getEntities<T>(query: EntitiesQuery): Promise<ValStat<IEntity<T>[]>>;
|
|
@@ -3,6 +3,7 @@ import { ValStat } from "../shared/valstat";
|
|
|
3
3
|
import { EntityID, Hash, ICrypto, IEntRev, IMessageHead, IMsgEntBody, IOp } from "../shared/types";
|
|
4
4
|
export { entStateManager } from "./manager.ts";
|
|
5
5
|
export interface IEntity<T = unknown> extends Omit<IMsgEntBody<T>, "body"> {
|
|
6
|
+
type: string;
|
|
6
7
|
eid: EntityID;
|
|
7
8
|
updatedAt: Date;
|
|
8
9
|
createdAt: Date;
|
|
@@ -3,8 +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
|
-
* subscribe path (mem patch +
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* subscribe path (mem patch + notify after paint, then durable persist).
|
|
7
|
+
* cacheDriven: StateManager.apply must not emit after the applier Promise
|
|
8
|
+
* settles — that emit would wait until durable IDB.
|
|
9
9
|
*/
|
|
10
10
|
export declare function entStateManager(edb: IEntDB): StateManager;
|