@inditextech/weave-store-azure-web-pubsub 0.67.3 → 0.67.5

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/dist/client.d.cts CHANGED
@@ -110,10 +110,13 @@ type WeaveStoreAzureWebPubsubConfig = {
110
110
  key?: string;
111
111
  custom?: TokenCredential;
112
112
  };
113
- connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "getConnectionRoom" | "getRoomConnections">;
113
+ connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "onConnect" | "onConnected" | "removeConnection" | "getConnectionRoom" | "getRoomConnections">;
114
114
  persistIntervalMs?: number;
115
115
  };
116
116
  type WeaveAzureWebPubsubSyncHandlerOptions = {
117
+ onConnect?: (connectionId: string, queries: Record<string, string[]> | undefined) => Promise<void>;
118
+ onConnected?: (connectionId: string) => Promise<void>;
119
+ removeConnection?: (connectionId: string) => Promise<void>;
117
120
  getConnectionRoom?: (connectionId: string) => Promise<string | null>;
118
121
  getRoomConnections?: (roomId: string) => Promise<string[]>;
119
122
  persistIntervalMs?: number;
package/dist/client.d.ts CHANGED
@@ -110,10 +110,13 @@ type WeaveStoreAzureWebPubsubConfig = {
110
110
  key?: string;
111
111
  custom?: TokenCredential;
112
112
  };
113
- connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "getConnectionRoom" | "getRoomConnections">;
113
+ connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "onConnect" | "onConnected" | "removeConnection" | "getConnectionRoom" | "getRoomConnections">;
114
114
  persistIntervalMs?: number;
115
115
  };
