@interncom/diplomatic 0.19.1 → 0.20.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.
@@ -1,12 +1,6 @@
1
1
  import { ICodecStruct } from "../codec.ts";
2
- import { EntityID } from "../types.ts";
3
- export interface IMessageHead {
4
- eid: EntityID;
5
- off: number;
6
- ctr: number;
7
- len: number;
8
- hsh?: Uint8Array;
9
- }
2
+ import { EntityID, IMessageHead } from "../types.ts";
3
+ export type { IMessageHead };
10
4
  export declare const messageHeadCodec: ICodecStruct<IMessageHead>;
11
5
  export interface IMinimalMessageHead {
12
6
  eid: EntityID;
@@ -17,5 +17,8 @@ export declare namespace Exim {
17
17
  }>) => Iterable<{
18
18
  head: IMessageHead;
19
19
  body?: Uint8Array;
20
- }>): Promise<ValStat<Uint8Array>>;
20
+ }> | Promise<Iterable<{
21
+ head: IMessageHead;
22
+ body?: Uint8Array;
23
+ }>>): Promise<ValStat<Uint8Array>>;
21
24
  }
@@ -5,18 +5,21 @@ interface IInsertParams {
5
5
  now: Date;
6
6
  bod: SerializedContent;
7
7
  crypto: ICrypto;
8
+ typ?: string;
8
9
  }
