From 8123af1beea51cb84d200c31bb84c0433bbf40d8 Mon Sep 17 00:00:00 2001 From: Eve Shum Date: Thu, 30 Jan 2020 13:06:41 -0800 Subject: [PATCH] types/Sharedb - add an optional agent parameter to the client connection (#41955) * add an optional agent to the client sharedb connection * remove myself as a contributor, set agent to be agent or null * add docs --- types/sharedb/lib/client.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/sharedb/lib/client.d.ts b/types/sharedb/lib/client.d.ts index f3275b8a19..a406a1fa2c 100644 --- a/types/sharedb/lib/client.d.ts +++ b/types/sharedb/lib/client.d.ts @@ -1,9 +1,15 @@ /// import * as WS from 'ws'; import * as ShareDB from './sharedb'; +import Agent = require('./agent'); export class Connection { constructor(ws: WebSocket | WS); + + // This direct reference from connection to agent is not used internal to + // ShareDB, but it is handy for server-side only user code that may cache + // state on the agent and read it in middleware + agent: Agent | null; get(collectionName: string, documentID: string): Doc; createFetchQuery(collectionName: string, query: any, options: {results?: Query[]}, callback: (err: Error, results: any[]) => void): Query; createSubscribeQuery(collectionName: string, query: any, options: {results?: Query[]}, callback: (err: Error, results: any[]) => void): Query;