@verdant-web/server 1.8.14-next.1 → 1.8.14

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 (135) hide show
  1. package/dist/cjs/Baselines.d.ts +15 -15
  2. package/dist/cjs/Baselines.js +83 -83
  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 +36 -36
  8. package/dist/cjs/OperationHistory.js +120 -120
  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 +24 -24
  16. package/dist/cjs/Replicas.js +137 -137
  17. package/dist/cjs/Server.d.ts +143 -143
  18. package/dist/cjs/Server.js +396 -396
  19. package/dist/cjs/ServerLibrary.d.ts +77 -77
  20. package/dist/cjs/ServerLibrary.js +487 -487
  21. package/dist/cjs/TokenProvider.d.ts +16 -16
  22. package/dist/cjs/TokenProvider.js +26 -26
  23. package/dist/cjs/TokenVerifier.d.ts +16 -16
  24. package/dist/cjs/TokenVerifier.js +28 -28
  25. package/dist/cjs/files/FileMetadata.d.ts +28 -28
  26. package/dist/cjs/files/FileMetadata.js +46 -46
  27. package/dist/cjs/files/FileStorage.d.ts +35 -35
  28. package/dist/cjs/files/FileStorage.js +71 -71
  29. package/dist/cjs/index.d.ts +9 -9
  30. package/dist/cjs/index.js +11 -11
  31. package/dist/cjs/migrations/v0.d.ts +1 -1
  32. package/dist/cjs/migrations/v0.js +4 -4
  33. package/dist/cjs/migrations/v1.d.ts +1 -1
  34. package/dist/cjs/migrations/v1.js +4 -4
  35. package/dist/cjs/migrations/v2.d.ts +1 -1
  36. package/dist/cjs/migrations/v2.js +5 -5
  37. package/dist/cjs/migrations/v3.d.ts +1 -1
  38. package/dist/cjs/migrations/v3.js +5 -5
  39. package/dist/cjs/migrations/v4.d.ts +1 -1
  40. package/dist/cjs/migrations/v4.js +5 -5
  41. package/dist/cjs/migrations/v5.d.ts +2 -2
  42. package/dist/cjs/migrations/v5.js +26 -26
  43. package/dist/cjs/migrations.d.ts +6 -6
  44. package/dist/cjs/migrations.js +62 -62
  45. package/dist/cjs/migrations.test.d.ts +1 -1
  46. package/dist/cjs/migrations.test.js +110 -110
  47. package/dist/cjs/types.d.ts +22 -22
  48. package/dist/cjs/types.js +2 -2
  49. package/dist/esm/Baselines.d.ts +15 -15
  50. package/dist/esm/Baselines.js +79 -79
  51. package/dist/esm/ClientConnection.d.ts +18 -18
  52. package/dist/esm/ClientConnection.js +101 -101
  53. package/dist/esm/MessageSender.d.ts +5 -5
  54. package/dist/esm/MessageSender.js +1 -1
  55. package/dist/esm/OperationHistory.d.ts +36 -36
  56. package/dist/esm/OperationHistory.js +116 -116
  57. package/dist/esm/Presence.d.ts +15 -15
  58. package/dist/esm/Presence.js +52 -52
  59. package/dist/esm/Profiles.d.ts +10 -10
  60. package/dist/esm/Profiles.js +15 -15
  61. package/dist/esm/ReplicaKeepaliveTimers.d.ts +17 -17
  62. package/dist/esm/ReplicaKeepaliveTimers.js +26 -26
  63. package/dist/esm/Replicas.d.ts +24 -24
  64. package/dist/esm/Replicas.js +133 -133
  65. package/dist/esm/Server.d.ts +143 -143
  66. package/dist/esm/Server.js +389 -389
  67. package/dist/esm/ServerLibrary.d.ts +77 -77
  68. package/dist/esm/ServerLibrary.js +483 -483
  69. package/dist/esm/TokenProvider.d.ts +16 -16
  70. package/dist/esm/TokenProvider.js +19 -19
  71. package/dist/esm/TokenVerifier.d.ts +16 -16
  72. package/dist/esm/TokenVerifier.js +21 -21
  73. package/dist/esm/files/FileMetadata.d.ts +28 -28
  74. package/dist/esm/files/FileMetadata.js +42 -42
  75. package/dist/esm/files/FileStorage.d.ts +35 -35
  76. package/dist/esm/files/FileStorage.js +44 -44
  77. package/dist/esm/index.d.ts +9 -9
  78. package/dist/esm/index.js +4 -4
  79. package/dist/esm/migrations/v0.d.ts +1 -1
  80. package/dist/esm/migrations/v0.js +1 -1
  81. package/dist/esm/migrations/v1.d.ts +1 -1
  82. package/dist/esm/migrations/v1.js +1 -1
  83. package/dist/esm/migrations/v2.d.ts +1 -1
  84. package/dist/esm/migrations/v2.js +2 -2
  85. package/dist/esm/migrations/v3.d.ts +1 -1
  86. package/dist/esm/migrations/v3.js +2 -2
  87. package/dist/esm/migrations/v4.d.ts +1 -1
  88. package/dist/esm/migrations/v4.js +2 -2
  89. package/dist/esm/migrations/v5.d.ts +2 -2
  90. package/dist/esm/migrations/v5.js +22 -22
  91. package/dist/esm/migrations.d.ts +6 -6
  92. package/dist/esm/migrations.js +35 -35
  93. package/dist/esm/migrations.test.d.ts +1 -1
  94. package/dist/esm/migrations.test.js +105 -105
  95. package/dist/esm/types.d.ts +22 -22
  96. package/dist/esm/types.js +1 -1
  97. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  98. package/dist/tsconfig.tsbuildinfo +1 -1
  99. package/package.json +2 -2
  100. package/dist/cjs/ServerStorage.d.ts +0 -35
  101. package/dist/cjs/ServerStorage.js +0 -60
  102. package/dist/cjs/ServerStorage.js.map +0 -1
  103. package/dist/cjs/migrations/v0.sql.d.ts +0 -2
  104. package/dist/cjs/migrations/v0.sql.js +0 -29
  105. package/dist/cjs/migrations/v0.sql.js.map +0 -1
  106. package/dist/cjs/migrations/v1.sql.d.ts +0 -2
  107. package/dist/cjs/migrations/v1.sql.js +0 -31
  108. package/dist/cjs/migrations/v1.sql.js.map +0 -1
  109. package/dist/cjs/migrations/v2.sql.d.ts +0 -2
  110. package/dist/cjs/migrations/v2.sql.js +0 -28
  111. package/dist/cjs/migrations/v2.sql.js.map +0 -1
  112. package/dist/cjs/migrations/v3.sql.d.ts +0 -2
  113. package/dist/cjs/migrations/v3.sql.js +0 -14
  114. package/dist/cjs/migrations/v3.sql.js.map +0 -1
  115. package/dist/cjs/migrations/v4.sql.d.ts +0 -2
  116. package/dist/cjs/migrations/v4.sql.js +0 -8
  117. package/dist/cjs/migrations/v4.sql.js.map +0 -1
  118. package/dist/esm/ServerStorage.d.ts +0 -44
  119. package/dist/esm/ServerStorage.js +0 -58
  120. package/dist/esm/ServerStorage.js.map +0 -1
  121. package/dist/esm/migrations/v0.sql.d.ts +0 -2
  122. package/dist/esm/migrations/v0.sql.js +0 -27
  123. package/dist/esm/migrations/v0.sql.js.map +0 -1
  124. package/dist/esm/migrations/v1.sql.d.ts +0 -2
  125. package/dist/esm/migrations/v1.sql.js +0 -29
  126. package/dist/esm/migrations/v1.sql.js.map +0 -1
  127. package/dist/esm/migrations/v2.sql.d.ts +0 -2
  128. package/dist/esm/migrations/v2.sql.js +0 -26
  129. package/dist/esm/migrations/v2.sql.js.map +0 -1
  130. package/dist/esm/migrations/v3.sql.d.ts +0 -2
  131. package/dist/esm/migrations/v3.sql.js +0 -12
  132. package/dist/esm/migrations/v3.sql.js.map +0 -1
  133. package/dist/esm/migrations/v4.sql.d.ts +0 -2
  134. package/dist/esm/migrations/v4.sql.js +0 -6
  135. package/dist/esm/migrations/v4.sql.js.map +0 -1
