@interncom/diplomatic 0.2.6 → 0.2.7

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.
@@ -10,6 +10,7 @@ export declare class SingletonStateManager implements IStateManager {
10
10
  private emitter;
11
11
  constructor(singletonType: string);
12
12
  apply(messages: IMessage[]): Promise<Status[]>;
13
+ clear: () => Promise<Status>;
13
14
  on: (event: string, listener: () => void) => void;
14
15
  off: (event: string, listener: () => void) => void;
15
16
  }
@@ -48,8 +48,22 @@ export interface IStorage {
48
48
  addUser: (pubKey: PublicKey) => Promise<ValStat<void>>;
49
49
  hasUser: (pubKey: PublicKey) => Promise<ValStat<boolean>>;
50
50
  subMeta: (pubKey: PublicKey) => Promise<ValStat<ISubscriptionMetadata>>;
51
- setBag: (pubKey: PublicKey, bag: IBag) => Promise<ValStat<number>>;
52
- getBody: (pubKey: PublicKey, seq: number) => Promise<ValStat<Uint8Array | undefined>>;
51
+ /**
52
+ * Store bags for a user. Returns host seq for each bag in order.
53
+ * Empty list succeeds with []. Implementations must assign contiguous
54
+ * seqs atomically (transaction / single batch) so concurrent writers
55
+ * cannot claim the same seq.
56
+ */
57
+ setBags: (pubKey: PublicKey, bags: IBag[]) => Promise<ValStat<number[]>>;
58
+ /**
59
+ * Fetch ciphertext bodies for the given host seqs.
60
+ * Returns only seqs that exist (missing seqs are omitted, not an error).
61
+ * Empty `seqs` succeeds with [].
62
+ */
63
+ getBodies: (pubKey: PublicKey, seqs: number[]) => Promise<ValStat<{
64
+ seq: number;
65
+ bodyCph: Uint8Array;
66
+ }[]>>;
53
67
  listHeads: (pubKey: PublicKey, minSeq: number) => Promise<ValStat<IBagPeekItem[]>>;
54
68
  }
55
69
  export interface KeyPair {
@@ -151,6 +165,8 @@ export interface ITransport {
151
165
  }
152
166
  export interface IStateManager {
153
167
  apply: (msgs: IMessage[]) => Promise<Status[]>;
168
+ /** Drop local application state (e.g. EntDB) and notify subscribers. */
169
+ clear: () => Promise<Status>;
154
170
  on: (type: string, listener: () => void) => void;
155
171
  off: (type: string, listener: () => void) => void;
156
172
  }
@@ -6,10 +6,12 @@ export declare function isMsgEntBody(bodDec: unknown): bodDec is IMsgEntBody;
6
6
  export declare function msgToOp(msg: IMessage): ValStat<IOp>;
7
7
  export declare class StateManager implements IStateManager {
8
8
  applier: Applier;
9
- clear: () => Promise<Status>;
10
9
  private emitter;
11
- constructor(applier: Applier, clear: () => Promise<Status>);
10
+ private clearer;
11
+ constructor(applier: Applier, clearer: () => Promise<Status>);
12
12
  apply: (msgs: IMessage[]) => Promise<Status[]>;
13
+ /** Clear underlying store (e.g. EntDB) and notify all type subscribers. */
14
+ clear: () => Promise<Status>;
13
15
  on: (opType: string, listener: () => void) => void;
14
16
  off: (opType: string, listener: () => void) => void;
15
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer and CLI utilities for DIPLOMATIC",
6
6
  "files": [