@verdant-web/server 1.7.8 → 1.7.10

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.
Files changed (100) hide show
  1. package/dist/cjs/Baselines.d.ts +14 -14
  2. package/dist/cjs/Baselines.js +77 -77
  3. package/dist/cjs/ClientConnection.d.ts +18 -18
  4. package/dist/cjs/ClientConnection.js +105 -105
  5. package/dist/cjs/MessageSender.d.ts +5 -5
  6. package/dist/cjs/MessageSender.js +2 -2
  7. package/dist/cjs/OperationHistory.d.ts +34 -34
  8. package/dist/cjs/OperationHistory.js +108 -108
  9. package/dist/cjs/Presence.d.ts +15 -15
  10. package/dist/cjs/Presence.js +59 -59
  11. package/dist/cjs/Profiles.d.ts +10 -10
  12. package/dist/cjs/Profiles.js +19 -19
  13. package/dist/cjs/ReplicaKeepaliveTimers.d.ts +17 -17
  14. package/dist/cjs/ReplicaKeepaliveTimers.js +30 -30
  15. package/dist/cjs/Replicas.d.ts +23 -23
  16. package/dist/cjs/Replicas.js +132 -132
  17. package/dist/cjs/Server.d.ts +121 -121
  18. package/dist/cjs/Server.js +385 -377
  19. package/dist/cjs/Server.js.map +1 -1
  20. package/dist/cjs/ServerLibrary.d.ts +63 -63
  21. package/dist/cjs/ServerLibrary.js +467 -467
  22. package/dist/cjs/TokenProvider.d.ts +16 -16
  23. package/dist/cjs/TokenProvider.js +26 -26
  24. package/dist/cjs/TokenVerifier.d.ts +16 -16
  25. package/dist/cjs/TokenVerifier.js +28 -28
  26. package/dist/cjs/files/FileMetadata.d.ts +28 -28
  27. package/dist/cjs/files/FileMetadata.js +46 -46
  28. package/dist/cjs/files/FileStorage.d.ts +35 -35
  29. package/dist/cjs/files/FileStorage.js +71 -71
  30. package/dist/cjs/index.d.ts +9 -9
  31. package/dist/cjs/index.js +11 -11
  32. package/dist/cjs/migrations/v0.sql.d.ts +2 -2
  33. package/dist/cjs/migrations/v0.sql.js +3 -3
  34. package/dist/cjs/migrations/v1.sql.d.ts +2 -2
  35. package/dist/cjs/migrations/v1.sql.js +3 -3
  36. package/dist/cjs/migrations/v2.sql.d.ts +2 -2
  37. package/dist/cjs/migrations/v2.sql.js +4 -4
  38. package/dist/cjs/migrations/v3.sql.d.ts +2 -2
  39. package/dist/cjs/migrations/v3.sql.js +4 -4
  40. package/dist/cjs/migrations/v4.sql.d.ts +2 -2
  41. package/dist/cjs/migrations/v4.sql.js +4 -4
  42. package/dist/cjs/migrations.d.ts +2 -2
  43. package/dist/cjs/migrations.js +32 -32
  44. package/dist/cjs/types.d.ts +22 -22
  45. package/dist/cjs/types.js +2 -2
  46. package/dist/esm/Baselines.d.ts +14 -14
  47. package/dist/esm/Baselines.js +73 -73
  48. package/dist/esm/ClientConnection.d.ts +18 -18
  49. package/dist/esm/ClientConnection.js +101 -101
  50. package/dist/esm/MessageSender.d.ts +5 -5
  51. package/dist/esm/MessageSender.js +1 -1
  52. package/dist/esm/OperationHistory.d.ts +34 -34
  53. package/dist/esm/OperationHistory.js +104 -104
  54. package/dist/esm/Presence.d.ts +15 -15
  55. package/dist/esm/Presence.js +52 -52
  56. package/dist/esm/Profiles.d.ts +10 -10
  57. package/dist/esm/Profiles.js +15 -15
  58. package/dist/esm/ReplicaKeepaliveTimers.d.ts +17 -17
  59. package/dist/esm/ReplicaKeepaliveTimers.js +26 -26
  60. package/dist/esm/Replicas.d.ts +23 -23
  61. package/dist/esm/Replicas.js +128 -128
  62. package/dist/esm/Server.d.ts +121 -121
  63. package/dist/esm/Server.js +378 -370
  64. package/dist/esm/Server.js.map +1 -1
  65. package/dist/esm/ServerLibrary.d.ts +63 -63
  66. package/dist/esm/ServerLibrary.js +463 -463
  67. package/dist/esm/TokenProvider.d.ts +16 -16
  68. package/dist/esm/TokenProvider.js +19 -19
  69. package/dist/esm/TokenVerifier.d.ts +16 -16
  70. package/dist/esm/TokenVerifier.js +21 -21
  71. package/dist/esm/files/FileMetadata.d.ts +28 -28
  72. package/dist/esm/files/FileMetadata.js +42 -42
  73. package/dist/esm/files/FileStorage.d.ts +35 -35
  74. package/dist/esm/files/FileStorage.js +44 -44
  75. package/dist/esm/index.d.ts +9 -9
  76. package/dist/esm/index.js +4 -4
  77. package/dist/esm/migrations/v0.sql.d.ts +2 -2
  78. package/dist/esm/migrations/v0.sql.js +1 -1
  79. package/dist/esm/migrations/v1.sql.d.ts +2 -2
  80. package/dist/esm/migrations/v1.sql.js +1 -1
  81. package/dist/esm/migrations/v2.sql.d.ts +2 -2
  82. package/dist/esm/migrations/v2.sql.js +2 -2
  83. package/dist/esm/migrations/v3.sql.d.ts +2 -2
  84. package/dist/esm/migrations/v3.sql.js +2 -2
  85. package/dist/esm/migrations/v4.sql.d.ts +2 -2
  86. package/dist/esm/migrations/v4.sql.js +2 -2
  87. package/dist/esm/migrations.d.ts +2 -2
  88. package/dist/esm/migrations.js +25 -25
  89. package/dist/esm/types.d.ts +22 -22
  90. package/dist/esm/types.js +1 -1
  91. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  92. package/dist/tsconfig.tsbuildinfo +1 -1
  93. package/package.json +2 -2
  94. package/src/Server.ts +9 -2
  95. package/dist/cjs/ServerStorage.d.ts +0 -35
  96. package/dist/cjs/ServerStorage.js +0 -60
  97. package/dist/cjs/ServerStorage.js.map +0 -1
  98. package/dist/esm/ServerStorage.d.ts +0 -44
  99. package/dist/esm/ServerStorage.js +0 -58
  100. package/dist/esm/ServerStorage.js.map +0 -1
