@types/sharedb 1.0.20 → 1.0.24
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 +29 -6
- sharedb/lib/agent.d.ts +2 -2
- sharedb/lib/client.d.ts +36 -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: Fri,
|
|
11
|
+
* Last updated: Fri, 19 Nov 2021 17:31:08 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: none
|
|
14
14
|
|
sharedb/index.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ declare class sharedb extends EventEmitter {
|
|
|
31
31
|
extraDbs: {[extraDbName: string]: sharedb.ExtraDB};
|
|
32
32
|
milestoneDb?: sharedb.MilestoneDB;
|
|
33
33
|
|
|
34
|
+
readonly projections: {
|
|
35
|
+
readonly [name: string]: ReadonlyProjection;
|
|
36
|
+
};
|
|
37
|
+
|
|
34
38
|
constructor(options?: {
|
|
35
39
|
db?: any,
|
|
36
40
|
pubsub?: sharedb.PubSub,
|
|
@@ -219,6 +223,7 @@ declare namespace sharedb {
|
|
|
219
223
|
readSnapshots: ReadSnapshotsContext;
|
|
220
224
|
receive: ReceiveContext;
|
|
221
225
|
reply: ReplyContext;
|
|
226
|
+
sendPresence: PresenceContext;
|
|
222
227
|
submit: SubmitContext;
|
|
223
228
|
}
|
|
224
229
|
|
|
@@ -251,16 +256,21 @@ declare namespace sharedb {
|
|
|
251
256
|
op: any;
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
interface PresenceContext extends BaseContext {
|
|
260
|
+
presence: PresenceMessage;
|
|
261
|
+
collection?: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
254
264
|
interface QueryContext extends BaseContext {
|
|
255
265
|
index: string;
|
|
256
266
|
collection: string;
|
|
257
|
-
projection:
|
|
267
|
+
projection: ReadonlyProjection;
|
|
258
268
|
fields: ProjectionFields;
|
|
259
269
|
channel: string;
|
|
260
270
|
query: any;
|
|
261
271
|
options?: {[key: string]: any};
|
|
262
272
|
db: DB | null;
|
|
263
|
-
snapshotProjection:
|
|
273
|
+
snapshotProjection: ReadonlyProjection | null;
|
|
264
274
|
}
|
|
265
275
|
|
|
266
276
|
interface ReadSnapshotsContext extends BaseContext {
|
|
@@ -285,9 +295,9 @@ declare namespace sharedb {
|
|
|
285
295
|
}
|
|
286
296
|
}
|
|
287
297
|
|
|
288
|
-
interface
|
|
289
|
-
target: string
|
|
290
|
-
fields: ProjectionFields
|
|
298
|
+
interface ReadonlyProjection {
|
|
299
|
+
readonly target: Readonly<string>;
|
|
300
|
+
readonly fields: Readonly<ProjectionFields>;
|
|
291
301
|
}
|
|
292
302
|
|
|
293
303
|
interface ProjectionFields {
|
|
@@ -296,7 +306,7 @@ interface ProjectionFields {
|
|
|
296
306
|
|
|
297
307
|
interface SubmitRequest {
|
|
298
308
|
index: string;
|
|
299
|
-
projection:
|
|
309
|
+
projection: ReadonlyProjection;
|
|
300
310
|
collection: string;
|
|
301
311
|
id: string;
|
|
302
312
|
op: sharedb.CreateOp | sharedb.DeleteOp | sharedb.EditOp;
|
|
@@ -322,4 +332,17 @@ interface GetOpsOptions {
|
|
|
322
332
|
};
|
|
323
333
|
}
|
|
324
334
|
|
|
335
|
+
interface PresenceMessage {
|
|
336
|
+
a: 'p';
|
|
337
|
+
ch: string; // channel
|
|
338
|
+
src: string; // client ID
|
|
339
|
+
id: string; // presence ID
|
|
340
|
+
p: any; // presence payload
|
|
341
|
+
pv: number; // presence version
|
|
342
|
+
c?: string; // document collection
|
|
343
|
+
d?: string; // document ID
|
|
344
|
+
v?: number; // document version
|
|
345
|
+
t?: string; // document OT type
|
|
346
|
+
}
|
|
347
|
+
|
|
325
348
|
type BasicCallback = (err?: Error) => void;
|
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
|
@@ -9,6 +9,18 @@ export class Connection {
|
|
|
9
9
|
// ShareDB, but it is handy for server-side only user code that may cache
|
|
10
10
|
// state on the agent and read it in middleware
|
|
11
11
|
agent: Agent | null;
|
|
12
|
+
|
|
13
|
+
collections: Record<string, Record<string, Doc>>;
|
|
14
|
+
queries: Record<string, Query>;
|
|
15
|
+
|
|
16
|
+
seq: number;
|
|
17
|
+
id: string | null; // Equals agent.src on the server
|
|
18
|
+
nextQueryId: number;
|
|
19
|
+
nextSnapshotRequestId: number;
|
|
20
|
+
|
|
21
|
+
state: string;
|
|
22
|
+
debug: boolean;
|
|
23
|
+
|
|
12
24
|
close(): void;
|
|
13
25
|
get(collectionName: string, documentID: string): Doc;
|
|
14
26
|
createFetchQuery<T = any>(collectionName: string, query: any, options?: {results?: Array<Doc<T>>} | null, callback?: (err: Error, results: Array<Doc<T>>) => void): Query<T>;
|
|
@@ -17,6 +29,30 @@ export class Connection {
|
|
|
17
29
|
fetchSnapshotByTimestamp(collection: string, id: string, timestamp: number, callback: (error: Error, snapshot: ShareDB.Snapshot) => void): void;
|
|
18
30
|
getPresence(channel: string): Presence;
|
|
19
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;
|
|
20
56
|
}
|
|
21
57
|
export type Doc<T = any> = ShareDB.Doc<T>;
|
|
22
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": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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": "31089b496f83294c189f25c4fe77b81644e41e69c380c9aa1b79cbbb645866c7",
|
|
44
|
+
"typeScriptVersion": "3.8"
|
|
45
45
|
}
|