9
- export declare function genInsertHead({ now, bod, crypto }: IInsertParams): Promise<ValStat<IMessageHead>>;
10
- interface IUpsertParams extends Omit<IMessage, "off" | "len" | "hsh"> {
10
+ export declare function genInsertHead({ now, bod, crypto, typ }: IInsertParams): Promise<ValStat<IMessageHead>>;
11
+ interface IUpsertParams extends Omit<IMessage, "off" | "len" | "hsh" | "typ"> {
11
12
  now: Date;
12
13
  crypto: ICrypto;
14
+ typ?: string;
13
15
  }
14
- export declare function genUpsertHead({ now, eid, ctr, bod, crypto }: IUpsertParams): Promise<ValStat<IMessageHead>>;
15
- interface IDeleteParams extends Omit<IMessage, "off" | "len" | "hsh" | "bod"> {
16
+ export declare function genUpsertHead({ now, eid, ctr, typ, bod, crypto }: IUpsertParams): Promise<ValStat<IMessageHead>>;
17
+ interface IDeleteParams extends Omit<IMessage, "off" | "len" | "hsh" | "bod" | "typ"> {
16
18
  now: Date;
17
19
  crypto: ICrypto;
20
+ typ?: string;
18
21
  }
19
- export declare function genDeleteHead({ now, eid, ctr, crypto }: IDeleteParams): Promise<ValStat<IMessageHead>>;
22
+ export declare function genDeleteHead({ now, eid, ctr, typ, crypto }: IDeleteParams): Promise<ValStat<IMessageHead>>;
20
23
  export declare function genInsert({ now, bod, crypto }: IInsertParams): Promise<ValStat<IUpsertMessage>>;
21
24
  export declare function genDelete(params: IDeleteParams): Promise<ValStat<IDeleteMessage>>;
22
25
  export {};
@@ -21,10 +21,10 @@ export interface IMsgEntBody<T = unknown> {
21
21
  * dropped on apply. Omit or [] means no tags.
22
22
  */
23
23
  tags?: string[];
24
- type: string;
25
24
  body?: T;
26
25
  }
27
26
  export interface IMessageHead {
27
+ typ?: string;
28
28
  eid: EntityID;
29
29
  off: number;
30
30
  ctr: number;
@@ -37,15 +37,17 @@ export interface IMessage extends IMessageHead {
37
37
  export interface IMessageWithHash extends IMessage {
38
38
  headHash: Hash;
39
39
  }
40
- export interface IDeleteOp extends Omit<IMessageHead, "len" | "hsh" | "bod"> {
40
+ export interface IDeleteOp extends Omit<IMessageHead, "len" | "hsh" | "bod" | "typ"> {
41
41
  }
42
42
  export interface IMutateOp<T = unknown> extends IDeleteOp, Omit<IMsgEntBody<T>, "body"> {
43
+ type: string;
43
44
  body: T;
44
45
  }
45
46
  export type IOp = IDeleteOp | IMutateOp;
46
47
  export declare function isDeleteOp(op: IOp): op is IDeleteOp;
47
48
  export declare function isMutateOp(op: IOp): op is IMutateOp;
48
49
  export interface IInsertParams<T> extends IMsgEntBody<T> {
50
+ type: string;
49
51
  /** Optional 8-byte id material for the new eid; else random. */
50
52
  id?: Uint8Array;
51
53
  }
@@ -60,6 +62,7 @@ export interface IEntRev {
60
62
  updatedAt: Date;
61
63
  }
62
64
  export interface IUpdateParams<T> extends IMsgEntBody<T> {
65
+ type: string;
63
66
  prior: IEntRev;
64
67
  /** Clock-skew recovery; default client-wide (usually true). */
65
68
  force?: boolean;
@@ -177,6 +177,8 @@ export interface IStoredMessageFields {
177
177
  eid: EntityID;
178
178
  off?: number;
179
179
  ctr?: number;
180
+ /** Msg head typ. Omit when empty (raw). */
181
+ typ?: string;
180
182
  body?: EncodedMessage;
181
183
  }
182
184
  /**
@@ -192,7 +194,7 @@ export interface IStoredMessageData extends IStoredMessageFields {
192
194
  /**
193
195
  * Required shape for every put into the message archive (app/API layer).
194
196
  * `apld` is required and must be one of the three {@link ApldState} values.
195
- * Omit optional fields (`off`, `ctr`, `body`, `err`) rather than storing empties.
197
+ * Omit optional fields (`off`, `ctr`, `typ`, `body`, `err`) rather than storing empties.
196
198
  */
197
199
  export type IStoredMessageWrite = IStoredMessageFields & {
198
200
  apld: ApldState;
@@ -299,8 +301,8 @@ export interface IClient<Handle extends HostHandle> {
299
301
  hosts(): Promise<IHostRow<Handle>[]>;
300
302
  connect(): Promise<void>;
301
303
  disconnect(): Promise<void>;
302
- insertRaw(content: SerializedContent): Promise<ValStat<IMessageHead>>;
303
- updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean): Promise<ValStat<IMessageHead>>;
304
+ insertRaw(content: SerializedContent, typ?: string): Promise<ValStat<IMessageHead>>;
305
+ updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean, typ?: string): Promise<ValStat<IMessageHead>>;
304
306
  insert<T = unknown>(op: IInsertParams<T>): Promise<ValStat<IMessageHead>>;
305
307
  update<T = unknown>(op: IUpdateParams<T>): Promise<ValStat<IMessageHead>>;
306
308
  /**
@@ -86,8 +86,8 @@ export declare class WorkerClient implements IClient<URL> {
86
86
  connect(listen?: boolean, sync?: boolean): Promise<void>;
87
87
  disconnect(): Promise<void>;
88
88
  /** Local UI write on main (cache notifies in apply's sync prefix); sync via worker. */
89
- insertRaw(content: SerializedContent): Promise<ValStat<IMessageHead>>;
90
- updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean): Promise<ValStat<IMessageHead>>;
89
+ insertRaw(content: SerializedContent, typ?: string): Promise<ValStat<IMessageHead>>;
90
+ updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean, typ?: string): Promise<ValStat<IMessageHead>>;
91
91
  insert<T = unknown>(op: IInsertParams<T>): Promise<ValStat<IMessageHead>>;
92
92
  update<T = unknown>(op: IUpdateParams<T>): Promise<ValStat<IMessageHead>>;
93
93
  delete(op: IDeleteParams): Promise<ValStat<IMessageHead>>;