@interncom/diplomatic 0.0.45 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +51 -20
  2. 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", 5, {
2920
+ var db = await openDB("client-store-db", 6, {
2921
2921
  upgrade(db3) {
2922
- db3.createObjectStore("metaKV");
2923
- db3.createObjectStore("ops", {
2924
- keyPath: "sha256"
2925
- });
2926
- db3.createObjectStore("uploadQueue", {
2927
- keyPath: "sha256"
2928
- });
2929
- db3.createObjectStore("downloadQueue", {
2930
- keyPath: "sha256"
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) => ({ sha256: htob(item.sha256), recordedAt: item.recordedAt }));
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) => ({ sha256: item.sha256, cipherOp: item.cipherOp }));
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 = "entity_type";
11707
- var db2 = await openDB("db", 5, {
11708
- upgrade(db3) {
11709
- const store = db3.createObjectStore("entities", { keyPath: "eid", autoIncrement: false });
11710
- store.createIndex("entity_type", "type");
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", { eid: op.eid, type: op.type, createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(), updatedAt: new Date(op.ts), body: op.body });
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(applier, () => db2.clear("entities"));
11756
+ var stateManager = new StateManager(
11757
+ applier,
11758
+ () => db2.clear("entities")
11759
+ );
11729
11760
  export {
11730
11761
  ClientStatusBar,
11731
11762
  DiplomaticClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",