@inditextech/weave-store-azure-web-pubsub 0.67.4 → 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
@@ -22944,18 +22944,26 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22944
22944
  super(hub, {
22945
22945
  ...eventHandlerOptions,
22946
22946
  handleConnect: (req, res) => {
22947
- this.actualServer.emitEvent("onConnect", {
22947
+ console.log("reached handleConnect", {
22948
22948
  context: req.context,
22949
22949
  queries: req.queries
22950
22950
  });
22951
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
+ });
22952
22957
  },
22953
22958
  onConnected: (req) => {
22959
+ console.log("reached onConnected", { context: req.context });
22960
+ this.syncOptions?.onConnected?.(req.context.connectionId);
22954
22961
  this.actualServer.emitEvent("onConnected", { context: req.context });
22955
22962
  },
22956
22963
  onDisconnected: (req) => {
22957
- this.actualServer.emitEvent("onDisconnected", { context: req.context });
22964
+ console.log("reached onDisconnected", { context: req.context });
22958
22965
  this.handleConnectionDisconnection(req.context.connectionId);
22966
+ this.actualServer.emitEvent("onDisconnected", { context: req.context });
22959
22967
  }
22960
22968
  });
22961
22969
  this.syncOptions = syncHandlerOptions;
@@ -22998,6 +23006,7 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22998
23006
  }
22999
23007
  async handleConnectionDisconnection(connectionId) {
23000
23008
  const connectionRoom = await this.syncOptions?.getConnectionRoom?.(connectionId);
23009
+ if (connectionRoom) await this.syncOptions?.removeConnection?.(connectionId);
23001
23010
  const roomConnections = connectionRoom ? await this.syncOptions?.getRoomConnections?.(connectionRoom) : [];
23002
23011
  if (connectionRoom && roomConnections?.length === 0) await this.destroyRoomInstance(connectionRoom);
23003
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;
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;
package/dist/server.js CHANGED
@@ -22948,18 +22948,26 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
22948
22948
  super(hub, {
22949
22949
  ...eventHandlerOptions,
22950
22950
  handleConnect: (req, res) => {
22951
- this.actualServer.emitEvent("onConnect", {
22951
+ console.log("reached handleConnect", {
22952
22952
  context: req.context,
22953
22953
  queries: req.queries
22954
22954
  });
22955
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
+ });
22956
22961
  },
22957
22962
  onConnected: (req) => {
22963
+ console.log("reached onConnected", { context: req.context });
22964
+ this.syncOptions?.onConnected?.(req.context.connectionId);
22958
22965
  this.actualServer.emitEvent("onConnected", { context: req.context });
22959
22966
  },
22960
22967
  onDisconnected: (req) => {
22961
- this.actualServer.emitEvent("onDisconnected", { context: req.context });
22968
+ console.log("reached onDisconnected", { context: req.context });
22962
22969
  this.handleConnectionDisconnection(req.context.connectionId);
22970
+ this.actualServer.emitEvent("onDisconnected", { context: req.context });
22963
22971
  }
22964
22972
  });
22965
22973
  this.syncOptions = syncHandlerOptions;
@@ -23002,6 +23010,7 @@ var WeaveAzureWebPubsubSyncHandler = class extends WebPubSubEventHandler {
23002
23010
  }
23003
23011
  async handleConnectionDisconnection(connectionId) {
23004
23012
  const connectionRoom = await this.syncOptions?.getConnectionRoom?.(connectionId);
23013
+ if (connectionRoom) await this.syncOptions?.removeConnection?.(connectionId);
23005
23014
  const roomConnections = connectionRoom ? await this.syncOptions?.getRoomConnections?.(connectionRoom) : [];
23006
23015
  if (connectionRoom && roomConnections?.length === 0) await this.destroyRoomInstance(connectionRoom);
23007
23016
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-store-azure-web-pubsub",
3
- "version": "0.67.4",
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.4",
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",