@interncom/diplomatic 0.0.58 → 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.
@@ -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: Uint8Array;
10
+ eid: EntityID;
10
11
  gid?: GroupID;
11
- pid?: Uint8Array;
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
- "entity_type_created_at": [string, Date];
23
- "entity_type_group_id": [string, GroupID];
23
+ [typeIndexName]: [string, Date];
24
+ [typeGroupIndexName]: [string, GroupID];
25
+ [typeParentIndexName]: [string, EntityID];
24
26
  };
25
27
  };
26
28
  }
package/dist/index.mjs CHANGED
@@ -11768,12 +11768,14 @@ __export(entityDB_exports, {
11768
11768
  entityTableName: () => entityTableName,
11769
11769
  stateManager: () => stateManager,
11770
11770
  typeGroupIndexName: () => typeGroupIndexName,
11771
- typeIndexName: () => typeIndexName
11771
+ typeIndexName: () => typeIndexName,
11772
+ typeParentIndexName: () => typeParentIndexName
11772
11773
  });
11773
11774
  var entityTableName = "entities";
11774
11775
  var typeIndexName = "entity_type_created_at";
11775
11776
  var typeGroupIndexName = "entity_type_group_id";
11776
- var db2 = await openDB("db", 7, {
11777
+ var typeParentIndexName = "entity_type_parent_id";
11778
+ var db2 = await openDB("db", 8, {
11777
11779
  upgrade(db3, prevVersion, currVersion, tx) {
11778
11780
  if (!db3.objectStoreNames.contains(entityTableName)) {
11779
11781
  const store2 = db3.createObjectStore(entityTableName, {
@@ -11792,6 +11794,11 @@ var db2 = await openDB("db", 7, {
11792
11794
  unique: false
11793
11795
  });
11794
11796
  }
11797
+ if (!store.indexNames.contains(typeParentIndexName)) {
11798
+ store.createIndex(typeGroupIndexName, ["type", "pid"], {
11799
+ unique: false
11800
+ });
11801
+ }
11795
11802
  }
11796
11803
  });
11797
11804
  var applier = async (op) => {
@@ -4,8 +4,9 @@ export declare enum Verb {
4
4
  }
5
5
  type Timestamp = string;
6
6
  export type GroupID = Uint8Array | string;
7
+ export type EntityID = Uint8Array;
7
8
  export interface IBaseOp {
8
- eid: Uint8Array;
9
+ eid: EntityID;
9
10
  gid?: GroupID;
10
11
  ts: Timestamp;
11
12
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",