document-drive 1.0.0-alpha.78 → 1.0.0-alpha.79

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-drive",
3
- "version": "1.0.0-alpha.78",
3
+ "version": "1.0.0-alpha.79",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "module": "./src/index.ts",
@@ -5,10 +5,19 @@ class InMemoryCache implements ICache {
5
5
  private cache = new Map<string, Map<string, Document>>();
6
6
 
7
7
  async setDocument(drive: string, id: string, document: Document) {
8
+ const global = document.operations.global.map(e => {
9
+ delete e.resultingState;
10
+ return e;
11
+ });
12
+ const local = document.operations.local.map(e => {
13
+ delete e.resultingState;
14
+ return e;
15
+ });
16
+ const doc = { ...document, operations: { global, local } }
8
17
  if (!this.cache.has(drive)) {
9
18
  this.cache.set(drive, new Map());
10
19
  }
11
- this.cache.get(drive)?.set(id, document);
20
+ this.cache.get(drive)?.set(id, doc);
12
21
  return true;
13
22
  }
14
23
 
@@ -12,7 +12,16 @@ class RedisCache implements ICache {
12
12
  }
13
13
 
14
14
  async setDocument(drive: string, id: string, document: Document) {
15
- return (await this.redis.hSet(drive, id, JSON.stringify(document))) > 0;
15
+ const global = document.operations.global.map(e => {
16
+ delete e.resultingState;
17
+ return e;
18
+ });
19
+ const local = document.operations.local.map(e => {
20
+ delete e.resultingState;
21
+ return e;
22
+ });
23
+ const doc = { ...document, operations: { global, local } }
24
+ return (await this.redis.hSet(drive, id, JSON.stringify(doc))) > 0;
16
25
  }
17
26
 
18
27
  async getDocument(drive: string, id: string) {