@@ -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
@@ -1,36 +1,36 @@
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
- getLatestServerOrder: (libraryId: string) => number;
23
- getCount: (libraryId: string) => number;
24
- /**
25
- * Adds a new operation or replaces an existing one.
26
- * The server order will be set to the current max + 1
27
- */
28
- insert: (libraryId: string, replicaId: string, item: Operation) => import("better-sqlite3").RunResult;
29
- /**
30
- * Inserts all operations and updates the server
31
- * order for this library
32
- */
33
- insertAll: (libraryId: string, replicaId: string, items: Operation[]) => Promise<void>;
34
- dropAll: (libraryId: string, items: Pick<OperationSpec, 'replicaId' | 'oid' | 'timestamp'>[]) => Promise<void>;
35
- deleteAll: (libraryId: string) => void;
36
- }
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
+ getLatestServerOrder: (libraryId: string) => number;
23
+ getCount: (libraryId: string) => number;
24
+ /**
25
+ * Adds a new operation or replaces an existing one.
26
+ * The server order will be set to the current max + 1
27
+ */
28
+ insert: (libraryId: string, replicaId: string, item: Operation) => import("better-sqlite3").RunResult;
29
+ /**
30
+ * Inserts all operations and updates the server
31
+ * order for this library
32
+ */
33
+ insertAll: (libraryId: string, replicaId: string, items: Operation[]) => Promise<void>;
34
+ dropAll: (libraryId: string, items: Pick<OperationSpec, 'replicaId' | 'oid' | 'timestamp'>[]) => Promise<void>;
35
+ deleteAll: (libraryId: string) => void;
36
+ }