document-drive 1.29.0-dev.1 → 1.29.0-dev.3
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/src/cache/memory.d.ts +15 -8
- package/dist/src/cache/memory.d.ts.map +1 -1
- package/dist/src/cache/memory.js +53 -29
- package/dist/src/cache/redis.d.ts +15 -8
- package/dist/src/cache/redis.d.ts.map +1 -1
- package/dist/src/cache/redis.js +67 -27
- package/dist/src/cache/types.d.ts +10 -3
- package/dist/src/cache/types.d.ts.map +1 -1
- package/dist/src/cache/util.d.ts +3 -0
- package/dist/src/cache/util.d.ts.map +1 -0
- package/dist/src/cache/util.js +13 -0
- package/dist/src/drive-document-model/gen/schema/zod.d.ts +8 -8
- package/dist/src/drive-document-model/gen/schema/zod.d.ts.map +1 -1
- package/dist/src/server/base-server.d.ts.map +1 -1
- package/dist/src/server/base-server.js +35 -15
- package/dist/src/server/sync-manager.js +2 -2
- package/dist/src/storage/browser.d.ts +6 -1
- package/dist/src/storage/browser.d.ts.map +1 -1
- package/dist/src/storage/browser.js +56 -4
- package/dist/src/storage/filesystem.d.ts +5 -1
- package/dist/src/storage/filesystem.d.ts.map +1 -1
- package/dist/src/storage/filesystem.js +59 -6
- package/dist/src/storage/ipfs.d.ts +4 -0
- package/dist/src/storage/ipfs.d.ts.map +1 -1
- package/dist/src/storage/ipfs.js +58 -5
- package/dist/src/storage/memory.d.ts +5 -1
- package/dist/src/storage/memory.d.ts.map +1 -1
- package/dist/src/storage/memory.js +47 -15
- package/dist/src/storage/prisma/factory.d.ts +2 -2
- package/dist/src/storage/prisma/factory.d.ts.map +1 -1
- package/dist/src/storage/prisma/index.d.ts +10 -4
- package/dist/src/storage/prisma/index.d.ts.map +1 -1
- package/dist/src/storage/prisma/index.js +209 -128
- package/dist/src/storage/types.d.ts +5 -4
- package/dist/src/storage/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
1
|
+
import { DocumentDriveDocument } from "#drive-document-model/gen/types";
|
|
2
|
+
import { type PHDocument } from "document-model";
|
|
3
3
|
import { type ICache } from "./types.js";
|
|
4
|
-
declare class InMemoryCache implements ICache
|
|
5
|
-
private
|
|
4
|
+
declare class InMemoryCache implements ICache {
|
|
5
|
+
private idTodocument;
|
|
6
|
+
private idToDrive;
|
|
7
|
+
private slugToDriveId;
|
|
6
8
|
clear(): void;
|
|
7
|
-
setDocument(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
setDocument(documentId: string, document: PHDocument): Promise<void>;
|
|
10
|
+
getDocument<TDocument extends PHDocument>(documentId: string): Promise<TDocument | undefined>;
|
|
11
|
+
deleteDocument(documentId: string): Promise<boolean>;
|
|
12
|
+
setDrive(driveId: string, drive: DocumentDriveDocument): Promise<void>;
|
|
13
|
+
getDrive(driveId: string): Promise<DocumentDriveDocument | undefined>;
|
|
14
|
+
deleteDrive(driveId: string): Promise<boolean>;
|
|
15
|
+
setDriveBySlug(slug: string, drive: DocumentDriveDocument): Promise<void>;
|
|
16
|
+
getDriveBySlug(slug: string): Promise<DocumentDriveDocument | undefined>;
|
|
17
|
+
deleteDriveBySlug(slug: string): Promise<boolean>;
|
|
11
18
|
}
|
|
12
19
|
export default InMemoryCache;
|
|
13
20
|
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/cache/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/cache/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,cAAM,aAAc,YAAW,MAAM;IACnC,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,SAAS,CAA4C;IAC7D,OAAO,CAAC,aAAa,CAA6B;IAElD,KAAK;IAUC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU;IAKpD,WAAW,CAAC,SAAS,SAAS,UAAU,EAC5C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAI3B,cAAc,CAAC,UAAU,EAAE,MAAM;IAIjC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IAKtD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAIrE,WAAW,CAAC,OAAO,EAAE,MAAM;IAe3B,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IAMzD,cAAc,CAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAQvC,iBAAiB,CAAC,IAAI,EAAE,MAAM;CASrC;AAED,eAAe,aAAa,CAAC"}
|
package/dist/src/cache/memory.js
CHANGED
|
@@ -1,40 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { trimResultingState } from "./util.js";
|
|
2
2
|
class InMemoryCache {
|
|
3
|
-
|
|
3
|
+
idTodocument = new Map();
|
|
4
|
+
idToDrive = new Map();
|
|
5
|
+
slugToDriveId = new Map();
|
|
4
6
|
clear() {
|
|
5
|
-
this.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.cache.set(drive, new Map());
|
|
19
|
-
}
|
|
20
|
-
this.cache.get(drive)?.set(id, doc);
|
|
21
|
-
return true;
|
|
7
|
+
this.idTodocument.clear();
|
|
8
|
+
this.idToDrive.clear();
|
|
9
|
+
this.slugToDriveId.clear();
|
|
10
|
+
}
|
|
11
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
12
|
+
// ICache
|
|
13
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
14
|
+
async setDocument(documentId, document) {
|
|
15
|
+
const doc = trimResultingState(document);
|
|
16
|
+
this.idTodocument.set(documentId, doc);
|
|
17
|
+
}
|
|
18
|
+
async getDocument(documentId) {
|
|
19
|
+
return this.idTodocument.get(documentId);
|
|
22
20
|
}
|
|
23
|
-
async deleteDocument(
|
|
24
|
-
return this.
|
|
21
|
+
async deleteDocument(documentId) {
|
|
22
|
+
return this.idTodocument.delete(documentId);
|
|
25
23
|
}
|
|
26
|
-
async
|
|
27
|
-
|
|
24
|
+
async setDrive(driveId, drive) {
|
|
25
|
+
const doc = trimResultingState(drive);
|
|
26
|
+
this.idToDrive.set(driveId, doc);
|
|
28
27
|
}
|
|
29
|
-
async
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
async getDrive(driveId) {
|
|
29
|
+
return this.idToDrive.get(driveId);
|
|
30
|
+
}
|
|
31
|
+
async deleteDrive(driveId) {
|
|
32
|
+
// look up the slug
|
|
33
|
+
const drive = this.idToDrive.get(driveId);
|
|
34
|
+
if (!drive) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const slug = drive.state.global.slug;
|
|
38
|
+
if (slug) {
|
|
39
|
+
this.slugToDriveId.delete(slug);
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
return this.idToDrive.delete(driveId);
|
|
42
|
+
}
|
|
43
|
+
async setDriveBySlug(slug, drive) {
|
|
44
|
+
const driveId = drive.state.global.id;
|
|
45
|
+
this.slugToDriveId.set(slug, driveId);
|
|
46
|
+
this.setDrive(driveId, drive);
|
|
47
|
+
}
|
|
48
|
+
async getDriveBySlug(slug) {
|
|
49
|
+
const driveId = this.slugToDriveId.get(slug);
|
|
50
|
+
if (!driveId) {
|
|
36
51
|
return undefined;
|
|
37
52
|
}
|
|
53
|
+
return this.getDrive(driveId);
|
|
54
|
+
}
|
|
55
|
+
async deleteDriveBySlug(slug) {
|
|
56
|
+
const driveId = this.slugToDriveId.get(slug);
|
|
57
|
+
if (!driveId) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
this.slugToDriveId.delete(slug);
|
|
61
|
+
return this.deleteDrive(driveId);
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
64
|
export default InMemoryCache;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DocumentDriveDocument } from "#drive-document-model/gen/types";
|
|
2
|
+
import { type PHDocument } from "document-model";
|
|
3
3
|
import type { RedisClientType } from "redis";
|
|
4
4
|
import { type ICache } from "./types.js";
|
|
5
|
-
declare class RedisCache implements ICache
|
|
5
|
+
declare class RedisCache implements ICache {
|
|
6
6
|
private logger;
|
|
7
7
|
private redis;
|
|
8
8
|
private timeoutInSeconds;
|
|
9
9
|
constructor(redis: RedisClientType, timeoutInSeconds?: number | undefined);
|
|
10
|
-
private static
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
private static _getDocumentKey;
|
|
11
|
+
private static _getDriveKey;
|
|
12
|
+
private static _getDriveBySlugKey;
|
|
13
|
+
setDocument(documentId: string, document: PHDocument): Promise<void>;
|
|
14
|
+
getDocument<TDocument extends PHDocument>(documentId: string): Promise<TDocument | undefined>;
|
|
15
|
+
deleteDocument(documentId: string): Promise<boolean>;
|
|
16
|
+
setDrive(driveId: string, drive: DocumentDriveDocument): Promise<void>;
|
|
17
|
+
getDrive(driveId: string): Promise<DocumentDriveDocument | undefined>;
|
|
18
|
+
deleteDrive(driveId: string): Promise<boolean>;
|
|
19
|
+
setDriveBySlug(slug: string, drive: DocumentDriveDocument): Promise<void>;
|
|
20
|
+
getDriveBySlug(slug: string): Promise<DocumentDriveDocument | undefined>;
|
|
21
|
+
deleteDriveBySlug(slug: string): Promise<boolean>;
|
|
15
22
|
}
|
|
16
23
|
export default RedisCache;
|
|
17
24
|
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/cache/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/cache/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,cAAM,UAAW,YAAW,MAAM;IAChC,OAAO,CAAC,MAAM,CAA+B;IAE7C,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,gBAAgB,CAAS;gBAG/B,KAAK,EAAE,eAAe,EACtB,gBAAgB,GAAE,MAAM,GAAG,SAAkB;IAM/C,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQ3B,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU;IAcpD,WAAW,CAAC,SAAS,SAAS,UAAU,EAC5C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAO3B,cAAc,CAAC,UAAU,EAAE,MAAM;IAKjC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IActD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAMrE,WAAW,CAAC,OAAO,EAAE,MAAM;IAiB3B,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IAgBzD,cAAc,CAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAMvC,iBAAiB,CAAC,IAAI,EAAE,MAAM;CAIrC;AAED,eAAe,UAAU,CAAC"}
|
package/dist/src/cache/redis.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { childLogger } from "#utils/logger";
|
|
2
|
+
import { trimResultingState } from "./util.js";
|
|
2
3
|
class RedisCache {
|
|
3
4
|
logger = childLogger(["RedisCache"]);
|
|
4
5
|
redis;
|
|
@@ -7,46 +8,85 @@ class RedisCache {
|
|
|
7
8
|
this.redis = redis;
|
|
8
9
|
this.timeoutInSeconds = timeoutInSeconds;
|
|
9
10
|
}
|
|
10
|
-
static
|
|
11
|
-
return `cache:${
|
|
11
|
+
static _getDocumentKey(documentId) {
|
|
12
|
+
return `cache:document:${documentId}`;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
14
|
+
static _getDriveKey(driveId) {
|
|
15
|
+
return `cache:drive:${driveId}`;
|
|
16
|
+
}
|
|
17
|
+
static _getDriveBySlugKey(slug) {
|
|
18
|
+
return `cache:drive:slug:${slug}`;
|
|
19
|
+
}
|
|
20
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
21
|
+
// ICache
|
|
22
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
async setDocument(documentId, document) {
|
|
24
|
+
const doc = trimResultingState(document);
|
|
25
|
+
const redisId = RedisCache._getDocumentKey(documentId);
|
|
24
26
|
const result = await this.redis.set(redisId, JSON.stringify(doc), {
|
|
25
27
|
EX: this.timeoutInSeconds ? this.timeoutInSeconds : undefined,
|
|
26
28
|
});
|
|
27
|
-
if (result
|
|
28
|
-
|
|
29
|
+
if (result !== "OK") {
|
|
30
|
+
throw new Error(`Failed to set document ${documentId} in redis. Got '${result}'`);
|
|
29
31
|
}
|
|
30
|
-
return false;
|
|
31
32
|
}
|
|
32
|
-
async getDocument(
|
|
33
|
-
const redisId = RedisCache.
|
|
33
|
+
async getDocument(documentId) {
|
|
34
|
+
const redisId = RedisCache._getDocumentKey(documentId);
|
|
34
35
|
const doc = await this.redis.get(redisId);
|
|
35
36
|
return doc ? JSON.parse(doc) : undefined;
|
|
36
37
|
}
|
|
37
|
-
async deleteDocument(
|
|
38
|
-
const redisId = RedisCache.
|
|
38
|
+
async deleteDocument(documentId) {
|
|
39
|
+
const redisId = RedisCache._getDocumentKey(documentId);
|
|
39
40
|
return (await this.redis.del(redisId)) > 0;
|
|
40
41
|
}
|
|
41
|
-
async
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
async setDrive(driveId, drive) {
|
|
43
|
+
const doc = trimResultingState(drive);
|
|
44
|
+
const redisId = RedisCache._getDriveKey(driveId);
|
|
45
|
+
const result = await this.redis.set(redisId, JSON.stringify(doc), {
|
|
46
|
+
EX: this.timeoutInSeconds ? this.timeoutInSeconds : undefined,
|
|
47
|
+
});
|
|
48
|
+
if (result !== "OK") {
|
|
49
|
+
throw new Error(`Failed to set drive ${driveId} in redis. Got '${result}'`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async getDrive(driveId) {
|
|
53
|
+
const redisId = RedisCache._getDriveKey(driveId);
|
|
54
|
+
const doc = await this.redis.get(redisId);
|
|
55
|
+
return doc ? JSON.parse(doc) : undefined;
|
|
56
|
+
}
|
|
57
|
+
async deleteDrive(driveId) {
|
|
58
|
+
const redisId = RedisCache._getDriveKey(driveId);
|
|
59
|
+
const drive = await this.getDrive(driveId);
|
|
60
|
+
if (!drive) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const slug = drive.state.global.slug;
|
|
64
|
+
if (slug) {
|
|
65
|
+
const slugRedisId = RedisCache._getDriveBySlugKey(slug);
|
|
66
|
+
await this.redis.del(slugRedisId);
|
|
45
67
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
return (await this.redis.del(redisId)) > 0;
|
|
69
|
+
}
|
|
70
|
+
// We store two pices: slug -> driveId, and driveId -> drive
|
|
71
|
+
async setDriveBySlug(slug, drive) {
|
|
72
|
+
const driveId = drive.state.global.id;
|
|
73
|
+
const redisId = RedisCache._getDriveBySlugKey(slug);
|
|
74
|
+
const result = await this.redis.set(redisId, driveId, {
|
|
75
|
+
EX: this.timeoutInSeconds ? this.timeoutInSeconds : undefined,
|
|
76
|
+
});
|
|
77
|
+
if (result !== "OK") {
|
|
78
|
+
throw new Error(`Failed to set drive slug mapping for ${slug} -> ${driveId} in redis. Got '${result}'`);
|
|
49
79
|
}
|
|
80
|
+
await this.setDrive(driveId, drive);
|
|
81
|
+
}
|
|
82
|
+
async getDriveBySlug(slug) {
|
|
83
|
+
const redisId = RedisCache._getDriveBySlugKey(slug);
|
|
84
|
+
const driveId = await this.redis.get(redisId);
|
|
85
|
+
return driveId ? await this.getDrive(driveId) : undefined;
|
|
86
|
+
}
|
|
87
|
+
async deleteDriveBySlug(slug) {
|
|
88
|
+
const redisId = RedisCache._getDriveBySlugKey(slug);
|
|
89
|
+
return (await this.redis.del(redisId)) > 0;
|
|
50
90
|
}
|
|
51
91
|
}
|
|
52
92
|
export default RedisCache;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { DocumentDriveDocument } from "#drive-document-model/gen/types";
|
|
1
2
|
import { type PHDocument } from "document-model";
|
|
2
3
|
export interface ICache {
|
|
3
|
-
setDocument(
|
|
4
|
-
getDocument<TDocument extends PHDocument>(
|
|
5
|
-
deleteDocument(
|
|
4
|
+
setDocument(documentId: string, document: PHDocument): Promise<void>;
|
|
5
|
+
getDocument<TDocument extends PHDocument>(documentId: string): Promise<TDocument | undefined>;
|
|
6
|
+
deleteDocument(documentId: string): Promise<boolean>;
|
|
7
|
+
setDrive(driveId: string, drive: DocumentDriveDocument): Promise<void>;
|
|
8
|
+
setDriveBySlug(slug: string, drive: DocumentDriveDocument): Promise<void>;
|
|
9
|
+
getDrive(driveId: string): Promise<DocumentDriveDocument | undefined>;
|
|
10
|
+
getDriveBySlug(slug: string): Promise<DocumentDriveDocument | undefined>;
|
|
11
|
+
deleteDrive(driveId: string): Promise<boolean>;
|
|
12
|
+
deleteDriveBySlug(slug: string): Promise<boolean>;
|
|
6
13
|
}
|
|
7
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cache/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,MAAM;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cache/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,MAAM;IAGrB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGrE,WAAW,CAAC,SAAS,SAAS,UAAU,EACtC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAElC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAIrD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAIvE,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG1E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;IAGtE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;IAEzE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/cache/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,eAAO,MAAM,kBAAkB,GAAI,SAAS,SAAS,UAAU,EAC7D,UAAU,SAAS,KAClB,SAYF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Deletes the resulting state on all operations in a document.
|
|
2
|
+
// NOTE: THE RESULT IS THE CACHES MUTATE DOCUMENTS
|
|
3
|
+
export const trimResultingState = (document) => {
|
|
4
|
+
const global = document.operations.global.map((e) => {
|
|
5
|
+
delete e.resultingState;
|
|
6
|
+
return e;
|
|
7
|
+
});
|
|
8
|
+
const local = document.operations.local.map((e) => {
|
|
9
|
+
delete e.resultingState;
|
|
10
|
+
return e;
|
|
11
|
+
});
|
|
12
|
+
return { ...document, operations: { global, local } };
|
|
13
|
+
};
|
|
@@ -30,19 +30,19 @@ export declare function NodeSchema(): z.ZodUnion<[z.ZodObject<Required<{
|
|
|
30
30
|
parentFolder: z.ZodType<import("./types.js").Maybe<string>, any, import("./types.js").Maybe<string>>;
|
|
31
31
|
synchronizationUnits: z.ZodType<SynchronizationUnit[], any, SynchronizationUnit[]>;
|
|
32
32
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
33
|
-
synchronizationUnits: Array<SynchronizationUnit>;
|
|
34
33
|
documentType: import("./types.js").Scalars["String"]["output"];
|
|
35
34
|
id: import("./types.js").Scalars["String"]["output"];
|
|
36
|
-
kind: import("./types.js").Scalars["String"]["output"];
|
|
37
35
|
name: import("./types.js").Scalars["String"]["output"];
|
|
38
36
|
parentFolder: import("./types.js").Maybe<import("./types.js").Scalars["String"]["output"]>;
|
|
39
|
-
}, {
|
|
40
37
|
synchronizationUnits: Array<SynchronizationUnit>;
|
|
38
|
+
kind: import("./types.js").Scalars["String"]["output"];
|
|
39
|
+
}, {
|
|
41
40
|
documentType: import("./types.js").Scalars["String"]["output"];
|
|
42
41
|
id: import("./types.js").Scalars["String"]["output"];
|
|
43
|
-
kind: import("./types.js").Scalars["String"]["output"];
|
|
44
42
|
name: import("./types.js").Scalars["String"]["output"];
|
|
45
43
|
parentFolder: import("./types.js").Maybe<import("./types.js").Scalars["String"]["output"]>;
|
|
44
|
+
synchronizationUnits: Array<SynchronizationUnit>;
|
|
45
|
+
kind: import("./types.js").Scalars["String"]["output"];
|
|
46
46
|
}>, z.ZodObject<Required<{
|
|
47
47
|
id: z.ZodType<string, any, string>;
|
|
48
48
|
kind: z.ZodType<string, any, string>;
|
|
@@ -50,14 +50,14 @@ export declare function NodeSchema(): z.ZodUnion<[z.ZodObject<Required<{
|
|
|
50
50
|
parentFolder: z.ZodType<import("./types.js").Maybe<string>, any, import("./types.js").Maybe<string>>;
|
|
51
51
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
52
52
|
id: import("./types.js").Scalars["String"]["output"];
|
|
53
|
-
kind: import("./types.js").Scalars["String"]["output"];
|
|
54
53
|
name: import("./types.js").Scalars["String"]["output"];
|
|
55
54
|
parentFolder: import("./types.js").Maybe<import("./types.js").Scalars["String"]["output"]>;
|
|
55
|
+
kind: import("./types.js").Scalars["String"]["output"];
|
|
56
56
|
}, {
|
|
57
57
|
id: import("./types.js").Scalars["String"]["output"];
|
|
58
|
-
kind: import("./types.js").Scalars["String"]["output"];
|
|
59
58
|
name: import("./types.js").Scalars["String"]["output"];
|
|
60
59
|
parentFolder: import("./types.js").Maybe<import("./types.js").Scalars["String"]["output"]>;
|
|
60
|
+
kind: import("./types.js").Scalars["String"]["output"];
|
|
61
61
|
}>]>;
|
|
62
62
|
export declare function PullResponderTriggerDataSchema(): z.ZodObject<Properties<PullResponderTriggerData>>;
|
|
63
63
|
export declare function RemoveListenerInputSchema(): z.ZodObject<Properties<RemoveListenerInput>>;
|
|
@@ -73,13 +73,13 @@ export declare function TriggerDataSchema(): z.ZodObject<Required<{
|
|
|
73
73
|
listenerId: z.ZodType<string, any, string>;
|
|
74
74
|
url: z.ZodType<string, any, string>;
|
|
75
75
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
76
|
-
url: import("./types.js").Scalars["String"]["output"];
|
|
77
76
|
listenerId: import("./types.js").Scalars["ID"]["output"];
|
|
78
77
|
interval: import("./types.js").Scalars["String"]["output"];
|
|
79
|
-
}, {
|
|
80
78
|
url: import("./types.js").Scalars["String"]["output"];
|
|
79
|
+
}, {
|
|
81
80
|
listenerId: import("./types.js").Scalars["ID"]["output"];
|
|
82
81
|
interval: import("./types.js").Scalars["String"]["output"];
|
|
82
|
+
url: import("./types.js").Scalars["String"]["output"];
|
|
83
83
|
}>;
|
|
84
84
|
export declare function UpdateFileInputSchema(): z.ZodObject<Properties<UpdateFileInput>>;
|
|
85
85
|
export declare function UpdateNodeInputSchema(): z.ZodObject<Properties<UpdateNodeInput>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../../../src/drive-document-model/gen/schema/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eA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AAC,eAAe,CAAC,CAC5B,CAIA;AAED,wBAAgB,6BAA6B,IAAI,CAAC,CAAC,SAAS,CAC1D,UAAU,CAAC,uBAAuB,CAAC,CACpC,CAQA;AAED,wBAAgB,wBAAwB,IAAI,CAAC,CAAC,SAAS,CACrD,UAAU,CAAC,kBAAkB,CAAC,CAC/B,CASA;AAED,wBAAgB,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAUlE;AAED,wBAAgB,gBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAQtE;AAED,wBAAgB,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAUlE;AAED,wBAAgB,sBAAsB,IAAI,CAAC,CAAC,SAAS,CACnD,UAAU,CAAC,gBAAgB,CAAC,CAC7B,CAOA;AAED,wBAAgB,oBAAoB,IAAI,CAAC,CAAC,SAAS,CACjD,UAAU,CAAC,cAAc,CAAC,CAC3B,CAQA;AAED,wBAAgB,mBAAmB,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAK5E;AAED,wBAAgB,UAAU
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../../../src/drive-document-model/gen/schema/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EAAE,OAAO,EAAE,eAAe,EAC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,MAAM,MAAM,8BAA8B,GACxC,WAAW,CAAC,uBAAuB,CAAC,CAAC;AAEvC,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,KAAK,CAC7C,OAAO,uBAAuB,EAC9B,CAAC,CACF,CAAC;AAEF,eAAO,MAAM,mBAAmB,sKAA0C,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { attachBranch, garbageCollect, garbageCollectDocumentOperations, groupOp
|
|
|
11
11
|
import { ClientError } from "graphql-request";
|
|
12
12
|
import { ConflictOperationError, DriveAlreadyExistsError, OperationError, } from "./error.js";
|
|
13
13
|
import { PullResponderTransmitter, } from "./listener/transmitter/pull-responder.js";
|
|
14
|
+
import { SwitchboardPushTransmitter } from "./listener/transmitter/switchboard-push.js";
|
|
14
15
|
import { DefaultListenerManagerOptions, } from "./types.js";
|
|
15
16
|
import { filterOperationsByRevision, isAtRevision } from "./utils.js";
|
|
16
17
|
export class BaseDocumentDriveServer {
|
|
@@ -239,6 +240,27 @@ export class BaseDocumentDriveServer {
|
|
|
239
240
|
if (this.shouldSyncRemoteDrive(drive)) {
|
|
240
241
|
await this.startSyncRemoteDrive(driveId);
|
|
241
242
|
}
|
|
243
|
+
// add switchboard push listeners
|
|
244
|
+
for (const zodListener of drive.state.local.listeners) {
|
|
245
|
+
if (zodListener.callInfo?.transmitterType === "SwitchboardPush") {
|
|
246
|
+
const transmitter = new SwitchboardPushTransmitter(zodListener.callInfo?.data ?? "");
|
|
247
|
+
this.listenerManager.setListener(driveId, {
|
|
248
|
+
block: zodListener.block,
|
|
249
|
+
driveId: drive.state.global.id,
|
|
250
|
+
filter: {
|
|
251
|
+
branch: zodListener.filter?.branch ?? [],
|
|
252
|
+
documentId: zodListener.filter?.documentId ?? [],
|
|
253
|
+
documentType: zodListener.filter?.documentType ?? [],
|
|
254
|
+
scope: zodListener.filter?.scope ?? [],
|
|
255
|
+
},
|
|
256
|
+
listenerId: zodListener.listenerId,
|
|
257
|
+
callInfo: zodListener.callInfo,
|
|
258
|
+
system: zodListener.system,
|
|
259
|
+
label: zodListener.label ?? "",
|
|
260
|
+
transmitter,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
242
264
|
}
|
|
243
265
|
// Delegate synchronization methods to synchronizationManager
|
|
244
266
|
getSynchronizationUnits(driveId, documentId, scope, branch, documentType) {
|
|
@@ -280,7 +302,7 @@ export class BaseDocumentDriveServer {
|
|
|
280
302
|
};
|
|
281
303
|
await this.storage.createDrive(id, document);
|
|
282
304
|
if (input.global.slug) {
|
|
283
|
-
await this.cache.
|
|
305
|
+
await this.cache.deleteDriveBySlug(input.global.slug);
|
|
284
306
|
}
|
|
285
307
|
await this._initializeDrive(id);
|
|
286
308
|
this.eventEmitter.emit("driveAdded", document);
|
|
@@ -312,7 +334,7 @@ export class BaseDocumentDriveServer {
|
|
|
312
334
|
const result = await Promise.allSettled([
|
|
313
335
|
this.stopSyncRemoteDrive(driveId),
|
|
314
336
|
this.listenerManager.removeDrive(driveId),
|
|
315
|
-
this.cache.
|
|
337
|
+
this.cache.deleteDrive(driveId),
|
|
316
338
|
this.storage.deleteDrive(driveId),
|
|
317
339
|
]);
|
|
318
340
|
result.forEach((r) => {
|
|
@@ -327,7 +349,7 @@ export class BaseDocumentDriveServer {
|
|
|
327
349
|
async getDrive(driveId, options) {
|
|
328
350
|
let document;
|
|
329
351
|
try {
|
|
330
|
-
const cachedDocument = await this.cache.
|
|
352
|
+
const cachedDocument = await this.cache.getDrive(driveId); // TODO support GetDocumentOptions
|
|
331
353
|
if (cachedDocument && isDocumentDrive(cachedDocument)) {
|
|
332
354
|
document = cachedDocument;
|
|
333
355
|
if (isAtRevision(document, options?.revisions)) {
|
|
@@ -345,16 +367,16 @@ export class BaseDocumentDriveServer {
|
|
|
345
367
|
}
|
|
346
368
|
else {
|
|
347
369
|
if (!options?.revisions) {
|
|
348
|
-
this.cache.
|
|
370
|
+
this.cache.setDrive(driveId, result).catch(logger.error);
|
|
349
371
|
}
|
|
350
372
|
return result;
|
|
351
373
|
}
|
|
352
374
|
}
|
|
353
375
|
async getDriveBySlug(slug, options) {
|
|
354
376
|
try {
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
return
|
|
377
|
+
const drive = await this.cache.getDriveBySlug(slug);
|
|
378
|
+
if (drive) {
|
|
379
|
+
return drive;
|
|
358
380
|
}
|
|
359
381
|
}
|
|
360
382
|
catch (e) {
|
|
@@ -366,14 +388,14 @@ export class BaseDocumentDriveServer {
|
|
|
366
388
|
throw new Error(`Document with slug ${slug} is not a Document Drive`);
|
|
367
389
|
}
|
|
368
390
|
else {
|
|
369
|
-
this.cache.
|
|
391
|
+
this.cache.setDriveBySlug(slug, document).catch(logger.error);
|
|
370
392
|
return document;
|
|
371
393
|
}
|
|
372
394
|
}
|
|
373
395
|
async getDocument(driveId, documentId, options) {
|
|
374
396
|
let cachedDocument;
|
|
375
397
|
try {
|
|
376
|
-
cachedDocument = await this.cache.getDocument(
|
|
398
|
+
cachedDocument = await this.cache.getDocument(documentId); // TODO support GetDocumentOptions
|
|
377
399
|
if (cachedDocument && isAtRevision(cachedDocument, options?.revisions)) {
|
|
378
400
|
return cachedDocument;
|
|
379
401
|
}
|
|
@@ -385,7 +407,7 @@ export class BaseDocumentDriveServer {
|
|
|
385
407
|
(await this.storage.getDocument(driveId, documentId));
|
|
386
408
|
const document = this._buildDocument(documentStorage, options);
|
|
387
409
|
if (!options?.revisions) {
|
|
388
|
-
this.cache.setDocument(
|
|
410
|
+
this.cache.setDocument(documentId, document).catch(logger.error);
|
|
389
411
|
}
|
|
390
412
|
return document;
|
|
391
413
|
}
|
|
@@ -454,7 +476,7 @@ export class BaseDocumentDriveServer {
|
|
|
454
476
|
catch (error) {
|
|
455
477
|
logger.warn("Error deleting document", error);
|
|
456
478
|
}
|
|
457
|
-
await this.cache.deleteDocument(
|
|
479
|
+
await this.cache.deleteDocument(documentId);
|
|
458
480
|
return this.storage.deleteDocument(driveId, documentId);
|
|
459
481
|
}
|
|
460
482
|
async _processOperations(driveId, documentId, documentStorage, operations) {
|
|
@@ -790,9 +812,7 @@ export class BaseDocumentDriveServer {
|
|
|
790
812
|
};
|
|
791
813
|
});
|
|
792
814
|
if (document) {
|
|
793
|
-
this.cache
|
|
794
|
-
.setDocument(driveId, documentId, document)
|
|
795
|
-
.catch(logger.error);
|
|
815
|
+
this.cache.setDocument(documentId, document).catch(logger.error);
|
|
796
816
|
}
|
|
797
817
|
// gets all the different scopes and branches combinations from the operations
|
|
798
818
|
const { scopes, branches } = operationsApplied.reduce((acc, operation) => {
|
|
@@ -984,7 +1004,7 @@ export class BaseDocumentDriveServer {
|
|
|
984
1004
|
if (!document || !isDocumentDrive(document)) {
|
|
985
1005
|
throw error ?? new Error("Invalid Document Drive document");
|
|
986
1006
|
}
|
|
987
|
-
this.cache.
|
|
1007
|
+
this.cache.setDrive(driveId, document).catch(logger.error);
|
|
988
1008
|
// update listener cache
|
|
989
1009
|
const lastOperation = operationsApplied
|
|
990
1010
|
.filter((op) => op.scope === "global")
|
|
@@ -152,7 +152,7 @@ export default class SynchronizationManager {
|
|
|
152
152
|
}
|
|
153
153
|
async getDrive(driveId) {
|
|
154
154
|
try {
|
|
155
|
-
const cachedDocument = await this.cache.
|
|
155
|
+
const cachedDocument = await this.cache.getDrive(driveId);
|
|
156
156
|
if (cachedDocument && isDocumentDrive(cachedDocument)) {
|
|
157
157
|
return cachedDocument;
|
|
158
158
|
}
|
|
@@ -169,7 +169,7 @@ export default class SynchronizationManager {
|
|
|
169
169
|
}
|
|
170
170
|
async getDocument(driveId, documentId) {
|
|
171
171
|
try {
|
|
172
|
-
const cachedDocument = await this.cache.getDocument(
|
|
172
|
+
const cachedDocument = await this.cache.getDocument(documentId);
|
|
173
173
|
if (cachedDocument) {
|
|
174
174
|
return cachedDocument;
|
|
175
175
|
}
|
|
@@ -9,11 +9,16 @@ export declare class BrowserStorage implements IDriveStorage, IDocumentStorage {
|
|
|
9
9
|
static DOCUMENT_KEY: string;
|
|
10
10
|
static MANIFEST_KEY: string;
|
|
11
11
|
constructor(namespace?: string);
|
|
12
|
+
clear(): Promise<void>;
|
|
12
13
|
exists(documentId: string): Promise<boolean>;
|
|
13
14
|
create(documentId: string, document: PHDocument): Promise<void>;
|
|
14
15
|
get<TDocument extends PHDocument>(documentId: string): Promise<TDocument>;
|
|
16
|
+
delete(documentId: string): Promise<boolean>;
|
|
17
|
+
removeChild(parentId: string, childId: string): Promise<boolean>;
|
|
18
|
+
addChild(parentId: string, childId: string): Promise<void>;
|
|
19
|
+
getChildren(parentId: string): Promise<string[]>;
|
|
15
20
|
checkDocumentExists(drive: string, documentId: string): Promise<boolean>;
|
|
16
|
-
private
|
|
21
|
+
private getManifest;
|
|
17
22
|
private updateDriveManifest;
|
|
18
23
|
getDocuments(drive: string): Promise<string[]>;
|
|
19
24
|
getDocument<TDocument extends PHDocument>(driveId: string, id: string): Promise<TDocument>;
|