@@ -1,14 +1,14 @@
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
- }
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
+ }
@@ -1,101 +1,101 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Baselines = void 0;
4
- const common_1 = require("@verdant-web/common");
5
- class Baselines {
6
- constructor(db) {
7
- this.db = db;
8
- this.get = (libraryId, oid) => {
9
- const row = this.db
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Baselines = void 0;
4
+ const common_1 = require("@verdant-web/common");
5
+ class Baselines {
6
+ constructor(db) {
7
+ this.db = db;
8
+ this.get = (libraryId, oid) => {
9
+ const row = this.db
10
10
  .prepare(`
11
11
  SELECT * FROM DocumentBaseline
12
12
  WHERE libraryId = ? AND oid = ?
13
- `)
14
- .get(libraryId, oid);
15
- if (!row) {
16
- return null;
17
- }
18
- return this.hydrateSnapshot(row);
19
- };
20
- this.getAllWithSubObjects = (libraryId, oid) => {
21
- const rows = this.db
13
+ `)
14
+ .get(libraryId, oid);
15
+ if (!row) {
16
+ return null;
17
+ }
18
+ return this.hydrateSnapshot(row);
19
+ };
20
+ this.getAllWithSubObjects = (libraryId, oid) => {
21
+ const rows = this.db
22
22
  .prepare(`
23
23
  SELECT * FROM DocumentBaseline
24
24
  WHERE libraryId = ? AND oid LIKE ?
25
- `)
26
- .all(libraryId, `${oid}%`);
27
- return rows.map(this.hydrateSnapshot);
28
- };
29
- this.set = (libraryId, baseline) => {
30
- return this.db
25
+ `)
26
+ .all(libraryId, `${oid}%`);
27
+ return rows.map(this.hydrateSnapshot);
28
+ };
29
+ this.set = (libraryId, baseline) => {
30
+ return this.db
31
31
  .prepare(`
32
32
  INSERT OR REPLACE INTO DocumentBaseline (libraryId, oid, snapshot, timestamp)
33
33
  VALUES (?, ?, ?, ?)
34
- `)
35
- .run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
36
- };
37
- this.insertAll = (libraryId, baselines) => {
38
- const tx = this.db.transaction(() => {
39
- for (const baseline of baselines) {
40
- this.db
34
+ `)
35
+ .run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
36
+ };
37
+ this.insertAll = (libraryId, baselines) => {
38
+ const tx = this.db.transaction(() => {
39
+ for (const baseline of baselines) {
40
+ this.db
41
41
  .prepare(`
42
42
  INSERT OR REPLACE INTO DocumentBaseline (libraryId, oid, snapshot, timestamp)
43
43
  VALUES (?, ?, ?, ?)
44
- `)
45
- .run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
46
- }
47
- });
48
- tx();
49
- };
50
- this.hydrateSnapshot = (snapshot) => {
51
- return Object.assign(Object.assign({}, snapshot), { snapshot: JSON.parse(snapshot.snapshot) });
52
- };
53
- this.getAllAfter = (libraryId, timestamp) => {
54
- if (!timestamp) {
55
- return this.db
44
+ `)
45
+ .run(libraryId, baseline.oid, JSON.stringify(baseline.snapshot), baseline.timestamp);
46
+ }
47
+ });
48
+ tx();
49
+ };
50
+ this.hydrateSnapshot = (snapshot) => {
51
+ return Object.assign(Object.assign({}, snapshot), { snapshot: JSON.parse(snapshot.snapshot) });
52
+ };
53
+ this.getAllAfter = (libraryId, timestamp) => {
54
+ if (!timestamp) {
55
+ return this.db
56
56
  .prepare(`
57
57
  SELECT * FROM DocumentBaseline
58
58
  WHERE libraryId = ?
59
59
  ORDER BY timestamp ASC
60
- `)
61
- .all(libraryId)
62
- .map(this.hydrateSnapshot);
63
- }
64
- return this.db
60
+ `)
61
+ .all(libraryId)
62
+ .map(this.hydrateSnapshot);
63
+ }
64
+ return this.db
65
65
  .prepare(`
66
66
  SELECT * FROM DocumentBaseline
67
67
  WHERE libraryId = ? AND timestamp > ?
68
68
  ORDER BY timestamp ASC
69
- `)
70
- .all(libraryId, timestamp)
71
- .map(this.hydrateSnapshot);
72
- };
73
- this.applyOperations = (libraryId, oid, operations, deletedRefs) => {
74
- if (operations.length === 0)
75
- return [];
76
- let baseline = this.get(libraryId, oid);
77
- if (!baseline) {
78
- baseline = {
79
- oid,
80
- snapshot: {},
81
- timestamp: operations[0].timestamp,
82
- };
83
- }
84
- for (const operation of operations) {
85
- baseline.snapshot = (0, common_1.applyPatch)(baseline.snapshot, operation.data, deletedRefs);
86
- }
87
- baseline.timestamp = operations[operations.length - 1].timestamp;
88
- this.set(libraryId, baseline);
89
- };
90
- this.deleteAll = (libraryId) => {
91
- this.db
69
+ `)
70
+ .all(libraryId, timestamp)
71
+ .map(this.hydrateSnapshot);
72
+ };
73
+ this.applyOperations = (libraryId, oid, operations, deletedRefs) => {
74
+ if (operations.length === 0)
75
+ return [];
76
+ let baseline = this.get(libraryId, oid);
77
+ if (!baseline) {
78
+ baseline = {
79
+ oid,
80
+ snapshot: {},
81
+ timestamp: operations[0].timestamp,
82
+ };
83
+ }
84
+ for (const operation of operations) {
85
+ baseline.snapshot = (0, common_1.applyPatch)(baseline.snapshot, operation.data, deletedRefs);
86
+ }
87
+ baseline.timestamp = operations[operations.length - 1].timestamp;
88
+ this.set(libraryId, baseline);
89
+ };
90
+ this.deleteAll = (libraryId) => {
91
+ this.db
92
92
  .prepare(`
93
93
  DELETE FROM DocumentBaseline
94
94
  WHERE libraryId = ?
95
- `)
96
- .run(libraryId);
97
- };
98
- }
99
- }
100
- exports.Baselines = Baselines;
95
+ `)
96
+ .run(libraryId);
97
+ };
98
+ }
99
+ }
100
+ exports.Baselines = Baselines;
101
101
  //# 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,106 +1,106 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientConnectionManager = void 0;
4
- class ClientConnection {
5
- constructor(key) {
6
- this.key = key;
7
- }
8
- }
9
- class RequestClientConnection extends ClientConnection {
10
- constructor(key, req, res, info) {
11
- super(key);
12
- this.req = req;
13
- this.res = res;
14
- this.info = info;
15
- this.type = 'request';
16
- this.responses = [];
17
- this.respond = (message) => {
18
- this.responses.push(message);
19
- };
20
- this.end = () => {
21
- this.res.writeHead(200, {
22
- 'Content-Type': 'application/json',
23
- });
24
- this.res.write(JSON.stringify({
25
- messages: this.responses,
26
- }));
27
- this.res.end();
28
- };
29
- }
30
- }
31
- class WebSocketClientConnection extends ClientConnection {
32
- constructor(key, ws, info) {
33
- super(key);
34
- this.ws = ws;
35
- this.info = info;
36
- this.type = 'websocket';
37
- this.respond = (message) => {
38
- this.ws.send(JSON.stringify(message));
39
- };
40
- }
41
- }
42
- class ClientConnectionManager {
43
- constructor() {
44
- this.connections = {};
45
- this.getLibraryConnections = (libraryId) => {
46
- if (!this.connections[libraryId]) {
47
- this.connections[libraryId] = new Map();
48
- }
49
- return this.connections[libraryId];
50
- };
51
- this.addSocket = (libraryId, key, socket, info) => {
52
- const lib = this.getLibraryConnections(libraryId);
53
- const connection = new WebSocketClientConnection(key, socket, info);
54
- lib.set(key, connection);
55
- socket.on('close', () => {
56
- lib.delete(key);
57
- });
58
- };
59
- this.addRequest = (libraryId, key, request, response, info) => {
60
- const lib = this.getLibraryConnections(libraryId);
61
- const connection = new RequestClientConnection(key, request, response, info);
62
- lib.set(key, connection);
63
- return () => {
64
- connection.end();
65
- lib.delete(key);
66
- };
67
- };
68
- this.remove = (libraryId, key) => {
69
- const lib = this.getLibraryConnections(libraryId);
70
- lib.delete(key);
71
- };
72
- this.respond = (libraryId, key, message) => {
73
- const lib = this.getLibraryConnections(libraryId);
74
- const connection = lib.get(key);
75
- if (connection) {
76
- connection.respond(message);
77
- }
78
- else {
79
- throw new Error(`No connection found for library ${libraryId}, key ${key}`);
80
- }
81
- };
82
- /**
83
- * Broadcasts a message to all live-connected clients in a library.
84
- * This does not reach push/pull clients.
85
- */
86
- this.broadcast = (libraryId, message, omitKeys = []) => {
87
- const lib = this.getLibraryConnections(libraryId);
88
- for (const [key, connection] of lib) {
89
- if (!omitKeys.includes(key)) {
90
- connection.respond(message);
91
- }
92
- }
93
- };
94
- this.disconnectAll = (libraryId) => {
95
- const lib = this.getLibraryConnections(libraryId);
96
- for (const connection of lib.values()) {
97
- if (connection instanceof WebSocketClientConnection) {
98
- connection.ws.close();
99
- }
100
- }
101
- lib.clear();
102
- };
103
- }
104
- }
105
- exports.ClientConnectionManager = ClientConnectionManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientConnectionManager = void 0;
4
+ class ClientConnection {
5
+ constructor(key) {
6
+ this.key = key;
7
+ }
8
+ }
9
+ class RequestClientConnection extends ClientConnection {
10
+ constructor(key, req, res, info) {
11
+ super(key);
12
+ this.req = req;
13
+ this.res = res;
14
+ this.info = info;
15
+ this.type = 'request';
16
+ this.responses = [];
17
+ this.respond = (message) => {
18
+ this.responses.push(message);
19
+ };
20
+ this.end = () => {
21
+ this.res.writeHead(200, {
22
+ 'Content-Type': 'application/json',
23
+ });
24
+ this.res.write(JSON.stringify({
25
+ messages: this.responses,
26
+ }));
27
+ this.res.end();
28
+ };
29
+ }
30
+ }
31
+ class WebSocketClientConnection extends ClientConnection {
32
+ constructor(key, ws, info) {
33
+ super(key);
34
+ this.ws = ws;
35
+ this.info = info;
36
+ this.type = 'websocket';
37
+ this.respond = (message) => {
38
+ this.ws.send(JSON.stringify(message));
39
+ };
40
+ }
41
+ }
42
+ class ClientConnectionManager {
43
+ constructor() {
44
+ this.connections = {};
45
+ this.getLibraryConnections = (libraryId) => {
46
+ if (!this.connections[libraryId]) {
47
+ this.connections[libraryId] = new Map();
48
+ }
49
+ return this.connections[libraryId];
50
+ };
51
+ this.addSocket = (libraryId, key, socket, info) => {
52
+ const lib = this.getLibraryConnections(libraryId);
53
+ const connection = new WebSocketClientConnection(key, socket, info);
54
+ lib.set(key, connection);
55
+ socket.on('close', () => {
56
+ lib.delete(key);
57
+ });
58
+ };
59
+ this.addRequest = (libraryId, key, request, response, info) => {
60
+ const lib = this.getLibraryConnections(libraryId);
61
+ const connection = new RequestClientConnection(key, request, response, info);
62
+ lib.set(key, connection);
63
+ return () => {
64
+ connection.end();
65
+ lib.delete(key);
66
+ };
67
+ };
68
+ this.remove = (libraryId, key) => {
69
+ const lib = this.getLibraryConnections(libraryId);
70
+ lib.delete(key);
71
+ };
72
+ this.respond = (libraryId, key, message) => {
73
+ const lib = this.getLibraryConnections(libraryId);
74
+ const connection = lib.get(key);
75
+ if (connection) {
76
+ connection.respond(message);
77
+ }
78
+ else {
79
+ throw new Error(`No connection found for library ${libraryId}, key ${key}`);
80
+ }
81
+ };
82
+ /**
83
+ * Broadcasts a message to all live-connected clients in a library.
84
+ * This does not reach push/pull clients.
85
+ */
86
+ this.broadcast = (libraryId, message, omitKeys = []) => {
87
+ const lib = this.getLibraryConnections(libraryId);
88
+ for (const [key, connection] of lib) {
89
+ if (!omitKeys.includes(key)) {
90
+ connection.respond(message);
91
+ }
92
+ }
93
+ };
94
+ this.disconnectAll = (libraryId) => {
95
+ const lib = this.getLibraryConnections(libraryId);
96
+ for (const connection of lib.values()) {
97
+ if (connection instanceof WebSocketClientConnection) {
98
+ connection.ws.close();
99
+ }
100
+ }
101
+ lib.clear();
102
+ };
103
+ }
104
+ }
105
+ exports.ClientConnectionManager = ClientConnectionManager;
106
106
  //# 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,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=MessageSender.js.map
@@ -1,34 +1,34 @@
1
- import { Operation } from '@verdant-web/common';
2
- import { Database } from 'better-sqlite3';
3
- import { OperationSpec } from './types.js';
4
- export declare class OperationHistory {
5
- private db;
6
- constructor(db: Database);
7
- private hydratePatch;
8
- getAllFor: (libraryId: string, oid: string) => OperationSpec[];
9
- getEarliest: (libraryId: string, count: number) => OperationSpec[];
10
- getAfter: (libraryId: string, timestamp?: string | null) => OperationSpec[];
11
- /**
12
- * Returns all operations before the given timestamp
13
- * in ascending chronological order
14
- */
15
- getBefore: (libraryId: string, before: string) => OperationSpec[];
16
- /**
17
- * Returns all operations after a given server order. Useful
18
- * for retrieving operations that were created after a client
19
- * last synced.
20
- */
21
- getFromServerOrder: (libraryId: string, serverOrder: number) => OperationSpec[];
22
- /**
23
- * Adds a new operation or replaces an existing one.
24
- * The server order will be set to the current max + 1
25
- */
26
- insert: (libraryId: string, replicaId: string, item: Operation) => import("better-sqlite3").RunResult;
27
- /**
28
- * Inserts all operations and updates the server
29
- * order for this library
30
- */
31
- insertAll: (libraryId: string, replicaId: string, items: Operation[]) => Promise<void>;
32
- dropAll: (libraryId: string, items: Pick<OperationSpec, 'replicaId' | 'oid' | 'timestamp'>[]) => Promise<void>;
33
- deleteAll: (libraryId: string) => void;
34
- }
1
+ import { Operation } from '@verdant-web/common';
2
+ import { Database } from 'better-sqlite3';
3
+ import { OperationSpec } from './types.js';
4
+ export declare class OperationHistory {
5
+ private db;
6
+ constructor(db: Database);
7
+ private hydratePatch;
8
+ getAllFor: (libraryId: string, oid: string) => OperationSpec[];
9
+ getEarliest: (libraryId: string, count: number) => OperationSpec[];
10
+ getAfter: (libraryId: string, timestamp?: string | null) => OperationSpec[];
11
+ /**
12
+ * Returns all operations before the given timestamp
13
+ * in ascending chronological order
14
+ */
15
+ getBefore: (libraryId: string, before: string) => OperationSpec[];
16
+ /**
17
+ * Returns all operations after a given server order. Useful
18
+ * for retrieving operations that were created after a client
19
+ * last synced.
20
+ */
21
+ getFromServerOrder: (libraryId: string, serverOrder: number) => OperationSpec[];
22
+ /**
23
+ * Adds a new operation or replaces an existing one.
24
+ * The server order will be set to the current max + 1
25
+ */
26
+ insert: (libraryId: string, replicaId: string, item: Operation) => import("better-sqlite3").RunResult;
27
+ /**
28
+ * Inserts all operations and updates the server
29
+ * order for this library
30
+ */
31
+ insertAll: (libraryId: string, replicaId: string, items: Operation[]) => Promise<void>;
32
+ dropAll: (libraryId: string, items: Pick<OperationSpec, 'replicaId' | 'oid' | 'timestamp'>[]) => Promise<void>;
33
+ deleteAll: (libraryId: string) => void;
34
+ }