@interncom/diplomatic 0.18.3 → 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/cli/shared/types.d.ts +0 -2
- package/dist/web/client.d.ts +10 -4
- package/dist/web/entdb/cached.d.ts +17 -6
- package/dist/web/entdb/entdb.d.ts +1 -4
- package/dist/web/entdb/idb.d.ts +3 -5
- package/dist/web/entdb/manager.d.ts +3 -1
- package/dist/web/entdb/memory.d.ts +1 -3
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.mjs +1 -1
- package/dist/web/react/useClient.d.ts +5 -0
- package/dist/web/shared/types.d.ts +0 -2
- 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
|
@@ -8,14 +8,12 @@ import type { ValStat } from "./valstat.ts";
|
|
|
8
8
|
/** Identity seed brands — defined in seed.ts; re-exported for convenience. */
|
|
9
9
|
export type { MasterSeed, SealedMasterKey } from "./seed.ts";
|
|
10
10
|
export { asSealedMasterKey, MASTER_SEED_LEN, SEALED_MASTER_KEY_LEN, } from "./seed.ts";
|
|
11
|
-
export type GroupID = string;
|
|
12
11
|
declare const entityIDSymbol: unique symbol;
|
|
13
12
|
export type EntityID = Uint8Array & {
|
|
14
13
|
readonly [entityIDSymbol]: true;
|
|
15
14
|
};
|
|
16
15
|
export type SerializedContent = Uint8Array;
|
|
17
16
|
export interface IMsgEntBody<T = unknown> {
|
|
18
|
-
gid?: GroupID;
|
|
19
17
|
pid?: EntityID;
|
|
20
18
|
/**
|
|
21
19
|
* Optional multi-value tags for reverse multi-ref / label lookup (multiEntry-indexed).
|
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.
|
|
@@ -10,19 +10,28 @@ export type OpenEntDBOptions = {
|
|
|
10
10
|
*/
|
|
11
11
|
cache?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Secondary type/pid/
|
|
13
|
+
* Secondary type/pid/tag indexes on the in-memory layer (default true).
|
|
14
14
|
* Speeds up getEntities list queries after a type is warm.
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Status } from "../shared/consts";
|
|
2
2
|
import { ValStat } from "../shared/valstat";
|
|
3
|
-
import { EntityID,
|
|
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
6
|
eid: EntityID;
|
|
@@ -52,9 +52,6 @@ export type TagSpec = string | {
|
|
|
52
52
|
};
|
|
53
53
|
export type EntitiesQuery = {
|
|
54
54
|
type: string;
|
|
55
|
-
} | {
|
|
56
|
-
type: string;
|
|
57
|
-
gid: GroupID;
|
|
58
55
|
} | {
|
|
59
56
|
type: string;
|
|
60
57
|
pid: EntityID;
|
package/dist/web/entdb/idb.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Status } from "../shared/consts";
|
|
2
|
-
import { EntityID,
|
|
2
|
+
import { EntityID, Hash, ICrypto, IOp } from "../shared/types";
|
|
3
3
|
import { ValStat } from "../shared/valstat.ts";
|
|
4
4
|
import { EntitiesQuery, IEntDB, IEntity, IEntRow, TagSpec } from "./entdb";
|
|
5
5
|
export declare const entityTableName = "entities";
|
|
6
6
|
export declare const typeIndexName = "entity_type_created_at";
|
|
7
7
|
export declare const typeUpdatedAtIndexName = "entity_type_updated_at";
|
|
8
|
-
export declare const typeGroupIndexName = "entity_type_group_id";
|
|
9
8
|
export declare const typeParentIndexName = "entity_type_parent_id";
|
|
10
9
|
/** multiEntry index on tgs[]; query by tag then filter by type. */
|
|
11
10
|
export declare const tagsIndexName = "entity_tags";
|
|
12
11
|
/** Shared by main thread and sync worker — must stay in lockstep. */
|
|
13
12
|
export declare const ENT_IDB_NAME = "db";
|
|
14
|
-
/**
|
|
15
|
-
export declare const ENT_IDB_VERSION =
|
|
13
|
+
/** v14: drop [`typ`,`gid`] index (gid superseded by tags). */
|
|
14
|
+
export declare const ENT_IDB_VERSION = 14;
|
|
16
15
|
export declare class EntIDB implements IEntDB {
|
|
17
16
|
db: IDBDatabase | undefined;
|
|
18
17
|
/** In-flight open; coalesces concurrent ensureDb / peer upgrade reopen. */
|
|
@@ -34,7 +33,6 @@ export declare class EntIDB implements IEntDB {
|
|
|
34
33
|
getEnt<T>(eid: EntityID): Promise<ValStat<IEntity<T> | undefined>>;
|
|
35
34
|
/** List live ents of type matching an updatedAt spec. */
|
|
36
35
|
private getByUpdatedAt;
|
|
37
|
-
getGroupMembers<T>(opType: string, gid: GroupID): Promise<ValStat<IEntity<T>[]>>;
|
|
38
36
|
getAllOfType<T>(opType: string): Promise<ValStat<IEntity<T>[]>>;
|
|
39
37
|
getByTag<T>(opType: string, spec: TagSpec): Promise<ValStat<IEntity<T>[]>>;
|
|
40
38
|
private getAllEntities;
|
|
@@ -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;
|
|
@@ -5,7 +5,7 @@ import { ValStat } from "../shared/valstat.ts";
|
|
|
5
5
|
/** Options for {@link EntDBMemory}. */
|
|
6
6
|
export type EntDBMemoryOptions = {
|
|
7
7
|
/**
|
|
8
|
-
* Secondary type / type+pid / type+
|
|
8
|
+
* Secondary type / type+pid / type+tag indexes for list queries.
|
|
9
9
|
* Default true. Disable only if you need to save the index memory.
|
|
10
10
|
*/
|
|
11
11
|
indexes?: boolean;
|
|
@@ -18,8 +18,6 @@ export declare class EntDBMemory implements IEntDB {
|
|
|
18
18
|
private byType;
|
|
19
19
|
/** type → pidKey → eidKey → ent */
|
|
20
20
|
private byTypePid;
|
|
21
|
-
/** type → gid → eidKey → ent */
|
|
22
|
-
private byTypeGid;
|
|
23
21
|
/** type → tag → eidKey → ent */
|
|
24
22
|
private byTypeTag;
|
|
25
23
|
constructor(initEnts?: IEntity[], opts?: EntDBMemoryOptions);
|
package/dist/web/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { Status } from "./shared/consts";
|
|
|
15
15
|
import { hostHTTPTransport, HTTPTransport } from "./shared/http";
|
|
16
16
|
import { TypedEventEmitter } from "./shared/events";
|
|
17
17
|
import { asSealedMasterKey, MASTER_SEED_LEN, SEALED_MASTER_KEY_LEN, type SealedMasterKey } from "./shared/seed";
|
|
18
|
-
import { EntityID,
|
|
18
|
+
import { EntityID, HostHandle, ICrypto, IDeleteParams, IEntRev, IHostConnectionInfo, IMessage, IMutateOp, type IOp, IStateManager, ITransport, IUpdateParams } from "./shared/types";
|
|
19
19
|
import { Enclave } from "./shared/crypto/enclave";
|
|
20
20
|
import { nullStateManager, StateManager } from "./state";
|
|
21
21
|
import { IDBSeedStore } from "./stores/idb/seed";
|
|
@@ -43,5 +43,5 @@ import type { WipeOpts } from "./types";
|
|
|
43
43
|
/** Platform advertises largeBlob (not a guarantee the binding key has it). */
|
|
44
44
|
export { largeBlobCapable } from "./shared/webauthn/largeBlob";
|
|
45
45
|
export { webAuthnLastError } from "./shared/webauthn/common";
|
|
46
|
-
export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, asDHKEReq, asDHKEResp, asSealedMasterKey, b64tob, b64urltob, btob64, btob64url, btoh, CachedEntDB, checksumEntRevs, checksumSet, Clock, cmpBytes, crypto, Decoder, DEFAULT_PRF_SALT, defaultPeekProgressEvery, defaultWebAuthnRpId, eidCodec, Enclave, encodeEntRev, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID,
|
|
46
|
+
export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, asDHKEReq, asDHKEResp, asSealedMasterKey, b64tob, b64urltob, btob64, btob64url, btoh, CachedEntDB, checksumEntRevs, checksumSet, Clock, cmpBytes, crypto, Decoder, DEFAULT_PRF_SALT, defaultPeekProgressEvery, defaultWebAuthnRpId, eidCodec, Enclave, encodeEntRev, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, hostHTTPTransport, htob, HTTPTransport, IDBSeedStore, IDBStore, idleProgress, IEntDB, IEntity, isApldState, isLiveEnt, isPendingApply, isTerminalApplyFailure, isTombstone, IStore, KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, MASTER_SEED_LEN, MemoryStore, normalizeTags, nullEntDB, nullStateManager, openDiplomaticClient, openEntDB, openIDBStore, PairRequest, PasskeySeedStore, prfCapable, PrfSeedStore, revFromEntity, revFromHead, SEALED_MASTER_KEY_LEN, setApld, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
|
|
47
47
|
export type { ApldState, Applier, BundleHost, CachedEntDBOptions, DateSpec, DHKEReq, DHKEResp, EntDBMemoryOptions, HostHandle, HostStatsUpdate, IClient, ICrypto, IDateRange, IDeleteParams, IDiplomaticClientState, IEntRev, IEntRow, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITagRange, ITombstone, ITransport, IUpdateParams, Keyring, KeyringEntry, KeyringRow, ListMsgsOpts, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, PasskeySeedStoreOpts, PersistKeyring, PrfRp, PrfSeedStoreOpts, ReconcileOpts, ReconcileReport, SealedMasterKey, SetSeedOpts, SyncProgressEvent, TagSpec, WipeOpts, WorkerClientOptions, };
|