@interncom/diplomatic 0.0.60 → 0.0.61

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GroupID, IOp, KeyPair } from "./shared/types";
1
+ import type { EntityID, GroupID, IOp, KeyPair } from "./shared/types";
2
2
  import type { IClientStateStore, IDiplomaticClientState, IDiplomaticClientXferState } from "./types";
3
3
  import type { StateManager } from "./state";
4
4
  export interface IDiplomaticClientParams {
@@ -41,11 +41,12 @@ export default class DiplomaticClient {
41
41
  apply(op: IOp): Promise<void>;
42
42
  export(filename: string, extension?: string): Promise<void>;
43
43
  import: (file: File) => Promise<void>;
44
- upsert<T>({ type, body, eid, gid, version }: {
44
+ upsert<T>({ type, body, eid, gid, pid, version }: {
45
45
  type: string;
46
46
  body: T;
47
- eid?: Uint8Array;
47
+ eid?: EntityID;
48
48
  gid?: GroupID;
49
+ pid?: EntityID;
49
50
  version?: number;
50
51
  }): Promise<void>;
51
52
  delete<T>(type: string, eid: Uint8Array, version?: number): Promise<void>;
package/dist/index.mjs CHANGED
@@ -11338,10 +11338,11 @@ var Verb = /* @__PURE__ */ ((Verb2) => {
11338
11338
  })(Verb || {});
11339
11339
 
11340
11340
  // ../shared/ops.ts
11341
- function genUpsertOp(eid, type, body, version = 0, gid) {
11341
+ function genUpsertOp(eid, type, body, version = 0, gid, pid) {
11342
11342
  return {
11343
11343
  eid,
11344
11344
  gid,
11345
+ pid,
11345
11346
  ts: (/* @__PURE__ */ new Date()).toISOString(),
11346
11347
  type,
11347
11348
  verb: 1 /* UPSERT */,
@@ -11660,9 +11661,9 @@ var DiplomaticClient = class {
11660
11661
  this.emitXferUpdate();
11661
11662
  }
11662
11663
  };
11663
- async upsert({ type, body, eid, gid, version = 0 }) {
11664
+ async upsert({ type, body, eid, gid, pid, version = 0 }) {
11664
11665
  const id = eid ?? await crypto_default.gen128BitRandomID();
11665
- const op = genUpsertOp(id, type, body, version, gid);
11666
+ const op = genUpsertOp(id, type, body, version, gid, pid);
11666
11667
  return this.apply(op);
11667
11668
  }
11668
11669
  async delete(type, eid, version = 0) {
@@ -1,4 +1,4 @@
1
- import { type GroupID, type IDeleteOp, type IOp, type IUpsertOp } from "./types.ts";
2
- export declare function genUpsertOp<T>(eid: Uint8Array, type: string, body: T, version?: number, gid?: GroupID): IUpsertOp;
1
+ import { type EntityID, type GroupID, type IDeleteOp, type IOp, type IUpsertOp } from "./types.ts";
2
+ export declare function genUpsertOp<T>(eid: EntityID, type: string, body: T, version?: number, gid?: GroupID, pid?: EntityID): IUpsertOp;
3
3
  export declare function genDeleteOp<T>(eid: Uint8Array, type: string, version?: number): IDeleteOp;
4
4
  export declare function isOp(op: any): op is IOp;
@@ -7,12 +7,13 @@ export type GroupID = Uint8Array | string;
7
7
  export type EntityID = Uint8Array;
8
8
  export interface IBaseOp {
9
9
  eid: EntityID;
10
- gid?: GroupID;
11
10
  ts: Timestamp;
12
11
  type: string;
13
12
  ver: number;
14
13
  }
15
14
  export interface IUpsertOp extends IBaseOp {
15
+ gid?: GroupID;
16
+ pid?: EntityID;
16
17
  verb: Verb.UPSERT;
17
18
  body: unknown;
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",