@types/sharedb 1.0.19 → 1.0.23

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 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: Tue, 27 Jul 2021 15:01:19 GMT
11
+ * Last updated: Fri, 12 Nov 2021 19:31:24 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,
@@ -254,13 +258,13 @@ declare namespace sharedb {
254
258
  interface QueryContext extends BaseContext {
255
259
  index: string;
256
260
  collection: string;
257
- projection: Projection;
261
+ projection: ReadonlyProjection;
258
262
  fields: ProjectionFields;
259
263
  channel: string;
260
264
  query: any;
261
265
  options?: {[key: string]: any};
262
266
  db: DB | null;
263
- snapshotProjection: Projection | null;
267
+ snapshotProjection: ReadonlyProjection | null;
264
268
  }
265
269
 
266
270
  interface ReadSnapshotsContext extends BaseContext {
@@ -285,9 +289,9 @@ declare namespace sharedb {
285
289
  }
286
290
  }
287
291
 
288
- interface Projection {
289
- target: string;
290
- fields: ProjectionFields;
292
+ interface ReadonlyProjection {
293
+ readonly target: Readonly<string>;
294
+ readonly fields: Readonly<ProjectionFields>;
291
295
  }
292
296
 
293
297
  interface ProjectionFields {
@@ -296,7 +300,7 @@ interface ProjectionFields {
296
300
 
297
301
  interface SubmitRequest {
298
302
  index: string;
299
- projection: Projection;
303
+ projection: ReadonlyProjection;
300
304
  collection: string;
301
305
  id: string;
302
306
  op: sharedb.CreateOp | sharedb.DeleteOp | sharedb.EditOp;
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: any;
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/lib/sharedb.d.ts CHANGED
@@ -143,9 +143,9 @@ export interface DocEventMap<T> {
143
143
  'no write pending': () => void;
144
144
  'nothing pending': () => void;
145
145
  'create': (source: any) => void;
146
- 'op': (ops: [any], source: any) => void;
146
+ 'op': (ops: [any], source: any, clientId: string) => void;
147
147
  'op batch': (ops: any[], source: any) => void;
148
- 'before op': (ops: [any], source: any) => void;
148
+ 'before op': (ops: [any], source: any, clientId: string) => void;
149
149
  'before op batch': (ops: any[], source: any) => void;
150
150
  'del': (data: T, source: any) => void;
151
151
  'error': (error: Error) => void;
sharedb/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/sharedb",
3
- "version": "1.0.19",
3
+ "version": "1.0.23",
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": "8f7fef5811510ee44814f58ddb800aad47997a4a88ab9c0fa8c41da573ff5a3c",
44
- "typeScriptVersion": "3.6"
43
+ "typesPublisherContentHash": "0fede5791642ef4d06d6a137afd9968129407dfe2827787900440ef8cb6555a8",
44
+ "typeScriptVersion": "3.7"
45
45
  }