@interncom/diplomatic 0.0.60 → 0.0.62
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 +4 -3
- package/dist/index.mjs +5 -3
- package/dist/shared/ops.d.ts +2 -2
- package/dist/shared/types.d.ts +2 -1
- package/package.json +1 -1
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?:
|
|
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) {
|
|
@@ -11809,6 +11810,7 @@ var applier = async (op) => {
|
|
|
11809
11810
|
await db2.put("entities", {
|
|
11810
11811
|
eid: op.eid,
|
|
11811
11812
|
gid: op.gid,
|
|
11813
|
+
pid: op.pid,
|
|
11812
11814
|
type: op.type,
|
|
11813
11815
|
createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(),
|
|
11814
11816
|
updatedAt: new Date(op.ts),
|
package/dist/shared/ops.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GroupID, type IDeleteOp, type IOp, type IUpsertOp } from "./types.ts";
|
|
2
|
-
export declare function genUpsertOp<T>(eid:
|
|
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;
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -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
|
}
|