@interncom/diplomatic 0.0.62 → 0.0.64

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.
@@ -4,6 +4,7 @@ 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
+ export declare const typeUpdatedAtIndexName = "entity_type_updated_at";
7
8
  export declare const typeGroupIndexName = "entity_type_group_id";
8
9
  export declare const typeParentIndexName = "entity_type_parent_id";
9
10
  export interface IEntity<T> {
@@ -21,6 +22,7 @@ interface IEntityDB extends DBSchema {
21
22
  value: IEntity<unknown>;
22
23
  indexes: {
23
24
  [typeIndexName]: [string, Date];
25
+ [typeUpdatedAtIndexName]: [string, Date];
24
26
  [typeGroupIndexName]: [string, GroupID];
25
27
  [typeParentIndexName]: [string, EntityID];
26
28
  };
package/dist/index.mjs CHANGED
@@ -11533,10 +11533,13 @@ var DiplomaticClient = class {
11533
11533
  return [];
11534
11534
  }
11535
11535
  const lastFetchedAt = await this.store.getLastFetchedAt();
11536
- const begin = /* @__PURE__ */ new Date(0);
11536
+ const begin = lastFetchedAt ?? /* @__PURE__ */ new Date(0);
11537
11537
  const { hostURL, hostKeyPair } = this;
11538
11538
  const resp = await api_default.listDeltas(hostURL, begin, hostKeyPair);
11539
11539
  for (const item of resp.deltas) {
11540
+ if (await this.store.hasOp(item.sha256)) {
11541
+ continue;
11542
+ }
11540
11543
  await this.store.enqueueDownload(item.sha256, item.recordedAt);
11541
11544
  this.emitXferUpdate();
11542
11545
  }
@@ -11770,13 +11773,15 @@ __export(entityDB_exports, {
11770
11773
  stateManager: () => stateManager,
11771
11774
  typeGroupIndexName: () => typeGroupIndexName,
11772
11775
  typeIndexName: () => typeIndexName,
11773
- typeParentIndexName: () => typeParentIndexName
11776
+ typeParentIndexName: () => typeParentIndexName,
11777
+ typeUpdatedAtIndexName: () => typeUpdatedAtIndexName
11774
11778
  });
11775
11779
  var entityTableName = "entities";
11776
11780
  var typeIndexName = "entity_type_created_at";
11781
+ var typeUpdatedAtIndexName = "entity_type_updated_at";
11777
11782
  var typeGroupIndexName = "entity_type_group_id";
11778
11783
  var typeParentIndexName = "entity_type_parent_id";
11779
- var db2 = await openDB("db", 9, {
11784
+ var db2 = await openDB("db", 10, {
11780
11785
  upgrade(db3, prevVersion, currVersion, tx) {
11781
11786
  if (!db3.objectStoreNames.contains(entityTableName)) {
11782
11787
  const store2 = db3.createObjectStore(entityTableName, {
@@ -11790,6 +11795,11 @@ var db2 = await openDB("db", 9, {
11790
11795
  unique: false
11791
11796
  });
11792
11797
  }
11798
+ if (!store.indexNames.contains(typeUpdatedAtIndexName)) {
11799
+ store.createIndex(typeUpdatedAtIndexName, ["type", "updatedAt"], {
11800
+ unique: false
11801
+ });
11802
+ }
11793
11803
  if (!store.indexNames.contains(typeGroupIndexName)) {
11794
11804
  store.createIndex(typeGroupIndexName, ["type", "gid"], {
11795
11805
  unique: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",