@verdant-web/server 1.8.13 → 1.8.14-next.0
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/cjs/Baselines.d.ts +15 -15
- package/dist/cjs/Baselines.js +83 -83
- package/dist/cjs/ClientConnection.d.ts +18 -18
- package/dist/cjs/ClientConnection.js +105 -105
- package/dist/cjs/MessageSender.d.ts +5 -5
- package/dist/cjs/MessageSender.js +2 -2
- package/dist/cjs/OperationHistory.d.ts +36 -36
- package/dist/cjs/OperationHistory.js +120 -120
- package/dist/cjs/Presence.d.ts +15 -15
- package/dist/cjs/Presence.js +59 -59
- package/dist/cjs/Profiles.d.ts +10 -10
- package/dist/cjs/Profiles.js +19 -19
- package/dist/cjs/ReplicaKeepaliveTimers.d.ts +17 -17
- package/dist/cjs/ReplicaKeepaliveTimers.js +30 -30
- package/dist/cjs/Replicas.d.ts +24 -24
- package/dist/cjs/Replicas.js +137 -137
- package/dist/cjs/Server.d.ts +143 -143
- package/dist/cjs/Server.js +396 -396
- package/dist/cjs/ServerLibrary.d.ts +77 -77
- package/dist/cjs/ServerLibrary.js +487 -487
- package/dist/cjs/ServerStorage.d.ts +35 -0
- package/dist/cjs/ServerStorage.js +60 -0
- package/dist/cjs/ServerStorage.js.map +1 -0
- package/dist/cjs/TokenProvider.d.ts +16 -16
- package/dist/cjs/TokenProvider.js +26 -26
- package/dist/cjs/TokenVerifier.d.ts +16 -16
- package/dist/cjs/TokenVerifier.js +28 -28
- package/dist/cjs/files/FileMetadata.d.ts +28 -28
- package/dist/cjs/files/FileMetadata.js +46 -46
- package/dist/cjs/files/FileStorage.d.ts +35 -35
- package/dist/cjs/files/FileStorage.js +71 -71
- package/dist/cjs/index.d.ts +9 -9
- package/dist/cjs/index.js +11 -11
- package/dist/cjs/migrations/v0.d.ts +1 -0
- package/dist/cjs/migrations/v0.js +30 -0
- package/dist/cjs/migrations/v0.js.map +1 -0
- package/dist/cjs/migrations/v0.sql.d.ts +2 -2
- package/dist/cjs/migrations/v0.sql.js +3 -3
- package/dist/cjs/migrations/v1.d.ts +1 -0
- package/dist/cjs/migrations/v1.js +32 -0
- package/dist/cjs/migrations/v1.js.map +1 -0
- package/dist/cjs/migrations/v1.sql.d.ts +2 -2
- package/dist/cjs/migrations/v1.sql.js +3 -3
- package/dist/cjs/migrations/v2.d.ts +1 -0
- package/dist/cjs/migrations/v2.js +29 -0
- package/dist/cjs/migrations/v2.js.map +1 -0
- package/dist/cjs/migrations/v2.sql.d.ts +2 -2
- package/dist/cjs/migrations/v2.sql.js +4 -4
- package/dist/cjs/migrations/v3.d.ts +1 -0
- package/dist/cjs/migrations/v3.js +15 -0
- package/dist/cjs/migrations/v3.js.map +1 -0
- package/dist/cjs/migrations/v3.sql.d.ts +2 -2
- package/dist/cjs/migrations/v3.sql.js +4 -4
- package/dist/cjs/migrations/v4.d.ts +1 -0
- package/dist/cjs/migrations/v4.js +9 -0
- package/dist/cjs/migrations/v4.js.map +1 -0
- package/dist/cjs/migrations/v4.sql.d.ts +2 -2
- package/dist/cjs/migrations/v4.sql.js +4 -4
- package/dist/cjs/migrations/v5.d.ts +2 -0
- package/dist/cjs/migrations/v5.js +35 -0
- package/dist/cjs/migrations/v5.js.map +1 -0
- package/dist/cjs/migrations.d.ts +6 -2
- package/dist/cjs/migrations.js +62 -32
- package/dist/cjs/migrations.js.map +1 -1
- package/dist/cjs/migrations.test.d.ts +1 -0
- package/dist/cjs/migrations.test.js +121 -0
- package/dist/cjs/migrations.test.js.map +1 -0
- package/dist/cjs/types.d.ts +22 -22
- package/dist/cjs/types.js +2 -2
- package/dist/esm/Baselines.d.ts +15 -15
- package/dist/esm/Baselines.js +79 -79
- package/dist/esm/ClientConnection.d.ts +18 -18
- package/dist/esm/ClientConnection.js +101 -101
- package/dist/esm/MessageSender.d.ts +5 -5
- package/dist/esm/MessageSender.js +1 -1
- package/dist/esm/OperationHistory.d.ts +36 -36
- package/dist/esm/OperationHistory.js +116 -116
- package/dist/esm/Presence.d.ts +15 -15
- package/dist/esm/Presence.js +52 -52
- package/dist/esm/Profiles.d.ts +10 -10
- package/dist/esm/Profiles.js +15 -15
- package/dist/esm/ReplicaKeepaliveTimers.d.ts +17 -17
- package/dist/esm/ReplicaKeepaliveTimers.js +26 -26
- package/dist/esm/Replicas.d.ts +24 -24
- package/dist/esm/Replicas.js +133 -133
- package/dist/esm/Server.d.ts +143 -143
- package/dist/esm/Server.js +389 -389
- package/dist/esm/ServerLibrary.d.ts +77 -77
- package/dist/esm/ServerLibrary.js +483 -483
- package/dist/esm/ServerStorage.d.ts +44 -0
- package/dist/esm/ServerStorage.js +58 -0
- package/dist/esm/ServerStorage.js.map +1 -0
- package/dist/esm/TokenProvider.d.ts +16 -16
- package/dist/esm/TokenProvider.js +19 -19
- package/dist/esm/TokenVerifier.d.ts +16 -16
- package/dist/esm/TokenVerifier.js +21 -21
- package/dist/esm/files/FileMetadata.d.ts +28 -28
- package/dist/esm/files/FileMetadata.js +42 -42
- package/dist/esm/files/FileStorage.d.ts +35 -35
- package/dist/esm/files/FileStorage.js +44 -44
- package/dist/esm/index.d.ts +9 -9
- package/dist/esm/index.js +4 -4
- package/dist/esm/migrations/v0.d.ts +1 -0
- package/dist/esm/migrations/v0.js +27 -0
- package/dist/esm/migrations/v0.js.map +1 -0
- package/dist/esm/migrations/v0.sql.d.ts +2 -2
- package/dist/esm/migrations/v0.sql.js +1 -1
- package/dist/esm/migrations/v1.d.ts +1 -0
- package/dist/esm/migrations/v1.js +29 -0
- package/dist/esm/migrations/v1.js.map +1 -0
- package/dist/esm/migrations/v1.sql.d.ts +2 -2
- package/dist/esm/migrations/v1.sql.js +1 -1
- package/dist/esm/migrations/v2.d.ts +1 -0
- package/dist/esm/migrations/v2.js +26 -0
- package/dist/esm/migrations/v2.js.map +1 -0
- package/dist/esm/migrations/v2.sql.d.ts +2 -2
- package/dist/esm/migrations/v2.sql.js +2 -2
- package/dist/esm/migrations/v3.d.ts +1 -0
- package/dist/esm/migrations/v3.js +12 -0
- package/dist/esm/migrations/v3.js.map +1 -0
- package/dist/esm/migrations/v3.sql.d.ts +2 -2
- package/dist/esm/migrations/v3.sql.js +2 -2
- package/dist/esm/migrations/v4.d.ts +1 -0
- package/dist/esm/migrations/v4.js +6 -0
- package/dist/esm/migrations/v4.js.map +1 -0
- package/dist/esm/migrations/v4.sql.d.ts +2 -2
- package/dist/esm/migrations/v4.sql.js +2 -2
- package/dist/esm/migrations/v5.d.ts +2 -0
- package/dist/esm/migrations/v5.js +31 -0
- package/dist/esm/migrations/v5.js.map +1 -0
- package/dist/esm/migrations.d.ts +6 -2
- package/dist/esm/migrations.js +35 -25
- package/dist/esm/migrations.js.map +1 -1
- package/dist/esm/migrations.test.d.ts +1 -0
- package/dist/esm/migrations.test.js +116 -0
- package/dist/esm/migrations.test.js.map +1 -0
- package/dist/esm/types.d.ts +22 -22
- package/dist/esm/types.js +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/__snapshots__/migrations.test.ts.snap +55 -0
- package/src/migrations/{v0.sql.ts → v0.ts} +1 -1
- package/src/migrations/{v1.sql.ts → v1.ts} +1 -1
- package/src/migrations/{v2.sql.ts → v2.ts} +1 -1
- package/src/migrations/{v3.sql.ts → v3.ts} +1 -1
- package/src/migrations/{v4.sql.ts → v4.ts} +1 -1
- package/src/migrations/v5.ts +47 -0
- package/src/migrations.test.ts +133 -0
- package/src/migrations.ts +28 -19
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
8
|
+
const migrations_js_1 = require("./migrations.js");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
(0, vitest_1.describe)('the v5->v6 migration', () => {
|
|
11
|
+
let dbFile;
|
|
12
|
+
let db;
|
|
13
|
+
(0, vitest_1.beforeAll)(() => {
|
|
14
|
+
dbFile = `v5-migration-test-${Math.random()}.sqlite`;
|
|
15
|
+
db = (0, better_sqlite3_1.default)(dbFile);
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.afterAll)(() => {
|
|
18
|
+
db.close();
|
|
19
|
+
fs_1.default.rmSync(dbFile);
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.it)('rewrites legacy oids in all ops and baselines', () => {
|
|
22
|
+
// manually migrate to v4 before starting and seed the database with some
|
|
23
|
+
// operations and baselines.
|
|
24
|
+
(0, migrations_js_1.migrations)(db, 5);
|
|
25
|
+
// manually insert some operations and baselines
|
|
26
|
+
db.transaction(() => {
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
libraryId: 'test-1',
|
|
30
|
+
replicaId: 'foo',
|
|
31
|
+
oid: 'weirds/b',
|
|
32
|
+
data: {
|
|
33
|
+
op: 'set',
|
|
34
|
+
value: { '@@type': 'ref', id: 'weirds/b.objectMap.one:ghi' },
|
|
35
|
+
},
|
|
36
|
+
timestamp: '1',
|
|
37
|
+
serverOrder: 1,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
libraryId: 'test-1',
|
|
41
|
+
replicaId: 'foo',
|
|
42
|
+
oid: 'weirds/b.list:ghi',
|
|
43
|
+
data: {
|
|
44
|
+
op: 'list-push',
|
|
45
|
+
value: { '@@type': 'ref', id: 'weirds/b.list.#:abc' },
|
|
46
|
+
},
|
|
47
|
+
timestamp: '1',
|
|
48
|
+
serverOrder: 2,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
libraryId: 'test-1',
|
|
52
|
+
replicaId: 'foo',
|
|
53
|
+
oid: 'weirds/b.list:ghi',
|
|
54
|
+
data: {
|
|
55
|
+
op: 'list-remove',
|
|
56
|
+
value: { '@@type': 'ref', id: 'weirds/b.list.#:abc' },
|
|
57
|
+
},
|
|
58
|
+
timestamp: '2',
|
|
59
|
+
serverOrder: 3,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
libraryId: 'test-2',
|
|
63
|
+
replicaId: 'bar',
|
|
64
|
+
oid: 'weirds/b',
|
|
65
|
+
data: {
|
|
66
|
+
op: 'set',
|
|
67
|
+
value: { '@@type': 'ref', id: 'weirds/b.objectMap.one:ghi' },
|
|
68
|
+
},
|
|
69
|
+
timestamp: '1a',
|
|
70
|
+
serverOrder: 1,
|
|
71
|
+
},
|
|
72
|
+
].forEach(({ libraryId, replicaId, oid, data, timestamp, serverOrder }) => {
|
|
73
|
+
db.prepare(
|
|
74
|
+
/* sql */ `
|
|
75
|
+
INSERT INTO OperationHistory (libraryId, replicaId, oid, data, timestamp, serverOrder)
|
|
76
|
+
VALUES (?, ?, ?, ?, ?, ?);
|
|
77
|
+
`).run(libraryId, replicaId, oid, JSON.stringify(data), timestamp, serverOrder);
|
|
78
|
+
});
|
|
79
|
+
[
|
|
80
|
+
{
|
|
81
|
+
libraryId: 'test-1',
|
|
82
|
+
oid: 'weirds/b.objectMap.one:ghi',
|
|
83
|
+
snapshot: { '@@type': 'ref', id: 'weirds/b.list.#:abc' },
|
|
84
|
+
timestamp: '1',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
libraryId: 'test-2',
|
|
88
|
+
oid: 'weirds/b.objectMap.one:ghi',
|
|
89
|
+
snapshot: { '@@type': 'ref', id: 'weirds/b.list.#:abc' },
|
|
90
|
+
timestamp: '1a',
|
|
91
|
+
},
|
|
92
|
+
].forEach(({ libraryId, oid, snapshot, timestamp }) => {
|
|
93
|
+
db.prepare(
|
|
94
|
+
/* sql */ `
|
|
95
|
+
INSERT INTO DocumentBaseline (libraryId, oid, snapshot, timestamp)
|
|
96
|
+
VALUES (?, ?, ?, ?);
|
|
97
|
+
`).run(libraryId, oid, JSON.stringify(snapshot), timestamp);
|
|
98
|
+
});
|
|
99
|
+
})();
|
|
100
|
+
(0, migrations_js_1.migrations)(db);
|
|
101
|
+
// check that the operations and baselines have been rewritten
|
|
102
|
+
db.transaction(() => {
|
|
103
|
+
const operations = db
|
|
104
|
+
.prepare(
|
|
105
|
+
/* sql */ `
|
|
106
|
+
SELECT * from OperationHistory;
|
|
107
|
+
`)
|
|
108
|
+
.all();
|
|
109
|
+
(0, vitest_1.expect)(operations).toMatchSnapshot();
|
|
110
|
+
const baselines = db
|
|
111
|
+
.prepare(
|
|
112
|
+
/* sql */ `
|
|
113
|
+
SELECT * from DocumentBaseline;
|
|
114
|
+
`)
|
|
115
|
+
.all();
|
|
116
|
+
(0, vitest_1.expect)(baselines).toMatchSnapshot();
|
|
117
|
+
})();
|
|
118
|
+
db.close();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=migrations.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.test.js","sourceRoot":"","sources":["../../src/migrations.test.ts"],"names":[],"mappings":"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"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { DocumentBaseline, Operation, ReplicaInfo, ReplicaType } from '@verdant-web/common';
|
|
2
|
-
export interface OperationSpec extends Operation {
|
|
3
|
-
serverOrder: number;
|
|
4
|
-
replicaId: string;
|
|
5
|
-
}
|
|
6
|
-
export interface DocumentBaselineSpec extends Omit<DocumentBaseline<any>, 'snapshot'> {
|
|
7
|
-
snapshot: string;
|
|
8
|
-
libraryId: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ReplicaInfoSpec extends ReplicaInfo {
|
|
11
|
-
libraryId: string;
|
|
12
|
-
clientId: string;
|
|
13
|
-
lastSeenWallClockTime: number | null;
|
|
14
|
-
type: ReplicaType;
|
|
15
|
-
ackedServerOrder: number;
|
|
16
|
-
}
|
|
17
|
-
declare global {
|
|
18
|
-
interface File {
|
|
19
|
-
readonly lastModified: number;
|
|
20
|
-
readonly name: string;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import { DocumentBaseline, Operation, ReplicaInfo, ReplicaType } from '@verdant-web/common';
|
|
2
|
+
export interface OperationSpec extends Operation {
|
|
3
|
+
serverOrder: number;
|
|
4
|
+
replicaId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DocumentBaselineSpec extends Omit<DocumentBaseline<any>, 'snapshot'> {
|
|
7
|
+
snapshot: string;
|
|
8
|
+
libraryId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ReplicaInfoSpec extends ReplicaInfo {
|
|
11
|
+
libraryId: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
lastSeenWallClockTime: number | null;
|
|
14
|
+
type: ReplicaType;
|
|
15
|
+
ackedServerOrder: number;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface File {
|
|
19
|
+
readonly lastModified: number;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=types.js.map
|
package/dist/esm/Baselines.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { DocumentBaseline, Operation, Ref } from '@verdant-web/common';
|
|
2
|
-
import { Database } from 'better-sqlite3';
|
|
3
|
-
export declare class Baselines {
|
|
4
|
-
private db;
|
|
5
|
-
constructor(db: Database);
|
|
6
|
-
get: (libraryId: string, oid: string) => DocumentBaseline<any> | null;
|
|
7
|
-
getAllWithSubObjects: (libraryId: string, oid: string) => DocumentBaseline<any>[];
|
|
8
|
-
set: (libraryId: string, baseline: DocumentBaseline) => import("better-sqlite3").RunResult;
|
|
9
|
-
insertAll: (libraryId: string, baselines: DocumentBaseline[]) => void;
|
|
10
|
-
private hydrateSnapshot;
|
|
11
|
-
getAllAfter: (libraryId: string, timestamp: string | null) => DocumentBaseline<any>[];
|
|
12
|
-
applyOperations: (libraryId: string, oid: string, operations: Operation[], deletedRefs?: Ref[]) => never[] | undefined;
|
|
13
|
-
deleteAll: (libraryId: string) => void;
|
|
14
|
-
getCount: (libraryId: string) => number;
|
|
15
|
-
}
|
|
1
|
+
import { DocumentBaseline, Operation, Ref } from '@verdant-web/common';
|
|
2
|
+
import { Database } from 'better-sqlite3';
|
|
3
|
+
export declare class Baselines {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
get: (libraryId: string, oid: string) => DocumentBaseline<any> | null;
|
|
7
|
+
getAllWithSubObjects: (libraryId: string, oid: string) => DocumentBaseline<any>[];
|
|
8
|
+
set: (libraryId: string, baseline: DocumentBaseline) => import("better-sqlite3").RunResult;
|
|
9
|
+
insertAll: (libraryId: string, baselines: DocumentBaseline[]) => void;
|
|
10
|
+
private hydrateSnapshot;
|
|
11
|
+
getAllAfter: (libraryId: string, timestamp: string | null) => DocumentBaseline<any>[];
|
|
12
|
+
applyOperations: (libraryId: string, oid: string, operations: Operation[], deletedRefs?: Ref[]) => never[] | undefined;
|
|
13
|
+
deleteAll: (libraryId: string) => void;
|
|
14
|
+
getCount: (libraryId: string) => number;
|
|
15
|
+
}
|
package/dist/esm/Baselines.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { applyPatch, } from '@verdant-web/common';
|
|
2
|
-
export class Baselines {
|
|
3
|
-
constructor(db) {
|
|
4
|
-
this.db = db;
|
|
5
|
-
this.get = (libraryId, oid) => {
|
|
6
|
-
const row = this.db
|
|
1
|
+
import { applyPatch, } from '@verdant-web/common';
|
|
2
|
+
export class Baselines {
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
this.get = (libraryId, oid) => {
|
|
6
|
+
const row = this.db
|
|
7
7
|
.prepare(`
|
|
8
8
|
SELECT * FROM DocumentBaseline
|
|
9
9
|
WHERE libraryId = ? AND oid = ?
|
|
10
|
-
`)
|
|
11
|
-
.get(libraryId, oid);
|
|
12
|
-
if (!row) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return this.hydrateSnapshot(row);
|
|
16
|
-
};
|
|
17
|
-
this.getAllWithSubObjects = (libraryId, oid) => {
|
|
18
|
-
const rows = this.db
|
|
10
|
+
`)
|
|
11
|
+
.get(libraryId, oid);
|
|
12
|
+
if (!row) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return this.hydrateSnapshot(row);
|
|
16
|
+
};
|
|
17
|
+
this.getAllWithSubObjects = (libraryId, oid) => {
|
|
18
|
+
const rows = this.db
|
|
19
19
|
.prepare(`
|
|
20
20
|
SELECT * FROM DocumentBaseline
|
|
21
21
|
WHERE libraryId = ? AND oid LIKE ?
|
|
22
|
-
`)
|
|
23
|
-
.all(libraryId, `${oid}%`);
|
|
24
|
-
return rows.map(this.hydrateSnapshot);
|
|
25
|
-
};
|
|
26
|
-
this.set = (libraryId, baseline) => {
|
|
27
|
-
return this.db
|
|
22
|
+
`)
|
|
23
|
+
.all(libraryId, `${oid}%`);
|
|
24
|
+
return rows.map(this.hydrateSnapshot);
|
|
25
|
+
};
|
|
26
|
+
this.set = (libraryId, baseline) => {
|
|
27
|
+
return this.db
|
|
28
28
|
.prepare(`
|
|
29
29
|
INSERT OR REPLACE INTO DocumentBaseline (libraryId, oid, snapshot, timestamp)
|
|
30
30
|
VALUES (?, ?, ?, ?)
|
|
31
|
-
`)
|
|
32
|
-
.run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
|
|
33
|
-
};
|
|
34
|
-
this.insertAll = (libraryId, baselines) => {
|
|
35
|
-
const tx = this.db.transaction(() => {
|
|
36
|
-
for (const baseline of baselines) {
|
|
37
|
-
this.db
|
|
31
|
+
`)
|
|
32
|
+
.run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
|
|
33
|
+
};
|
|
34
|
+
this.insertAll = (libraryId, baselines) => {
|
|
35
|
+
const tx = this.db.transaction(() => {
|
|
36
|
+
for (const baseline of baselines) {
|
|
37
|
+
this.db
|
|
38
38
|
.prepare(`
|
|
39
39
|
INSERT OR REPLACE INTO DocumentBaseline (libraryId, oid, snapshot, timestamp)
|
|
40
40
|
VALUES (?, ?, ?, ?)
|
|
41
|
-
`)
|
|
42
|
-
.run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
tx();
|
|
46
|
-
};
|
|
47
|
-
this.hydrateSnapshot = (snapshot) => {
|
|
48
|
-
return Object.assign(Object.assign({}, snapshot), { snapshot: JSON.parse(snapshot.snapshot) });
|
|
49
|
-
};
|
|
50
|
-
this.getAllAfter = (libraryId, timestamp) => {
|
|
51
|
-
if (!timestamp) {
|
|
52
|
-
return this.db
|
|
41
|
+
`)
|
|
42
|
+
.run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
tx();
|
|
46
|
+
};
|
|
47
|
+
this.hydrateSnapshot = (snapshot) => {
|
|
48
|
+
return Object.assign(Object.assign({}, snapshot), { snapshot: JSON.parse(snapshot.snapshot) });
|
|
49
|
+
};
|
|
50
|
+
this.getAllAfter = (libraryId, timestamp) => {
|
|
51
|
+
if (!timestamp) {
|
|
52
|
+
return this.db
|
|
53
53
|
.prepare(`
|
|
54
54
|
SELECT * FROM DocumentBaseline
|
|
55
55
|
WHERE libraryId = ?
|
|
56
56
|
ORDER BY timestamp ASC
|
|
57
|
-
`)
|
|
58
|
-
.all(libraryId)
|
|
59
|
-
.map(this.hydrateSnapshot);
|
|
60
|
-
}
|
|
61
|
-
return this.db
|
|
57
|
+
`)
|
|
58
|
+
.all(libraryId)
|
|
59
|
+
.map(this.hydrateSnapshot);
|
|
60
|
+
}
|
|
61
|
+
return this.db
|
|
62
62
|
.prepare(`
|
|
63
63
|
SELECT * FROM DocumentBaseline
|
|
64
64
|
WHERE libraryId = ? AND timestamp > ?
|
|
65
65
|
ORDER BY timestamp ASC
|
|
66
|
-
`)
|
|
67
|
-
.all(libraryId, timestamp)
|
|
68
|
-
.map(this.hydrateSnapshot);
|
|
69
|
-
};
|
|
70
|
-
this.applyOperations = (libraryId, oid, operations, deletedRefs) => {
|
|
71
|
-
if (operations.length === 0)
|
|
72
|
-
return [];
|
|
73
|
-
let baseline = this.get(libraryId, oid);
|
|
74
|
-
if (!baseline) {
|
|
75
|
-
baseline = {
|
|
76
|
-
oid,
|
|
77
|
-
snapshot: {},
|
|
78
|
-
timestamp: operations[0].timestamp,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
for (const operation of operations) {
|
|
82
|
-
baseline.snapshot = applyPatch(baseline.snapshot, operation.data, deletedRefs);
|
|
83
|
-
}
|
|
84
|
-
baseline.timestamp = operations[operations.length - 1].timestamp;
|
|
85
|
-
this.set(libraryId, baseline);
|
|
86
|
-
};
|
|
87
|
-
this.deleteAll = (libraryId) => {
|
|
88
|
-
this.db
|
|
66
|
+
`)
|
|
67
|
+
.all(libraryId, timestamp)
|
|
68
|
+
.map(this.hydrateSnapshot);
|
|
69
|
+
};
|
|
70
|
+
this.applyOperations = (libraryId, oid, operations, deletedRefs) => {
|
|
71
|
+
if (operations.length === 0)
|
|
72
|
+
return [];
|
|
73
|
+
let baseline = this.get(libraryId, oid);
|
|
74
|
+
if (!baseline) {
|
|
75
|
+
baseline = {
|
|
76
|
+
oid,
|
|
77
|
+
snapshot: {},
|
|
78
|
+
timestamp: operations[0].timestamp,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
for (const operation of operations) {
|
|
82
|
+
baseline.snapshot = applyPatch(baseline.snapshot, operation.data, deletedRefs);
|
|
83
|
+
}
|
|
84
|
+
baseline.timestamp = operations[operations.length - 1].timestamp;
|
|
85
|
+
this.set(libraryId, baseline);
|
|
86
|
+
};
|
|
87
|
+
this.deleteAll = (libraryId) => {
|
|
88
|
+
this.db
|
|
89
89
|
.prepare(`
|
|
90
90
|
DELETE FROM DocumentBaseline
|
|
91
91
|
WHERE libraryId = ?
|
|
92
|
-
`)
|
|
93
|
-
.run(libraryId);
|
|
94
|
-
};
|
|
95
|
-
this.getCount = (libraryId) => {
|
|
96
|
-
var _a, _b;
|
|
97
|
-
return ((_b = (_a = this.db
|
|
92
|
+
`)
|
|
93
|
+
.run(libraryId);
|
|
94
|
+
};
|
|
95
|
+
this.getCount = (libraryId) => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
return ((_b = (_a = this.db
|
|
98
98
|
.prepare(`
|
|
99
99
|
SELECT COUNT(*) AS count FROM DocumentBaseline
|
|
100
100
|
WHERE libraryId = ?
|
|
101
|
-
`)
|
|
102
|
-
.get(libraryId)) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0);
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
101
|
+
`)
|
|
102
|
+
.get(libraryId)) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
106
|
//# sourceMappingURL=Baselines.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ServerMessage } from '@verdant-web/common';
|
|
2
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
-
import { WebSocket } from 'ws';
|
|
4
|
-
import { TokenInfo } from './TokenVerifier.js';
|
|
5
|
-
export declare class ClientConnectionManager {
|
|
6
|
-
private readonly connections;
|
|
7
|
-
private getLibraryConnections;
|
|
8
|
-
addSocket: (libraryId: string, key: string, socket: WebSocket, info: TokenInfo) => void;
|
|
9
|
-
addRequest: (libraryId: string, key: string, request: IncomingMessage, response: ServerResponse, info: TokenInfo) => () => void;
|
|
10
|
-
remove: (libraryId: string, key: string) => void;
|
|
11
|
-
respond: (libraryId: string, key: string, message: ServerMessage) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Broadcasts a message to all live-connected clients in a library.
|
|
14
|
-
* This does not reach push/pull clients.
|
|
15
|
-
*/
|
|
16
|
-
broadcast: (libraryId: string, message: ServerMessage, omitKeys?: string[]) => void;
|
|
17
|
-
disconnectAll: (libraryId: string) => void;
|
|
18
|
-
}
|
|
1
|
+
import { ServerMessage } from '@verdant-web/common';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { WebSocket } from 'ws';
|
|
4
|
+
import { TokenInfo } from './TokenVerifier.js';
|
|
5
|
+
export declare class ClientConnectionManager {
|
|
6
|
+
private readonly connections;
|
|
7
|
+
private getLibraryConnections;
|
|
8
|
+
addSocket: (libraryId: string, key: string, socket: WebSocket, info: TokenInfo) => void;
|
|
9
|
+
addRequest: (libraryId: string, key: string, request: IncomingMessage, response: ServerResponse, info: TokenInfo) => () => void;
|
|
10
|
+
remove: (libraryId: string, key: string) => void;
|
|
11
|
+
respond: (libraryId: string, key: string, message: ServerMessage) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Broadcasts a message to all live-connected clients in a library.
|
|
14
|
+
* This does not reach push/pull clients.
|
|
15
|
+
*/
|
|
16
|
+
broadcast: (libraryId: string, message: ServerMessage, omitKeys?: string[]) => void;
|
|
17
|
+
disconnectAll: (libraryId: string) => void;
|
|
18
|
+
}
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
class ClientConnection {
|
|
2
|
-
constructor(key) {
|
|
3
|
-
this.key = key;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
class RequestClientConnection extends ClientConnection {
|
|
7
|
-
constructor(key, req, res, info) {
|
|
8
|
-
super(key);
|
|
9
|
-
this.req = req;
|
|
10
|
-
this.res = res;
|
|
11
|
-
this.info = info;
|
|
12
|
-
this.type = 'request';
|
|
13
|
-
this.responses = [];
|
|
14
|
-
this.respond = (message) => {
|
|
15
|
-
this.responses.push(message);
|
|
16
|
-
};
|
|
17
|
-
this.end = () => {
|
|
18
|
-
this.res.writeHead(200, {
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
|
-
});
|
|
21
|
-
this.res.write(JSON.stringify({
|
|
22
|
-
messages: this.responses,
|
|
23
|
-
}));
|
|
24
|
-
this.res.end();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
class WebSocketClientConnection extends ClientConnection {
|
|
29
|
-
constructor(key, ws, info) {
|
|
30
|
-
super(key);
|
|
31
|
-
this.ws = ws;
|
|
32
|
-
this.info = info;
|
|
33
|
-
this.type = 'websocket';
|
|
34
|
-
this.respond = (message) => {
|
|
35
|
-
this.ws.send(JSON.stringify(message));
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export class ClientConnectionManager {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.connections = {};
|
|
42
|
-
this.getLibraryConnections = (libraryId) => {
|
|
43
|
-
if (!this.connections[libraryId]) {
|
|
44
|
-
this.connections[libraryId] = new Map();
|
|
45
|
-
}
|
|
46
|
-
return this.connections[libraryId];
|
|
47
|
-
};
|
|
48
|
-
this.addSocket = (libraryId, key, socket, info) => {
|
|
49
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
50
|
-
const connection = new WebSocketClientConnection(key, socket, info);
|
|
51
|
-
lib.set(key, connection);
|
|
52
|
-
socket.on('close', () => {
|
|
53
|
-
lib.delete(key);
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
this.addRequest = (libraryId, key, request, response, info) => {
|
|
57
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
58
|
-
const connection = new RequestClientConnection(key, request, response, info);
|
|
59
|
-
lib.set(key, connection);
|
|
60
|
-
return () => {
|
|
61
|
-
connection.end();
|
|
62
|
-
lib.delete(key);
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
this.remove = (libraryId, key) => {
|
|
66
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
67
|
-
lib.delete(key);
|
|
68
|
-
};
|
|
69
|
-
this.respond = (libraryId, key, message) => {
|
|
70
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
71
|
-
const connection = lib.get(key);
|
|
72
|
-
if (connection) {
|
|
73
|
-
connection.respond(message);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
throw new Error(`No connection found for library ${libraryId}, key ${key}`);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Broadcasts a message to all live-connected clients in a library.
|
|
81
|
-
* This does not reach push/pull clients.
|
|
82
|
-
*/
|
|
83
|
-
this.broadcast = (libraryId, message, omitKeys = []) => {
|
|
84
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
85
|
-
for (const [key, connection] of lib) {
|
|
86
|
-
if (!omitKeys.includes(key)) {
|
|
87
|
-
connection.respond(message);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
this.disconnectAll = (libraryId) => {
|
|
92
|
-
const lib = this.getLibraryConnections(libraryId);
|
|
93
|
-
for (const connection of lib.values()) {
|
|
94
|
-
if (connection instanceof WebSocketClientConnection) {
|
|
95
|
-
connection.ws.close();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
lib.clear();
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
class ClientConnection {
|
|
2
|
+
constructor(key) {
|
|
3
|
+
this.key = key;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class RequestClientConnection extends ClientConnection {
|
|
7
|
+
constructor(key, req, res, info) {
|
|
8
|
+
super(key);
|
|
9
|
+
this.req = req;
|
|
10
|
+
this.res = res;
|
|
11
|
+
this.info = info;
|
|
12
|
+
this.type = 'request';
|
|
13
|
+
this.responses = [];
|
|
14
|
+
this.respond = (message) => {
|
|
15
|
+
this.responses.push(message);
|
|
16
|
+
};
|
|
17
|
+
this.end = () => {
|
|
18
|
+
this.res.writeHead(200, {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
});
|
|
21
|
+
this.res.write(JSON.stringify({
|
|
22
|
+
messages: this.responses,
|
|
23
|
+
}));
|
|
24
|
+
this.res.end();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class WebSocketClientConnection extends ClientConnection {
|
|
29
|
+
constructor(key, ws, info) {
|
|
30
|
+
super(key);
|
|
31
|
+
this.ws = ws;
|
|
32
|
+
this.info = info;
|
|
33
|
+
this.type = 'websocket';
|
|
34
|
+
this.respond = (message) => {
|
|
35
|
+
this.ws.send(JSON.stringify(message));
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class ClientConnectionManager {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.connections = {};
|
|
42
|
+
this.getLibraryConnections = (libraryId) => {
|
|
43
|
+
if (!this.connections[libraryId]) {
|
|
44
|
+
this.connections[libraryId] = new Map();
|
|
45
|
+
}
|
|
46
|
+
return this.connections[libraryId];
|
|
47
|
+
};
|
|
48
|
+
this.addSocket = (libraryId, key, socket, info) => {
|
|
49
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
50
|
+
const connection = new WebSocketClientConnection(key, socket, info);
|
|
51
|
+
lib.set(key, connection);
|
|
52
|
+
socket.on('close', () => {
|
|
53
|
+
lib.delete(key);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
this.addRequest = (libraryId, key, request, response, info) => {
|
|
57
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
58
|
+
const connection = new RequestClientConnection(key, request, response, info);
|
|
59
|
+
lib.set(key, connection);
|
|
60
|
+
return () => {
|
|
61
|
+
connection.end();
|
|
62
|
+
lib.delete(key);
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
this.remove = (libraryId, key) => {
|
|
66
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
67
|
+
lib.delete(key);
|
|
68
|
+
};
|
|
69
|
+
this.respond = (libraryId, key, message) => {
|
|
70
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
71
|
+
const connection = lib.get(key);
|
|
72
|
+
if (connection) {
|
|
73
|
+
connection.respond(message);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new Error(`No connection found for library ${libraryId}, key ${key}`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Broadcasts a message to all live-connected clients in a library.
|
|
81
|
+
* This does not reach push/pull clients.
|
|
82
|
+
*/
|
|
83
|
+
this.broadcast = (libraryId, message, omitKeys = []) => {
|
|
84
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
85
|
+
for (const [key, connection] of lib) {
|
|
86
|
+
if (!omitKeys.includes(key)) {
|
|
87
|
+
connection.respond(message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
this.disconnectAll = (libraryId) => {
|
|
92
|
+
const lib = this.getLibraryConnections(libraryId);
|
|
93
|
+
for (const connection of lib.values()) {
|
|
94
|
+
if (connection instanceof WebSocketClientConnection) {
|
|
95
|
+
connection.ws.close();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
lib.clear();
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
102
|
//# sourceMappingURL=ClientConnection.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerMessage } from '@verdant-web/common';
|
|
2
|
-
export interface MessageSender {
|
|
3
|
-
broadcast(libraryId: string, message: ServerMessage, omitKeys?: string[]): void;
|
|
4
|
-
send(libraryId: string, clientKey: string, message: ServerMessage): void;
|
|
5
|
-
}
|
|
1
|
+
import { ServerMessage } from '@verdant-web/common';
|
|
2
|
+
export interface MessageSender {
|
|
3
|
+
broadcast(libraryId: string, message: ServerMessage, omitKeys?: string[]): void;
|
|
4
|
+
send(libraryId: string, clientKey: string, message: ServerMessage): void;
|
|
5
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=MessageSender.js.map
|