@interncom/diplomatic 0.0.57 → 0.0.59
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/entityDB.d.ts +7 -5
- package/dist/index.mjs +34 -39
- package/dist/shared/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/entityDB.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type DBSchema } from "idb";
|
|
2
2
|
import type { Applier } from "./types";
|
|
3
|
-
import { type GroupID } from "./shared/types";
|
|
3
|
+
import { type EntityID, type GroupID } from "./shared/types";
|
|
4
4
|
import { StateManager } from "./state";
|
|
5
5
|
export declare const entityTableName = "entities";
|
|
6
6
|
export declare const typeIndexName = "entity_type_created_at";
|
|
7
7
|
export declare const typeGroupIndexName = "entity_type_group_id";
|
|
8
|
+
export declare const typeParentIndexName = "entity_type_parent_id";
|
|
8
9
|
export interface IEntity<T> {
|
|
9
|
-
eid:
|
|
10
|
+
eid: EntityID;
|
|
10
11
|
gid?: GroupID;
|
|
11
|
-
pid?:
|
|
12
|
+
pid?: EntityID;
|
|
12
13
|
type: string;
|
|
13
14
|
updatedAt: Date;
|
|
14
15
|
createdAt: Date;
|
|
@@ -19,8 +20,9 @@ interface IEntityDB extends DBSchema {
|
|
|
19
20
|
key: Uint8Array;
|
|
20
21
|
value: IEntity<unknown>;
|
|
21
22
|
indexes: {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
[typeIndexName]: [string, Date];
|
|
24
|
+
[typeGroupIndexName]: [string, GroupID];
|
|
25
|
+
[typeParentIndexName]: [string, EntityID];
|
|
24
26
|
};
|
|
25
27
|
};
|
|
26
28
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2846,17 +2846,6 @@ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {})
|
|
|
2846
2846
|
});
|
|
2847
2847
|
return openPromise;
|
|
2848
2848
|
}
|
|
2849
|
-
function deleteDB(name, { blocked } = {}) {
|
|
2850
|
-
const request = indexedDB.deleteDatabase(name);
|
|
2851
|
-
if (blocked) {
|
|
2852
|
-
request.addEventListener("blocked", (event) => blocked(
|
|
2853
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
2854
|
-
event.oldVersion,
|
|
2855
|
-
event
|
|
2856
|
-
));
|
|
2857
|
-
}
|
|
2858
|
-
return wrap(request).then(() => void 0);
|
|
2859
|
-
}
|
|
2860
2849
|
var readMethods = ["get", "getKey", "getAll", "getAllKeys", "count"];
|
|
2861
2850
|
var writeMethods = ["put", "add", "delete", "clear"];
|
|
2862
2851
|
var cachedMethods = /* @__PURE__ */ new Map();
|
|
@@ -2943,39 +2932,38 @@ replaceTraps((oldTraps) => ({
|
|
|
2943
2932
|
}));
|
|
2944
2933
|
|
|
2945
2934
|
// src/idbStore.ts
|
|
2946
|
-
var
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
db3.createObjectStore("metaKV");
|
|
2951
|
-
}
|
|
2952
|
-
if (!db3.objectStoreNames.contains("ops")) {
|
|
2953
|
-
db3.createObjectStore("ops", {
|
|
2954
|
-
keyPath: "sha256"
|
|
2955
|
-
});
|
|
2956
|
-
}
|
|
2957
|
-
if (!db3.objectStoreNames.contains("uploadQueue")) {
|
|
2958
|
-
db3.createObjectStore("uploadQueue", {
|
|
2959
|
-
keyPath: "sha256"
|
|
2960
|
-
});
|
|
2961
|
-
}
|
|
2962
|
-
if (!db3.objectStoreNames.contains("downloadQueue")) {
|
|
2963
|
-
db3.createObjectStore("downloadQueue", {
|
|
2964
|
-
keyPath: "sha256"
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2935
|
+
var db = await openDB("client-store-db", 6, {
|
|
2936
|
+
upgrade(db3) {
|
|
2937
|
+
if (!db3.objectStoreNames.contains("metaKV")) {
|
|
2938
|
+
db3.createObjectStore("metaKV");
|
|
2967
2939
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2940
|
+
if (!db3.objectStoreNames.contains("ops")) {
|
|
2941
|
+
db3.createObjectStore("ops", {
|
|
2942
|
+
keyPath: "sha256"
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
if (!db3.objectStoreNames.contains("uploadQueue")) {
|
|
2946
|
+
db3.createObjectStore("uploadQueue", {
|
|
2947
|
+
keyPath: "sha256"
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
if (!db3.objectStoreNames.contains("downloadQueue")) {
|
|
2951
|
+
db3.createObjectStore("downloadQueue", {
|
|
2952
|
+
keyPath: "sha256"
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
});
|
|
2971
2957
|
var IDBStore = class {
|
|
2972
2958
|
seed;
|
|
2973
2959
|
hostURL;
|
|
2974
2960
|
hostID;
|
|
2975
2961
|
lastFetchedAt;
|
|
2976
2962
|
async wipe() {
|
|
2977
|
-
await
|
|
2978
|
-
|
|
2963
|
+
await db.clear("metaKV");
|
|
2964
|
+
await db.clear("uploadQueue");
|
|
2965
|
+
await db.clear("downloadQueue");
|
|
2966
|
+
await db.clear("ops");
|
|
2979
2967
|
}
|
|
2980
2968
|
async getSeed() {
|
|
2981
2969
|
const hex = await db.get("metaKV", "seed");
|
|
@@ -11780,12 +11768,14 @@ __export(entityDB_exports, {
|
|
|
11780
11768
|
entityTableName: () => entityTableName,
|
|
11781
11769
|
stateManager: () => stateManager,
|
|
11782
11770
|
typeGroupIndexName: () => typeGroupIndexName,
|
|
11783
|
-
typeIndexName: () => typeIndexName
|
|
11771
|
+
typeIndexName: () => typeIndexName,
|
|
11772
|
+
typeParentIndexName: () => typeParentIndexName
|
|
11784
11773
|
});
|
|
11785
11774
|
var entityTableName = "entities";
|
|
11786
11775
|
var typeIndexName = "entity_type_created_at";
|
|
11787
11776
|
var typeGroupIndexName = "entity_type_group_id";
|
|
11788
|
-
var
|
|
11777
|
+
var typeParentIndexName = "entity_type_parent_id";
|
|
11778
|
+
var db2 = await openDB("db", 8, {
|
|
11789
11779
|
upgrade(db3, prevVersion, currVersion, tx) {
|
|
11790
11780
|
if (!db3.objectStoreNames.contains(entityTableName)) {
|
|
11791
11781
|
const store2 = db3.createObjectStore(entityTableName, {
|
|
@@ -11804,6 +11794,11 @@ var db2 = await openDB("db", 7, {
|
|
|
11804
11794
|
unique: false
|
|
11805
11795
|
});
|
|
11806
11796
|
}
|
|
11797
|
+
if (!store.indexNames.contains(typeParentIndexName)) {
|
|
11798
|
+
store.createIndex(typeGroupIndexName, ["type", "pid"], {
|
|
11799
|
+
unique: false
|
|
11800
|
+
});
|
|
11801
|
+
}
|
|
11807
11802
|
}
|
|
11808
11803
|
});
|
|
11809
11804
|
var applier = async (op) => {
|
package/dist/shared/types.d.ts
CHANGED