@interncom/diplomatic 0.0.33 → 0.0.34
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/entityDB.d.ts +8 -6
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/entityDB.d.ts
CHANGED
|
@@ -3,15 +3,17 @@ import { Applier } from './types';
|
|
|
3
3
|
import { StateManager } from './state';
|
|
4
4
|
export declare const entityTableName = "entities";
|
|
5
5
|
export declare const typeIndexName = "entity_type";
|
|
6
|
+
export interface IEntity<T> {
|
|
7
|
+
eid: Uint8Array;
|
|
8
|
+
type: string;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
body: T;
|
|
12
|
+
}
|
|
6
13
|
interface IEntityDB extends DBSchema {
|
|
7
14
|
entities: {
|
|
8
15
|
key: Uint8Array;
|
|
9
|
-
value:
|
|
10
|
-
eid: Uint8Array;
|
|
11
|
-
type: string;
|
|
12
|
-
updatedAt: Date;
|
|
13
|
-
body: unknown;
|
|
14
|
-
};
|
|
16
|
+
value: IEntity<unknown>;
|
|
15
17
|
indexes: {
|
|
16
18
|
"entity_type": "string";
|
|
17
19
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -9143,7 +9143,7 @@ __export(entityDB_exports, {
|
|
|
9143
9143
|
});
|
|
9144
9144
|
var entityTableName = "entities";
|
|
9145
9145
|
var typeIndexName = "entity_type";
|
|
9146
|
-
var db2 = await openDB("db",
|
|
9146
|
+
var db2 = await openDB("db", 5, {
|
|
9147
9147
|
upgrade(db3) {
|
|
9148
9148
|
const store = db3.createObjectStore("entities", { keyPath: "eid", autoIncrement: false });
|
|
9149
9149
|
store.createIndex("entity_type", "type");
|
|
@@ -9154,7 +9154,7 @@ var applier = async (op) => {
|
|
|
9154
9154
|
case 1 /* UPSERT */: {
|
|
9155
9155
|
const curr = await db2.get("entities", op.eid);
|
|
9156
9156
|
if (new Date(op.ts) > (curr?.updatedAt ?? "")) {
|
|
9157
|
-
await db2.put("entities", { eid: op.eid, type: op.type, updatedAt: new Date(op.ts), body: op.body });
|
|
9157
|
+
await db2.put("entities", { eid: op.eid, type: op.type, createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(), updatedAt: new Date(op.ts), body: op.body });
|
|
9158
9158
|
}
|
|
9159
9159
|
break;
|
|
9160
9160
|
}
|