@interncom/diplomatic 0.4.5 → 0.6.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/cli/index.mjs +2 -2
- package/dist/cli/shared/singleton.d.ts +2 -1
- package/dist/cli/shared/types.d.ts +30 -3
- package/dist/web/client.d.ts +46 -10
- package/dist/web/entdb/cached.d.ts +52 -0
- package/dist/web/entdb/entdb.d.ts +15 -7
- package/dist/web/entdb/idb.d.ts +2 -0
- package/dist/web/entdb/manager.d.ts +8 -0
- package/dist/web/entdb/memory.d.ts +1 -0
- package/dist/web/index.d.ts +8 -7
- package/dist/web/index.mjs +1 -1
- package/dist/web/shared/singleton.d.ts +2 -1
- package/dist/web/shared/types.d.ts +30 -3
- package/dist/web/state.d.ts +24 -5
- package/dist/web/stores/idb/msgs.d.ts +6 -3
- package/dist/web/stores/idb/store.d.ts +3 -2
- package/dist/web/stores/memory/msgs.d.ts +6 -3
- package/dist/web/types.d.ts +61 -23
- package/dist/web/worker/client.d.ts +25 -5
- package/dist/web/worker/protocol.d.ts +5 -38
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Status } from "../shared/consts";
|
|
2
2
|
import { ValStat } from "../shared/valstat";
|
|
3
|
-
import { EntityID, GroupID, IMsgEntBody, IOp } from "../shared/types";
|
|
4
|
-
|
|
3
|
+
import { EntityID, GroupID, IEntRev, IMessageHead, IMsgEntBody, IOp } from "../shared/types";
|
|
4
|
+
export { entStateManager } from "./manager.ts";
|
|
5
5
|
export interface IEntity<T = unknown> extends Omit<IMsgEntBody<T>, "body"> {
|
|
6
6
|
eid: EntityID;
|
|
7
7
|
updatedAt: Date;
|
|
@@ -25,11 +25,16 @@ export type EntitiesQuery = {
|
|
|
25
25
|
type: string;
|
|
26
26
|
updatedBetween: IDateRange;
|
|
27
27
|
};
|
|
28
|
+
/** Result of applying ops to EntDB. */
|
|
29
|
+
export type ApplyResult = {
|
|
30
|
+
stats: Status[];
|
|
31
|
+
/** Types whose rendered state may have changed (for app list invalidation). */
|
|
32
|
+
types: Set<string>;
|
|
33
|
+
/** Eids that successfully applied (for granular cache ingest). */
|
|
34
|
+
eids: EntityID[];
|
|
35
|
+
};
|
|
28
36
|
export interface IEntDB {
|
|
29
|
-
apply: (ops: IOp[]) => Promise<
|
|
30
|
-
stats: Status[];
|
|
31
|
-
types: Set<string>;
|
|
32
|
-
}>;
|
|
37
|
+
apply: (ops: IOp[]) => Promise<ApplyResult>;
|
|
33
38
|
clear: () => Promise<Status>;
|
|
34
39
|
getEnt<T>(eid: EntityID): Promise<ValStat<IEntity<T> | undefined>>;
|
|
35
40
|
getEntities<T>(query: EntitiesQuery): Promise<ValStat<IEntity<T>[]>>;
|
|
@@ -37,6 +42,9 @@ export interface IEntDB {
|
|
|
37
42
|
type: string;
|
|
38
43
|
}): Promise<ValStat<number>>;
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
/** Prior rev from a loaded entity (typical update/delete input). */
|
|
46
|
+
export declare function revFromEntity(ent: IEntity): IEntRev;
|
|
47
|
+
/** Prior rev from a msg head returned by insert/update/delete. */
|
|
48
|
+
export declare function revFromHead(head: IMessageHead): ValStat<IEntRev>;
|
|
41
49
|
export declare function applyOp(curr: IEntity | undefined, op: IOp): ValStat<IEntity | undefined>;
|
|
42
50
|
export declare const nullEntDB: IEntDB;
|
package/dist/web/entdb/idb.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class EntIDB implements IEntDB {
|
|
|
13
13
|
apply: (ops: IOp[]) => Promise<{
|
|
14
14
|
stats: Status[];
|
|
15
15
|
types: Set<string>;
|
|
16
|
+
eids: EntityID[];
|
|
16
17
|
}>;
|
|
17
18
|
clear(): Promise<Status>;
|
|
18
19
|
getEnt<T>(eid: EntityID): Promise<ValStat<IEntity<T> | undefined>>;
|
|
@@ -25,4 +26,5 @@ export declare class EntIDB implements IEntDB {
|
|
|
25
26
|
type: string;
|
|
26
27
|
}): Promise<ValStat<number>>;
|
|
27
28
|
}
|
|
29
|
+
/** Durable IndexedDB EntDB. Internal-only. Apps use {@link openEntDB} instead. */
|
|
28
30
|
export declare function openEntIDB(): Promise<EntIDB>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StateManager } from "../state";
|
|
2
|
+
import type { IEntDB } from "./entdb";
|
|
3
|
+
/**
|
|
4
|
+
* Build a StateManager for an EntDB.
|
|
5
|
+
* When `edb` is a {@link CachedEntDB}, type notifies come from the cache
|
|
6
|
+
* (immediate apply + durable reconcile / peer ingest).
|
|
7
|
+
*/
|
|
8
|
+
export declare function entStateManager(edb: IEntDB): StateManager;
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SyncClient } from "./client";
|
|
2
2
|
import crypto from "./crypto";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CachedEntDB, openEntDB, type OpenEntDBOptions } from "./entdb/cached";
|
|
4
|
+
import { EntitiesQuery, entStateManager, IEntDB, IEntity, nullEntDB, revFromEntity, revFromHead } from "./entdb/entdb";
|
|
5
|
+
import { EntIDB } from "./entdb/idb";
|
|
5
6
|
import { EntDBMemory } from "./entdb/memory";
|
|
6
7
|
import { useClient, useClientState, useClientXferState, useSyncOnResume } from "./react/useClient";
|
|
7
8
|
import useStateWatcher, { useStateWatcherSuspense } from "./react/useStateWatcher";
|
|
@@ -12,13 +13,13 @@ import { eidCodec, genSingletonEID } from "./shared/codecs/eid";
|
|
|
12
13
|
import { Status } from "./shared/consts";
|
|
13
14
|
import { hostHTTPTransport, HTTPTransport } from "./shared/http";
|
|
14
15
|
import { TypedEventEmitter } from "./shared/events";
|
|
15
|
-
import { EntityID, GroupID, HostHandle, ICrypto, IHostConnectionInfo, IMessage, IMutateOp, type IOp, IStateManager, ITransport, MasterSeed } from "./shared/types";
|
|
16
|
+
import { EntityID, GroupID, HostHandle, ICrypto, IDeleteParams, IEntRev, IHostConnectionInfo, IMessage, IMutateOp, type IOp, IStateManager, ITransport, IUpdateParams, MasterSeed } from "./shared/types";
|
|
16
17
|
import { nullStateManager, StateManager } from "./state";
|
|
17
18
|
import { IDBStore, openIDBStore } from "./stores/idb/store";
|
|
18
19
|
import { MemoryStore } from "./stores/memory/store";
|
|
19
20
|
import { SingletonStateManager } from "./shared/singleton";
|
|
20
|
-
import type { Applier, IClient, IDiplomaticClientState, IHostRow, IStore, IStoredMessage, IStoredMessageData, IStoredMessageWrite } from "./types";
|
|
21
|
-
import { isPendingApply,
|
|
21
|
+
import type { ApldState, Applier, IClient, IDiplomaticClientState, IHostRow, IStore, IStoredMessage, IStoredMessageData, IStoredMessageWrite } from "./types";
|
|
22
|
+
import { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, isApldState, isPendingApply, isTerminalApplyFailure, setApld } from "./types";
|
|
22
23
|
import type { SyncProgressEvent } from "./progress";
|
|
23
24
|
import { defaultPeekProgressEvery, idleProgress, shouldEmitItemProgress } from "./progress";
|
|
24
25
|
import { openDiplomaticClient, type OpenDiplomaticClientMainOptions, type OpenDiplomaticClientOptions, type OpenDiplomaticClientWorkerOptions, type OpenedDiplomaticClient } from "./openClient";
|
|
@@ -28,5 +29,5 @@ export declare function genWebClient(stateMgr: IStateManager, url: URL): Promise
|
|
|
28
29
|
client: SyncClient<URL>;
|
|
29
30
|
setSeed: (seedHex: string) => Promise<void>;
|
|
30
31
|
}>;
|
|
31
|
-
export { btoh, Clock, crypto, Decoder, defaultPeekProgressEvery, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, hostHTTPTransport, htob, HTTPTransport, IDBStore, idleProgress, IEntDB, IEntity, isPendingApply, IStore, MasterSeed, MemoryStore,
|
|
32
|
-
export type { Applier, HostHandle, IClient, ICrypto, IDiplomaticClientState, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITransport, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, SyncProgressEvent, WorkerClientOptions, };
|
|
32
|
+
export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, btoh, CachedEntDB, Clock, crypto, Decoder, defaultPeekProgressEvery, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, hostHTTPTransport, htob, HTTPTransport, IDBStore, idleProgress, IEntDB, IEntity, isApldState, isPendingApply, isTerminalApplyFailure, IStore, MasterSeed, MemoryStore, nullEntDB, nullStateManager, openDiplomaticClient, openEntDB, openIDBStore, revFromEntity, revFromHead, setApld, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
|
|
33
|
+
export type { ApldState, Applier, HostHandle, IClient, ICrypto, IDeleteParams, IDiplomaticClientState, IEntRev, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITransport, IUpdateParams, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, SyncProgressEvent, WorkerClientOptions, };
|