@types/sharedb 1.0.21 → 2.2.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.
- sharedb/README.md +1 -1
- sharedb/index.d.ts +39 -7
- sharedb/lib/agent.d.ts +2 -2
- sharedb/lib/client.d.ts +24 -0
- sharedb/package.json +3 -3
sharedb/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for sharedb (https://github.com/share/sha
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sharedb.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Wed, 01 Dec 2021 08:01:02 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: none
|
|
14
14
|
|
sharedb/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for sharedb
|
|
1
|
+
// Type definitions for sharedb 2.2
|
|
2
2
|
// Project: https://github.com/share/sharedb
|
|
3
3
|
// Definitions by: Steve Oney <https://github.com/soney>
|
|
4
4
|
// Eric Hwang <https://github.com/ericyhwang>
|
|
@@ -30,6 +30,11 @@ declare class sharedb extends EventEmitter {
|
|
|
30
30
|
pubsub: sharedb.PubSub;
|
|
31
31
|
extraDbs: {[extraDbName: string]: sharedb.ExtraDB};
|
|
32
32
|
milestoneDb?: sharedb.MilestoneDB;
|
|
33
|
+
errorHandler: ErrorHandler;
|
|
34
|
+
|
|
35
|
+
readonly projections: {
|
|
36
|
+
readonly [name: string]: ReadonlyProjection;
|
|
37
|
+
};
|
|
33
38
|
|
|
34
39
|
constructor(options?: {
|
|
35
40
|
db?: any,
|
|
@@ -38,6 +43,8 @@ declare class sharedb extends EventEmitter {
|
|
|
38
43
|
milestoneDb?: sharedb.MilestoneDB,
|
|
39
44
|
suppressPublish?: boolean,
|
|
40
45
|
maxSubmitRetries?: number,
|
|
46
|
+
doNotForwardSendPresenceErrorsToClient?: boolean,
|
|
47
|
+
errorHandler?: ErrorHandler;
|
|
41
48
|
|
|
42
49
|
presence?: boolean,
|
|
43
50
|
/**
|
|
@@ -218,7 +225,9 @@ declare namespace sharedb {
|
|
|
218
225
|
query: QueryContext;
|
|
219
226
|
readSnapshots: ReadSnapshotsContext;
|
|
220
227
|
receive: ReceiveContext;
|
|
228
|
+
receivePresence: PresenceContext;
|
|
221
229
|
reply: ReplyContext;
|
|
230
|
+
sendPresence: PresenceContext;
|
|
222
231
|
submit: SubmitContext;
|
|
223
232
|
}
|
|
224
233
|
|
|
@@ -251,16 +260,21 @@ declare namespace sharedb {
|
|
|
251
260
|
op: any;
|
|
252
261
|
}
|
|
253
262
|
|
|
263
|
+
interface PresenceContext extends BaseContext {
|
|
264
|
+
presence: PresenceMessage;
|
|
265
|
+
collection?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
254
268
|
interface QueryContext extends BaseContext {
|
|
255
269
|
index: string;
|
|
256
270
|
collection: string;
|
|
257
|
-
projection:
|
|
271
|
+
projection: ReadonlyProjection;
|
|
258
272
|
fields: ProjectionFields;
|
|
259
273
|
channel: string;
|
|
260
274
|
query: any;
|
|
261
275
|
options?: {[key: string]: any};
|
|
262
276
|
db: DB | null;
|
|
263
|
-
snapshotProjection:
|
|
277
|
+
snapshotProjection: ReadonlyProjection | null;
|
|
264
278
|
}
|
|
265
279
|
|
|
266
280
|
interface ReadSnapshotsContext extends BaseContext {
|
|
@@ -285,9 +299,9 @@ declare namespace sharedb {
|
|
|
285
299
|
}
|
|
286
300
|
}
|
|
287
301
|
|
|
288
|
-
interface
|
|
289
|
-
target: string
|
|
290
|
-
fields: ProjectionFields
|
|
302
|
+
interface ReadonlyProjection {
|
|
303
|
+
readonly target: Readonly<string>;
|
|
304
|
+
readonly fields: Readonly<ProjectionFields>;
|
|
291
305
|
}
|
|
292
306
|
|
|
293
307
|
interface ProjectionFields {
|
|
@@ -296,7 +310,7 @@ interface ProjectionFields {
|
|
|
296
310
|
|
|
297
311
|
interface SubmitRequest {
|
|
298
312
|
index: string;
|
|
299
|
-
projection:
|
|
313
|
+
projection: ReadonlyProjection;
|
|
300
314
|
collection: string;
|
|
301
315
|
id: string;
|
|
302
316
|
op: sharedb.CreateOp | sharedb.DeleteOp | sharedb.EditOp;
|
|
@@ -322,4 +336,22 @@ interface GetOpsOptions {
|
|
|
322
336
|
};
|
|
323
337
|
}
|
|
324
338
|
|
|
339
|
+
interface PresenceMessage {
|
|
340
|
+
a: 'p';
|
|
341
|
+
ch: string; // channel
|
|
342
|
+
src: string; // client ID
|
|
343
|
+
id: string; // presence ID
|
|
344
|
+
p: any; // presence payload
|
|
345
|
+
pv: number; // presence version
|
|
346
|
+
c?: string; // document collection
|
|
347
|
+
d?: string; // document ID
|
|
348
|
+
v?: number; // document version
|
|
349
|
+
t?: string; // document OT type
|
|
350
|
+
}
|
|
351
|
+
|
|
325
352
|
type BasicCallback = (err?: Error) => void;
|
|
353
|
+
|
|
354
|
+
type ErrorHandler = (error: Error, context: ErrorHandlerContext) => void;
|
|
355
|
+
interface ErrorHandlerContext {
|
|
356
|
+
agent?: Agent;
|
|
357
|
+
}
|
sharedb/lib/agent.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export = Agent;
|
|
|
16
16
|
*
|
|
17
17
|
* @see https://github.com/share/sharedb#class-sharedbagent
|
|
18
18
|
*/
|
|
19
|
-
declare class Agent {
|
|
19
|
+
declare class Agent<TCustom = any> {
|
|
20
20
|
backend: ShareDbBackend;
|
|
21
21
|
stream: Duplex & {
|
|
22
22
|
/**
|
|
@@ -30,7 +30,7 @@ declare class Agent {
|
|
|
30
30
|
* given client session. It is in memory only as long as the session is
|
|
31
31
|
* active, and it is passed to each middleware call.
|
|
32
32
|
*/
|
|
33
|
-
custom:
|
|
33
|
+
custom: TCustom;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Sends a JSON-compatible message to the client for this agent.
|
sharedb/lib/client.d.ts
CHANGED
|
@@ -29,6 +29,30 @@ export class Connection {
|
|
|
29
29
|
fetchSnapshotByTimestamp(collection: string, id: string, timestamp: number, callback: (error: Error, snapshot: ShareDB.Snapshot) => void): void;
|
|
30
30
|
getPresence(channel: string): Presence;
|
|
31
31
|
getDocPresence(collection: string, id: string): Presence;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns whether anything in this client is either:
|
|
35
|
+
* - In-flight, waiting on a response from the server
|
|
36
|
+
* - Pending (locally queued)
|
|
37
|
+
*/
|
|
38
|
+
hasPending(): boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Invokes the callback once nothing on this client is in-flight or pending.
|
|
42
|
+
*
|
|
43
|
+
* @see hasPending
|
|
44
|
+
*/
|
|
45
|
+
whenNothingPending(callback: () => void): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Manually send a JSON-serializable message to the server.
|
|
49
|
+
*
|
|
50
|
+
* WARNING - This is mostly for internal use within sharedb.
|
|
51
|
+
*
|
|
52
|
+
* Prefer to use methods like `Doc#submitOp`, `Doc#subscribe`, `Connection#createFetchQuery`,
|
|
53
|
+
* etc., which will manage the necessary message exchanges.
|
|
54
|
+
*/
|
|
55
|
+
send(message: Record<string, unknown>): void;
|
|
32
56
|
}
|
|
33
57
|
export type Doc<T = any> = ShareDB.Doc<T>;
|
|
34
58
|
export type Snapshot<T = any> = ShareDB.Snapshot<T>;
|
sharedb/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/sharedb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "TypeScript definitions for sharedb",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sharedb",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {},
|
|
42
42
|
"dependencies": {},
|
|
43
|
-
"typesPublisherContentHash": "
|
|
44
|
-
"typeScriptVersion": "3.
|
|
43
|
+
"typesPublisherContentHash": "dad7e36fc031d7a9c0b324db1a345d7056c756cc410f1e22257f26b18d53aa63",
|
|
44
|
+
"typeScriptVersion": "3.8"
|
|
45
45
|
}
|