@verdant-web/server 3.3.10 → 4.0.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/bin/server.mjs +110 -107
- package/dist/esm/TokenVerifier.d.ts +1 -0
- package/dist/esm/TokenVerifier.js +3 -0
- package/dist/esm/TokenVerifier.js.map +1 -1
- package/dist/esm/adapters/node/errorHandler.d.ts +2 -0
- package/dist/esm/adapters/node/errorHandler.js +12 -0
- package/dist/esm/adapters/node/errorHandler.js.map +1 -0
- package/dist/esm/adapters/node/getRequestToken.d.ts +1 -0
- package/dist/esm/adapters/node/getRequestToken.js +25 -0
- package/dist/esm/adapters/node/getRequestToken.js.map +1 -0
- package/dist/esm/adapters/node/httpRouter.d.ts +47 -0
- package/dist/esm/adapters/node/httpRouter.js +88 -0
- package/dist/esm/adapters/node/httpRouter.js.map +1 -0
- package/dist/esm/adapters/node/index.d.ts +5 -0
- package/dist/esm/adapters/node/index.js +6 -0
- package/dist/esm/adapters/node/index.js.map +1 -0
- package/dist/esm/adapters/node/tokenMiddleware.d.ts +7 -0
- package/dist/esm/adapters/node/tokenMiddleware.js +22 -0
- package/dist/esm/adapters/node/tokenMiddleware.js.map +1 -0
- package/dist/esm/adapters/node/websocketHandler.d.ts +4 -0
- package/dist/esm/adapters/node/websocketHandler.js +54 -0
- package/dist/esm/adapters/node/websocketHandler.js.map +1 -0
- package/dist/esm/connections/ClientConnection.d.ts +25 -0
- package/dist/esm/{ClientConnection.js → connections/ClientConnection.js} +47 -38
- package/dist/esm/connections/ClientConnection.js.map +1 -0
- package/dist/esm/connections/MessageSender.d.ts +5 -0
- package/dist/esm/connections/MessageSender.js.map +1 -0
- package/dist/esm/connections/Presence.d.ts +23 -0
- package/dist/esm/connections/Presence.js +65 -0
- package/dist/esm/connections/Presence.js.map +1 -0
- package/dist/esm/core.d.ts +15 -0
- package/dist/esm/core.js +15 -0
- package/dist/esm/core.js.map +1 -0
- package/dist/esm/defaults.d.ts +2 -0
- package/dist/esm/defaults.js +3 -0
- package/dist/esm/defaults.js.map +1 -0
- package/dist/esm/files/FileStorage.d.ts +12 -3
- package/dist/esm/files/FileStorage.js +20 -0
- package/dist/esm/files/FileStorage.js.map +1 -1
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internals.d.ts +14 -0
- package/dist/esm/internals.js +12 -0
- package/dist/esm/internals.js.map +1 -0
- package/dist/esm/libraries/Library.d.ts +78 -0
- package/dist/esm/{ServerLibrary.js → libraries/Library.js} +153 -144
- package/dist/esm/libraries/Library.js.map +1 -0
- package/dist/esm/{ServerLibrary.test.js → libraries/Library.test.js} +42 -33
- package/dist/esm/libraries/Library.test.js.map +1 -0
- package/dist/esm/libraries/generic.d.ts +8 -0
- package/dist/esm/libraries/generic.js +2 -0
- package/dist/esm/libraries/generic.js.map +1 -0
- package/dist/esm/libraries/singleNode.d.ts +53 -0
- package/dist/esm/libraries/singleNode.js +88 -0
- package/dist/esm/libraries/singleNode.js.map +1 -0
- package/dist/esm/logger.d.ts +1 -0
- package/dist/esm/logger.js +2 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/storage/Storage.d.ts +39 -38
- package/dist/esm/storage/StorageManager.d.ts +11 -0
- package/dist/esm/storage/StorageManager.js +32 -0
- package/dist/esm/storage/StorageManager.js.map +1 -0
- package/dist/esm/storage/index.d.ts +1 -2
- package/dist/esm/storage/index.js +1 -2
- package/dist/esm/storage/index.js.map +1 -1
- package/dist/esm/storage/sqlShard/Databases.d.ts +5 -3
- package/dist/esm/storage/sqlShard/Databases.js +11 -7
- package/dist/esm/storage/sqlShard/Databases.js.map +1 -1
- package/dist/esm/storage/sqlShard/SqlBaselines.d.ts +16 -17
- package/dist/esm/storage/sqlShard/SqlBaselines.js +55 -59
- package/dist/esm/storage/sqlShard/SqlBaselines.js.map +1 -1
- package/dist/esm/storage/sqlShard/SqlFileMetadata.d.ts +13 -13
- package/dist/esm/storage/sqlShard/SqlFileMetadata.js +44 -57
- package/dist/esm/storage/sqlShard/SqlFileMetadata.js.map +1 -1
- package/dist/esm/storage/sqlShard/SqlOperations.d.ts +12 -12
- package/dist/esm/storage/sqlShard/SqlOperations.js +38 -73
- package/dist/esm/storage/sqlShard/SqlOperations.js.map +1 -1
- package/dist/esm/storage/sqlShard/SqlReplicas.d.ts +18 -17
- package/dist/esm/storage/sqlShard/SqlReplicas.js +63 -100
- package/dist/esm/storage/sqlShard/SqlReplicas.js.map +1 -1
- package/dist/esm/storage/sqlShard/database.d.ts +25 -5
- package/dist/esm/storage/sqlShard/database.js +47 -15
- package/dist/esm/storage/sqlShard/database.js.map +1 -1
- package/dist/esm/storage/sqlShard/migrations/v1.d.ts +2 -3
- package/dist/esm/storage/sqlShard/migrations/v1.js +42 -47
- package/dist/esm/storage/sqlShard/migrations/v1.js.map +1 -1
- package/dist/esm/storage/sqlShard/migrations/v2.d.ts +2 -3
- package/dist/esm/storage/sqlShard/migrations/v2.js +5 -15
- package/dist/esm/storage/sqlShard/migrations/v2.js.map +1 -1
- package/dist/esm/storage/sqlShard/migrations.d.ts +5 -7
- package/dist/esm/storage/sqlShard/migrations.js +48 -1
- package/dist/esm/storage/sqlShard/migrations.js.map +1 -1
- package/dist/esm/storage/sqlShard/sqlShardStorage.d.ts +25 -4
- package/dist/esm/storage/sqlShard/sqlShardStorage.js +43 -40
- package/dist/esm/storage/sqlShard/sqlShardStorage.js.map +1 -1
- package/dist/esm/storage/sqlShard/tables.d.ts +9 -6
- package/dist/esm/types.d.ts +1 -2
- package/package.json +24 -13
- package/src/TokenVerifier.ts +4 -0
- package/src/adapters/node/errorHandler.ts +18 -0
- package/src/adapters/node/getRequestToken.ts +34 -0
- package/src/adapters/node/httpRouter.ts +139 -0
- package/src/adapters/node/index.ts +5 -0
- package/src/adapters/node/tokenMiddleware.ts +32 -0
- package/src/adapters/node/websocketHandler.ts +79 -0
- package/src/{ClientConnection.ts → connections/ClientConnection.ts} +64 -57
- package/src/connections/MessageSender.ts +6 -0
- package/src/connections/Presence.ts +95 -0
- package/src/core.ts +36 -0
- package/src/defaults.ts +2 -0
- package/src/files/FileStorage.ts +36 -3
- package/src/index.ts +7 -7
- package/src/internals.ts +14 -0
- package/src/{ServerLibrary.test.ts → libraries/Library.test.ts} +51 -49
- package/src/{ServerLibrary.ts → libraries/Library.ts} +203 -206
- package/src/libraries/generic.ts +9 -0
- package/src/libraries/singleNode.ts +145 -0
- package/src/logger.ts +4 -0
- package/src/storage/Storage.ts +37 -66
- package/src/storage/StorageManager.ts +39 -0
- package/src/storage/index.ts +1 -2
- package/src/storage/sqlShard/Databases.ts +26 -13
- package/src/storage/sqlShard/SqlBaselines.ts +58 -67
- package/src/storage/sqlShard/SqlFileMetadata.ts +51 -72
- package/src/storage/sqlShard/SqlOperations.ts +57 -81
- package/src/storage/sqlShard/SqlReplicas.ts +80 -121
- package/src/storage/sqlShard/database.ts +82 -18
- package/src/storage/sqlShard/migrations/v1.ts +42 -52
- package/src/storage/sqlShard/migrations/v2.ts +5 -19
- package/src/storage/sqlShard/migrations.ts +66 -1
- package/src/storage/sqlShard/sqlShardStorage.ts +56 -55
- package/src/storage/sqlShard/tables.ts +6 -6
- package/src/types.ts +1 -2
- package/dist/esm/ClientConnection.d.ts +0 -19
- package/dist/esm/ClientConnection.js.map +0 -1
- package/dist/esm/MessageSender.d.ts +0 -5
- package/dist/esm/MessageSender.js.map +0 -1
- package/dist/esm/Presence.d.ts +0 -18
- package/dist/esm/Presence.js +0 -65
- package/dist/esm/Presence.js.map +0 -1
- package/dist/esm/ReplicaKeepaliveTimers.d.ts +0 -17
- package/dist/esm/ReplicaKeepaliveTimers.js +0 -27
- package/dist/esm/ReplicaKeepaliveTimers.js.map +0 -1
- package/dist/esm/Server.d.ts +0 -166
- package/dist/esm/Server.js +0 -572
- package/dist/esm/Server.js.map +0 -1
- package/dist/esm/ServerLibrary.d.ts +0 -64
- package/dist/esm/ServerLibrary.js.map +0 -1
- package/dist/esm/ServerLibrary.test.js.map +0 -1
- package/dist/esm/storage/sql/SqlBaselines.d.ts +0 -22
- package/dist/esm/storage/sql/SqlBaselines.js +0 -107
- package/dist/esm/storage/sql/SqlBaselines.js.map +0 -1
- package/dist/esm/storage/sql/SqlFileMetadata.d.ts +0 -18
- package/dist/esm/storage/sql/SqlFileMetadata.js +0 -69
- package/dist/esm/storage/sql/SqlFileMetadata.js.map +0 -1
- package/dist/esm/storage/sql/SqlOperations.d.ts +0 -19
- package/dist/esm/storage/sql/SqlOperations.js +0 -122
- package/dist/esm/storage/sql/SqlOperations.js.map +0 -1
- package/dist/esm/storage/sql/SqlReplicas.d.ts +0 -32
- package/dist/esm/storage/sql/SqlReplicas.js +0 -163
- package/dist/esm/storage/sql/SqlReplicas.js.map +0 -1
- package/dist/esm/storage/sql/database.d.ts +0 -9
- package/dist/esm/storage/sql/database.js +0 -24
- package/dist/esm/storage/sql/database.js.map +0 -1
- package/dist/esm/storage/sql/migrations/v1.d.ts +0 -3
- package/dist/esm/storage/sql/migrations/v1.js +0 -59
- package/dist/esm/storage/sql/migrations/v1.js.map +0 -1
- package/dist/esm/storage/sql/migrations/v2.d.ts +0 -3
- package/dist/esm/storage/sql/migrations/v2.js +0 -16
- package/dist/esm/storage/sql/migrations/v2.js.map +0 -1
- package/dist/esm/storage/sql/migrations.d.ts +0 -7
- package/dist/esm/storage/sql/migrations.js +0 -4
- package/dist/esm/storage/sql/migrations.js.map +0 -1
- package/dist/esm/storage/sql/sqlStorage.d.ts +0 -6
- package/dist/esm/storage/sql/sqlStorage.js +0 -35
- package/dist/esm/storage/sql/sqlStorage.js.map +0 -1
- package/dist/esm/storage/sql/tables.d.ts +0 -44
- package/dist/esm/storage/sql/tables.js +0 -2
- package/dist/esm/storage/sql/tables.js.map +0 -1
- package/dist/esm/storage/sqlShard/transfer.d.ts +0 -7
- package/dist/esm/storage/sqlShard/transfer.js +0 -90
- package/dist/esm/storage/sqlShard/transfer.js.map +0 -1
- package/dist/esm/storage/sqlShard/transfer.test.d.ts +0 -1
- package/dist/esm/storage/sqlShard/transfer.test.js +0 -109
- package/dist/esm/storage/sqlShard/transfer.test.js.map +0 -1
- package/src/MessageSender.ts +0 -10
- package/src/Presence.ts +0 -86
- package/src/ReplicaKeepaliveTimers.ts +0 -34
- package/src/Server.ts +0 -859
- package/src/storage/sql/SqlBaselines.ts +0 -147
- package/src/storage/sql/SqlFileMetadata.ts +0 -94
- package/src/storage/sql/SqlOperations.ts +0 -160
- package/src/storage/sql/SqlReplicas.ts +0 -234
- package/src/storage/sql/database.ts +0 -32
- package/src/storage/sql/migrations/v1.ts +0 -64
- package/src/storage/sql/migrations/v2.ts +0 -20
- package/src/storage/sql/migrations.ts +0 -4
- package/src/storage/sql/sqlStorage.ts +0 -57
- package/src/storage/sql/tables.ts +0 -51
- package/src/storage/sqlShard/transfer.test.ts +0 -149
- package/src/storage/sqlShard/transfer.ts +0 -123
- /package/dist/esm/{MessageSender.js → connections/MessageSender.js} +0 -0
- /package/dist/esm/{ServerLibrary.test.d.ts → libraries/Library.test.d.ts} +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber } from '@verdant-web/common';
|
|
2
|
-
/**
|
|
3
|
-
* A set of timers per-replica which are
|
|
4
|
-
* refreshed whenever the replica sends
|
|
5
|
-
* a message to the server. If a timer expires,
|
|
6
|
-
* the replica is removed from presence. This
|
|
7
|
-
* is a failsafe for socket-based replicas but
|
|
8
|
-
* essential for pull-based replicas.
|
|
9
|
-
*/
|
|
10
|
-
export class ReplicaKeepaliveTimers extends EventSubscriber {
|
|
11
|
-
constructor(timeout = 30 * 1000) {
|
|
12
|
-
super();
|
|
13
|
-
this.timeout = timeout;
|
|
14
|
-
this.timers = new Map();
|
|
15
|
-
this.refresh = (libraryId, replicaId) => {
|
|
16
|
-
const existing = this.timers.get(replicaId);
|
|
17
|
-
if (existing) {
|
|
18
|
-
clearTimeout(existing);
|
|
19
|
-
}
|
|
20
|
-
this.timers.set(replicaId, setTimeout(() => {
|
|
21
|
-
this.emit('lost', libraryId, replicaId);
|
|
22
|
-
this.timers.delete(replicaId);
|
|
23
|
-
}, this.timeout));
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=ReplicaKeepaliveTimers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReplicaKeepaliveTimers.js","sourceRoot":"","sources":["../../src/ReplicaKeepaliveTimers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAE1C;IAGD,YAAoB,UAAU,EAAE,GAAG,IAAI;QACtC,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAY;QAF/B,WAAM,GAAG,IAAI,GAAG,EAA0B,CAAC;QAMnD,YAAO,GAAG,CAAC,SAAiB,EAAE,SAAiB,EAAE,EAAE;YAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,QAAQ,EAAE,CAAC;gBACd,YAAY,CAAC,QAAQ,CAAC,CAAC;YACxB,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,GAAG,CACd,SAAS,EACT,UAAU,CAAC,GAAG,EAAE;gBACf,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC/B,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAChB,CAAC;QACH,CAAC,CAAC;IAfF,CAAC;CAgBD"}
|
package/dist/esm/Server.d.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { DocumentBaseline, FileData, Operation, ServerMessage } from '@verdant-web/common';
|
|
2
|
-
import EventEmitter from 'events';
|
|
3
|
-
import { Server as HttpServer, IncomingMessage, ServerResponse } from 'http';
|
|
4
|
-
import internal from 'stream';
|
|
5
|
-
import { FileStorage } from './files/FileStorage.js';
|
|
6
|
-
import { MessageSender } from './MessageSender.js';
|
|
7
|
-
import { UserProfiles } from './Profiles.js';
|
|
8
|
-
import { StorageFactory } from './storage/Storage.js';
|
|
9
|
-
import { TokenInfo } from './TokenVerifier.js';
|
|
10
|
-
export interface ServerOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Attach to a pre-existing HTTP server. Provide this if you have another server,
|
|
13
|
-
* like an Express server, that you want to add lofi to. If provided, you don't
|
|
14
|
-
* need to call .listen()
|
|
15
|
-
*/
|
|
16
|
-
httpServer?: HttpServer;
|
|
17
|
-
/**
|
|
18
|
-
* The secret value used to generate tokens from your authentication endpoint.
|
|
19
|
-
* Used to verify and decode user identity and library access on connection.
|
|
20
|
-
*/
|
|
21
|
-
tokenSecret: string;
|
|
22
|
-
/**
|
|
23
|
-
* Your storage implementation. See the sqlStorage export for a built-in
|
|
24
|
-
* option.
|
|
25
|
-
*/
|
|
26
|
-
storage: StorageFactory;
|
|
27
|
-
/**
|
|
28
|
-
* Optionally provide an implementation of the UserProfiles interface to look up
|
|
29
|
-
* static user profile data to use in persistence. This data is considered trusted
|
|
30
|
-
* and can be used to identify users with information like name or profile image.
|
|
31
|
-
*/
|
|
32
|
-
profiles?: UserProfiles<any>;
|
|
33
|
-
/**
|
|
34
|
-
* How many minutes of inactivity before a replica is considered truant and
|
|
35
|
-
* removed from the library. Defaults to 30 days.
|
|
36
|
-
*/
|
|
37
|
-
replicaTruancyMinutes?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Supply a logging function to log debug messages.
|
|
40
|
-
*/
|
|
41
|
-
log?: (...args: any[]) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Disable history compaction. Storage usage will grow indefinitely. Not recommended.
|
|
44
|
-
*/
|
|
45
|
-
disableRebasing?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Provide a FileStorage backend to accept file uploads. Without a file backend,
|
|
48
|
-
* users will not be able to synchronize files, and all files added on peer replicas
|
|
49
|
-
* will be forever unavailable.
|
|
50
|
-
*
|
|
51
|
-
* A default, filesystem-backed FileStorage implementation is provided as an export
|
|
52
|
-
* of this library.
|
|
53
|
-
*/
|
|
54
|
-
fileStorage?: FileStorage;
|
|
55
|
-
fileConfig?: {
|
|
56
|
-
deleteExpirationDays?: number;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export interface ServerEvents {
|
|
60
|
-
error: (err: any) => void;
|
|
61
|
-
warning: (msg: string, ...args: any[]) => void;
|
|
62
|
-
changes: (info: Omit<TokenInfo, 'token'>, operations: Operation[], baselines: DocumentBaseline[]) => void;
|
|
63
|
-
request: (info: TokenInfo) => void;
|
|
64
|
-
'socket-close': (info: TokenInfo) => void;
|
|
65
|
-
'socket-connection': (info: TokenInfo) => void;
|
|
66
|
-
}
|
|
67
|
-
export declare interface Server {
|
|
68
|
-
on<Event extends keyof ServerEvents>(ev: Event, cb: ServerEvents[Event]): this;
|
|
69
|
-
off<Event extends keyof ServerEvents>(ev: Event, cb: ServerEvents[Event]): this;
|
|
70
|
-
emit<Event extends keyof ServerEvents>(ev: Event, ...args: Parameters<ServerEvents[Event]>): boolean;
|
|
71
|
-
}
|
|
72
|
-
export declare class Server extends EventEmitter implements MessageSender {
|
|
73
|
-
private httpServer;
|
|
74
|
-
private wss;
|
|
75
|
-
private fileStorage?;
|
|
76
|
-
private storage;
|
|
77
|
-
private library;
|
|
78
|
-
private clientConnections;
|
|
79
|
-
private keepalives;
|
|
80
|
-
private tokenVerifier;
|
|
81
|
-
private connectionToReplicaIdMap;
|
|
82
|
-
private log;
|
|
83
|
-
private __testMode;
|
|
84
|
-
constructor(options: ServerOptions);
|
|
85
|
-
/**
|
|
86
|
-
* Attaches the Verdant server to an HttpServer instance, which
|
|
87
|
-
* allows it to handle requests and websockets required for the
|
|
88
|
-
* Verdant protocol.
|
|
89
|
-
*
|
|
90
|
-
* You can pass httpPath = false if you want to handle HTTP requests
|
|
91
|
-
* yourself, and this will only attach the websocket handling.
|
|
92
|
-
*/
|
|
93
|
-
attach: (server: HttpServer, options?: {
|
|
94
|
-
httpPath?: string | false;
|
|
95
|
-
}) => void;
|
|
96
|
-
/**
|
|
97
|
-
* Handles an HTTP upgrade request to a websocket connection.
|
|
98
|
-
*/
|
|
99
|
-
handleUpgrade: (req: IncomingMessage, socket: internal.Duplex, head: Buffer) => Promise<void>;
|
|
100
|
-
private authorizeRequest;
|
|
101
|
-
private getRequestToken;
|
|
102
|
-
private createInternalRequestHandler;
|
|
103
|
-
/**
|
|
104
|
-
* Handles an HTTP request from a verdant client.
|
|
105
|
-
*/
|
|
106
|
-
handleRequest: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Handles a "fetch" style request. Complement to handleRequest, for servers
|
|
109
|
-
* that use Request/Response style handlers.
|
|
110
|
-
*/
|
|
111
|
-
handleFetch: (req: Request) => Promise<Response>;
|
|
112
|
-
private handleRequestBody;
|
|
113
|
-
private writeErrorResponse;
|
|
114
|
-
private getErrorResponse;
|
|
115
|
-
/**
|
|
116
|
-
* Handles a multipart upload of a file from a verdant client. The upload
|
|
117
|
-
* will include parameters for the file's ID, name, and type. The request
|
|
118
|
-
* must be authenticated with a token to tie it to a library.
|
|
119
|
-
*/
|
|
120
|
-
handleFileRequest: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Handles a "fetch" style file request. Complement to handleFileRequest,
|
|
123
|
-
* for servers that use Request/Response style handlers.
|
|
124
|
-
*/
|
|
125
|
-
handleFileFetch: (req: Request) => Promise<Response>;
|
|
126
|
-
private getFileStorageOrThrow;
|
|
127
|
-
private streamIncomingFile;
|
|
128
|
-
getFileData: (library: string, fileId: string) => Promise<FileData>;
|
|
129
|
-
broadcast: (libraryId: string, message: ServerMessage, omitKeys?: string[]) => void;
|
|
130
|
-
send: (libraryId: string, key: string, message: ServerMessage) => void;
|
|
131
|
-
private handleMessage;
|
|
132
|
-
private handleConnection;
|
|
133
|
-
listen: (handle: any, listeningListener?: (() => void) | undefined) => void;
|
|
134
|
-
close: () => Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
* Completely remove a library from the server.
|
|
137
|
-
* This will remove all data associated with the library.
|
|
138
|
-
* Use it very carefully! Data will still be stored on user
|
|
139
|
-
* devices, so this is not as scary as it sounds - the next time
|
|
140
|
-
* any replica connects, it will repopulate the library. But
|
|
141
|
-
* you should still be careful.
|
|
142
|
-
*/
|
|
143
|
-
evictLibrary: (libraryId: string) => Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Returns currently connected replica info for a library
|
|
146
|
-
*/
|
|
147
|
-
getLibraryPresence: (libraryId: string) => Record<string, import("@verdant-web/common").UserInfo<any, any>>;
|
|
148
|
-
/**
|
|
149
|
-
* Returns helpful information about a library.
|
|
150
|
-
* This is currently only the known replicas and some
|
|
151
|
-
* more low-level metadata.
|
|
152
|
-
*/
|
|
153
|
-
getLibraryInfo: (libraryId: string) => Promise<import("./types.js").LibraryInfo | null>;
|
|
154
|
-
/**
|
|
155
|
-
* Removes all replicas associated with a User ID from
|
|
156
|
-
* the server. Consistency algorithms will no longer wait on these
|
|
157
|
-
* replicas before confirming and squashing changes.
|
|
158
|
-
*/
|
|
159
|
-
evictUser: (libraryId: string, userId: string) => void;
|
|
160
|
-
/**
|
|
161
|
-
* Retrieves a snapshot of the full document contents at this time.
|
|
162
|
-
* Useful for capturing the shape of data for static usage outside
|
|
163
|
-
* of the live system.
|
|
164
|
-
*/
|
|
165
|
-
getDocumentSnapshot: (libraryId: string, collection: string, documentId: string) => Promise<any>;
|
|
166
|
-
}
|