116
116
  type WeaveAzureWebPubsubSyncHandlerOptions = {
117
+ onConnect?: (connectionId: string, queries: Record<string, string[]> | undefined) => Promise<void>;
118
+ onConnected?: (connectionId: string) => Promise<void>;
119
+ removeConnection?: (connectionId: string) => Promise<void>;
117
120
  getConnectionRoom?: (connectionId: string) => Promise<string | null>;
118
121
  getRoomConnections?: (roomId: string) => Promise<string[]>;
119
122
  persistIntervalMs?: number;
package/dist/server.cjs CHANGED
@@ -22940,23 +22940,30 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22940
22940
  _rooms = new Map();
22941
22941
  _roomsSyncHost = new Map();
22942
22942
  _store_persistence = new Map();
22943
- eventsHub = new Emittery();
22944
22943
  constructor(hub, server, client, initialState, syncHandlerOptions, eventHandlerOptions) {
22945
22944
  super(hub, {
22946
22945
  ...eventHandlerOptions,
22947
22946
  handleConnect: (req, res) => {
22948
- this.eventsHub.emit("onConnect", {
22947
+ console.log("reached handleConnect", {
22949
22948
  context: req.context,
22950
22949
  queries: req.queries
22951
22950
  });
22952
22951
  res.success();
22952
+ this.syncOptions?.onConnect?.(req.context.connectionId, req.queries);
22953
+ this.actualServer.emitEvent("onConnect", {
22954
+ context: req.context,
22955
+ queries: req.queries
22956
+ });
22953
22957
  },
22954
22958
  onConnected: (req) => {
22955
- this.eventsHub.emit("onConnected", { context: req.context });
22959
+ console.log("reached onConnected", { context: req.context });
22960
+ this.syncOptions?.onConnected?.(req.context.connectionId);
22961
+ this.actualServer.emitEvent("onConnected", { context: req.context });
22956
22962
  },
22957
22963
  onDisconnected: (req) => {
22958
- this.eventsHub.emit("onDisconnected", { context: req.context });
22964
+ console.log("reached onDisconnected", { context: req.context });
22959
22965
  this.handleConnectionDisconnection(req.context.connectionId);
22966
+ this.actualServer.emitEvent("onDisconnected", { context: req.context });
22960
22967
  }
22961
22968
  });
22962
22969
  this.syncOptions = syncHandlerOptions;
@@ -22964,12 +22971,6 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22964
22971
  this.initialState = initialState;
22965
22972
  this._client = client;
22966
22973
  }
22967
- addEventListener(event, callback) {
22968
- this.eventsHub.on(event, callback);
22969
- }
22970
- removeEventListener(event, callback) {
22971
- this.eventsHub.off(event, callback);
22972
- }
22973
22974
  getNewYDoc() {
22974
22975
  return new yjs.Doc();
22975
22976
  }
@@ -23005,6 +23006,7 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
23005
23006
  }
23006
23007
  async handleConnectionDisconnection(connectionId) {
23007
23008
  const connectionRoom = await this.syncOptions?.getConnectionRoom?.(connectionId);
23009
+ if (connectionRoom) await this.syncOptions?.removeConnection?.(connectionId);
23008
23010
  const roomConnections = connectionRoom ? await this.syncOptions?.getRoomConnections?.(connectionRoom) : [];
23009
23011
  if (connectionRoom && roomConnections?.length === 0) await this.destroyRoomInstance(connectionRoom);
23010
23012
  }
package/dist/server.d.cts CHANGED
@@ -16,10 +16,13 @@ type WeaveStoreAzureWebPubsubConfig = {
16
16
  key?: string;
17
17
  custom?: TokenCredential;
18
18
  };
19
- connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "getConnectionRoom" | "getRoomConnections">;
19
+ connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "onConnect" | "onConnected" | "removeConnection" | "getConnectionRoom" | "getRoomConnections">;
20
20
  persistIntervalMs?: number;
21
21
  };
22
22
  type WeaveAzureWebPubsubSyncHandlerOptions = {
23
+ onConnect?: (connectionId: string, queries: Record<string, string[]> | undefined) => Promise<void>;
24
+ onConnected?: (connectionId: string) => Promise<void>;
25
+ removeConnection?: (connectionId: string) => Promise<void>;
23
26
  getConnectionRoom?: (connectionId: string) => Promise<string | null>;
24
27
  getRoomConnections?: (roomId: string) => Promise<string[]>;
25
28
  persistIntervalMs?: number;
@@ -848,10 +851,7 @@ declare class WeaveAzureWebPubsubSyncHandler extends WebPubSubEventHandler {
848
851
  private readonly syncOptions?;
849
852
  private initialState;
850
853
  private actualServer;
851
- private readonly eventsHub;
852
854
  constructor(hub: string, server: WeaveAzureWebPubsubServer, client: WebPubSubServiceClient, initialState: FetchInitialState, syncHandlerOptions?: WeaveAzureWebPubsubSyncHandlerOptions, eventHandlerOptions?: WebPubSubEventHandlerOptions);
853
- addEventListener(event: keyof WeaveStoreAzureWebPubsubEvents, callback: (payload: WeaveStoreAzureWebPubsubEvents[typeof event]) => void): void;
854
- removeEventListener(event: keyof WeaveStoreAzureWebPubsubEvents, callback: (payload: WeaveStoreAzureWebPubsubEvents[typeof event]) => void): void;
855
855
  private getNewYDoc;
856
856
  private setupRoomInstance;
857
857
  private persistRoomTask;
package/dist/server.d.ts CHANGED
@@ -16,10 +16,13 @@ type WeaveStoreAzureWebPubsubConfig = {
16
16
  key?: string;
17
17
  custom?: TokenCredential;
18
18
  };
19
- connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "getConnectionRoom" | "getRoomConnections">;
19
+ connectionHandlers?: Pick<WeaveAzureWebPubsubSyncHandlerOptions, "onConnect" | "onConnected" | "removeConnection" | "getConnectionRoom" | "getRoomConnections">;
20
20
  persistIntervalMs?: number;
21
21
  };
22
22
  type WeaveAzureWebPubsubSyncHandlerOptions = {
23
+ onConnect?: (connectionId: string, queries: Record<string, string[]> | undefined) => Promise<void>;
24
+ onConnected?: (connectionId: string) => Promise<void>;
25
+ removeConnection?: (connectionId: string) => Promise<void>;
23
26
  getConnectionRoom?: (connectionId: string) => Promise<string | null>;
24
27
  getRoomConnections?: (roomId: string) => Promise<string[]>;
25
28
  persistIntervalMs?: number;
@@ -848,10 +851,7 @@ declare class WeaveAzureWebPubsubSyncHandler extends WebPubSubEventHandler {
848
851
  private readonly syncOptions?;
849
852
  private initialState;
850
853
  private actualServer;
851
- private readonly eventsHub;
852
854
  constructor(hub: string, server: WeaveAzureWebPubsubServer, client: WebPubSubServiceClient, initialState: FetchInitialState, syncHandlerOptions?: WeaveAzureWebPubsubSyncHandlerOptions, eventHandlerOptions?: WebPubSubEventHandlerOptions);
853
- addEventListener(event: keyof WeaveStoreAzureWebPubsubEvents, callback: (payload: WeaveStoreAzureWebPubsubEvents[typeof event]) => void): void;
854
- removeEventListener(event: keyof WeaveStoreAzureWebPubsubEvents, callback: (payload: WeaveStoreAzureWebPubsubEvents[typeof event]) => void): void;
855
855
  private getNewYDoc;
856
856
  private setupRoomInstance;
857
857
  private persistRoomTask;
package/dist/server.js CHANGED
@@ -22944,23 +22944,30 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22944
22944
  _rooms = new Map();
22945
22945
  _roomsSyncHost = new Map();
22946
22946
  _store_persistence = new Map();
22947
- eventsHub = new Emittery();
22948
22947
  constructor(hub, server, client, initialState, syncHandlerOptions, eventHandlerOptions) {
22949
22948
  super(hub, {
22950
22949
  ...eventHandlerOptions,
22951
22950
  handleConnect: (req, res) => {
22952
- this.eventsHub.emit("onConnect", {
22951
+ console.log("reached handleConnect", {
22953
22952
  context: req.context,
22954
22953
  queries: req.queries
22955
22954
  });
22956
22955
  res.success();
22956
+ this.syncOptions?.onConnect?.(req.context.connectionId, req.queries);
22957
+ this.actualServer.emitEvent("onConnect", {
22958
+ context: req.context,
22959
+ queries: req.queries
22960
+ });
22957
22961
  },
22958
22962
  onConnected: (req) => {
22959
- this.eventsHub.emit("onConnected", { context: req.context });
22963
+ console.log("reached onConnected", { context: req.context });
22964
+ this.syncOptions?.onConnected?.(req.context.connectionId);
22965
+ this.actualServer.emitEvent("onConnected", { context: req.context });
22960
22966
  },
22961
22967
  onDisconnected: (req) => {
22962
- this.eventsHub.emit("onDisconnected", { context: req.context });
22968
+ console.log("reached onDisconnected", { context: req.context });
22963
22969
  this.handleConnectionDisconnection(req.context.connectionId);
22970
+ this.actualServer.emitEvent("onDisconnected", { context: req.context });
22964
22971
  }
22965
22972
  });
22966
22973
  this.syncOptions = syncHandlerOptions;
@@ -22968,12 +22975,6 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22968
22975
  this.initialState = initialState;
22969
22976
  this._client = client;
22970
22977
  }
22971
- addEventListener(event, callback) {
22972
- this.eventsHub.on(event, callback);
22973
- }
22974
- removeEventListener(event, callback) {
22975
- this.eventsHub.off(event, callback);
22976
- }
22977
22978
  getNewYDoc() {
22978
22979
  return new Y$1.Doc();
22979
22980
  }
@@ -23009,6 +23010,7 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
23009
23010
  }
23010
23011
  async handleConnectionDisconnection(connectionId) {
23011
23012
  const connectionRoom = await this.syncOptions?.getConnectionRoom?.(connectionId);
23013
+ if (connectionRoom) await this.syncOptions?.removeConnection?.(connectionId);
23012
23014
  const roomConnections = connectionRoom ? await this.syncOptions?.getRoomConnections?.(connectionRoom) : [];
23013
23015
  if (connectionRoom && roomConnections?.length === 0) await this.destroyRoomInstance(connectionRoom);
23014
23016
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-store-azure-web-pubsub",
3
- "version": "0.67.3",
3
+ "version": "0.67.5",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -61,7 +61,7 @@
61
61
  "yjs": "13.6.27"
62
62
  },
63
63
  "devDependencies": {
64
- "@inditextech/weave-sdk": "0.67.3",
64
+ "@inditextech/weave-sdk": "0.67.5",
65
65
  "@koa/cors": "^5.0.0",
66
66
  "@types/express": "^5.0.1",
67
67
  "@types/ioredis": "^4.28.10",