@interncom/diplomatic 0.0.44 → 0.0.46
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 +51 -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,19 @@ __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", 6, {
|
|
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
|
+
store.createIndex("entity_type_created_at", ["type", "createdAt"], {
|
|
11731
|
+
unique: false
|
|
11732
|
+
});
|
|
11711
11733
|
}
|
|
11712
11734
|
});
|
|
11713
11735
|
var applier = async (op) => {
|
|
@@ -11715,7 +11737,13 @@ var applier = async (op) => {
|
|
|
11715
11737
|
case 1 /* UPSERT */: {
|
|
11716
11738
|
const curr = await db2.get("entities", op.eid);
|
|
11717
11739
|
if (new Date(op.ts) > (curr?.updatedAt ?? "")) {
|
|
11718
|
-
await db2.put("entities", {
|
|
11740
|
+
await db2.put("entities", {
|
|
11741
|
+
eid: op.eid,
|
|
11742
|
+
type: op.type,
|
|
11743
|
+
createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(),
|
|
11744
|
+
updatedAt: new Date(op.ts),
|
|
11745
|
+
body: op.body
|
|
11746
|
+
});
|
|
11719
11747
|
}
|
|
11720
11748
|
break;
|
|
11721
11749
|
}
|
|
@@ -11725,7 +11753,10 @@ var applier = async (op) => {
|
|
|
11725
11753
|
}
|
|
11726
11754
|
}
|
|
11727
11755
|
};
|
|
11728
|
-
var stateManager = new StateManager(
|
|
11756
|
+
var stateManager = new StateManager(
|
|
11757
|
+
applier,
|
|
11758
|
+
() => db2.clear("entities")
|
|
11759
|
+
);
|
|
11729
11760
|
export {
|
|
11730
11761
|
ClientStatusBar,
|
|
11731
11762
|
DiplomaticClient,
|