@interncom/diplomatic 0.0.45 → 0.0.47
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/index.mjs +58 -20
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2917,18 +2917,26 @@ replaceTraps((oldTraps) => ({
|
|
|
2917
2917
|
}));
|
|
2918
2918
|
|
|
2919
2919
|
// src/idbStore.ts
|
|
2920
|
-
var db = await openDB("client-store-db",
|
|
2920
|
+
var db = await openDB("client-store-db", 6, {
|
|
2921
2921
|
upgrade(db3) {
|
|
2922
|
-
db3.
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2922
|
+
if (!db3.objectStoreNames.contains("metaKV")) {
|
|
2923
|
+
db3.createObjectStore("metaKV");
|
|
2924
|
+
}
|
|
2925
|
+
if (!db3.objectStoreNames.contains("ops")) {
|
|
2926
|
+
db3.createObjectStore("ops", {
|
|
2927
|
+
keyPath: "sha256"
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
if (!db3.objectStoreNames.contains("uploadQueue")) {
|
|
2931
|
+
db3.createObjectStore("uploadQueue", {
|
|
2932
|
+
keyPath: "sha256"
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
if (!db3.objectStoreNames.contains("downloadQueue")) {
|
|
2936
|
+
db3.createObjectStore("downloadQueue", {
|
|
2937
|
+
keyPath: "sha256"
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2932
2940
|
}
|
|
2933
2941
|
});
|
|
2934
2942
|
var IDBStore = class {
|
|
@@ -3012,7 +3020,10 @@ var IDBStore = class {
|
|
|
3012
3020
|
};
|
|
3013
3021
|
listDownloads = async () => {
|
|
3014
3022
|
const list = await db.getAll("downloadQueue");
|
|
3015
|
-
return list.map((item) => ({
|
|
3023
|
+
return list.map((item) => ({
|
|
3024
|
+
sha256: htob(item.sha256),
|
|
3025
|
+
recordedAt: item.recordedAt
|
|
3026
|
+
}));
|
|
3016
3027
|
};
|
|
3017
3028
|
numDownloads = async () => {
|
|
3018
3029
|
const num = await db.count("downloadQueue");
|
|
@@ -3028,7 +3039,10 @@ var IDBStore = class {
|
|
|
3028
3039
|
};
|
|
3029
3040
|
listOps = async () => {
|
|
3030
3041
|
const list = await db.getAll("ops");
|
|
3031
|
-
return list.map((item) => ({
|
|
3042
|
+
return list.map((item) => ({
|
|
3043
|
+
sha256: item.sha256,
|
|
3044
|
+
cipherOp: item.cipherOp
|
|
3045
|
+
}));
|
|
3032
3046
|
};
|
|
3033
3047
|
hasOp = async (sha256) => {
|
|
3034
3048
|
const hex = btoh(sha256);
|
|
@@ -11703,11 +11717,26 @@ __export(entityDB_exports, {
|
|
|
11703
11717
|
typeIndexName: () => typeIndexName
|
|
11704
11718
|
});
|
|
11705
11719
|
var entityTableName = "entities";
|
|
11706
|
-
var typeIndexName = "
|
|
11707
|
-
var db2 = await openDB("db",
|
|
11708
|
-
upgrade(db3) {
|
|
11709
|
-
|
|
11710
|
-
|
|
11720
|
+
var typeIndexName = "entity_type_created_at";
|
|
11721
|
+
var db2 = await openDB("db", 7, {
|
|
11722
|
+
upgrade(db3, prevVersion, currVersion, tx) {
|
|
11723
|
+
if (!db3.objectStoreNames.contains(entityTableName)) {
|
|
11724
|
+
const store2 = db3.createObjectStore(entityTableName, {
|
|
11725
|
+
keyPath: "eid",
|
|
11726
|
+
autoIncrement: false
|
|
11727
|
+
});
|
|
11728
|
+
}
|
|
11729
|
+
const store = tx.objectStore(entityTableName);
|
|
11730
|
+
if (!store.indexNames.contains("entity_type_created_at")) {
|
|
11731
|
+
store.createIndex("entity_type_created_at", ["type", "createdAt"], {
|
|
11732
|
+
unique: false
|
|
11733
|
+
});
|
|
11734
|
+
}
|
|
11735
|
+
if (!store.indexNames.contains("entity_type_group_id")) {
|
|
11736
|
+
store.createIndex("entity_type_group_id", ["type", "gid"], {
|
|
11737
|
+
unique: false
|
|
11738
|
+
});
|
|
11739
|
+
}
|
|
11711
11740
|
}
|
|
11712
11741
|
});
|
|
11713
11742
|
var applier = async (op) => {
|
|
@@ -11715,7 +11744,13 @@ var applier = async (op) => {
|
|
|
11715
11744
|
case 1 /* UPSERT */: {
|
|
11716
11745
|
const curr = await db2.get("entities", op.eid);
|
|
11717
11746
|
if (new Date(op.ts) > (curr?.updatedAt ?? "")) {
|
|
11718
|
-
await db2.put("entities", {
|
|
11747
|
+
await db2.put("entities", {
|
|
11748
|
+
eid: op.eid,
|
|
11749
|
+
type: op.type,
|
|
11750
|
+
createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(),
|
|
11751
|
+
updatedAt: new Date(op.ts),
|
|
11752
|
+
body: op.body
|
|
11753
|
+
});
|
|
11719
11754
|
}
|
|
11720
11755
|
break;
|
|
11721
11756
|
}
|
|
@@ -11725,7 +11760,10 @@ var applier = async (op) => {
|
|
|
11725
11760
|
}
|
|
11726
11761
|
}
|
|
11727
11762
|
};
|
|
11728
|
-
var stateManager = new StateManager(
|
|
11763
|
+
var stateManager = new StateManager(
|
|
11764
|
+
applier,
|
|
11765
|
+
() => db2.clear("entities")
|
|
11766
|
+
);
|
|
11729
11767
|
export {
|
|
11730
11768
|
ClientStatusBar,
|
|
11731
11769
|
DiplomaticClient,
|