@api.global/typedsocket 3.0.0 → 3.1.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export declare const commitinfo: {
5
5
  name: string;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@api.global/typedsocket',
6
- version: '3.0.0',
7
- description: 'a typedrequest extension supporting websockets'
6
+ version: '3.1.1',
7
+ description: 'A library for creating typed WebSocket connections, supporting bi-directional communication with type safety.'
8
8
  };
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLGdEQUFnRDtDQUM5RCxDQUFBIn0=
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLCtHQUErRztDQUM3SCxDQUFBIn0=
@@ -1,5 +1,16 @@
1
1
  import * as plugins from './typedsocket.plugins.js';
2
2
  export type TTypedSocketSide = 'server' | 'client';
3
+ /**
4
+ * Wrapper for SmartServe's IWebSocketPeer to provide tag compatibility
5
+ * SmartServe uses Set<string> for tags, while TypedSocket uses {id, payload} format
6
+ */
7
+ export interface ISmartServeConnectionWrapper {
8
+ peer: plugins.IWebSocketPeer;
9
+ getTagById(tagId: string): Promise<{
10
+ id: string;
11
+ payload: any;
12
+ } | undefined>;
13
+ }
3
14
  export declare class TypedSocket {
4
15
  /**
5
16
  * creates a typedsocket server
@@ -8,27 +19,63 @@ export declare class TypedSocket {
8
19
  static createServer(typedrouterArg: plugins.typedrequest.TypedRouter, smartexpressServerArg?: any): Promise<TypedSocket>;
9
20
  static createClient(typedrouterArg: plugins.typedrequest.TypedRouter, serverUrlArg: string, aliasArg?: string): Promise<TypedSocket>;
10
21
  static useWindowLocationOriginUrl: () => string;
22
+ /**
23
+ * Creates a TypedSocket server from an existing SmartServe instance.
24
+ * Use this when you want TypedSocket to work with SmartServe's WebSocket handling.
25
+ *
26
+ * @param smartServeArg - SmartServe instance with typedRouter configured in websocket options
27
+ * @param typedRouterArg - TypedRouter for handling requests (must match SmartServe's typedRouter)
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const typedRouter = new TypedRouter();
32
+ * const smartServe = new SmartServe({
33
+ * port: 3000,
34
+ * websocket: {
35
+ * typedRouter,
36
+ * onConnectionOpen: (peer) => peer.tags.add('client')
37
+ * }
38
+ * });
39
+ * await smartServe.start();
40
+ * const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
41
+ * ```
42
+ */
43
+ static fromSmartServe(smartServeArg: plugins.SmartServe, typedRouterArg: plugins.typedrequest.TypedRouter): TypedSocket;
11
44
  side: TTypedSocketSide;
12
45
  typedrouter: plugins.typedrequest.TypedRouter;
46
+ private smartServeRef?;
47
+ private smartServeConnectionWrappers;
13
48
  get eventSubject(): plugins.smartrx.rxjs.Subject<plugins.smartsocket.TConnectionStatus>;
14
49
  private postMethod;
15
50
  private socketServerOrClient;
16
51
  constructor(sideArg: TTypedSocketSide, typedrouterArg: plugins.typedrequest.TypedRouter, postMethodArg: plugins.typedrequest.IPostMethod, socketServerOrClientArg: plugins.smartsocket.Smartsocket | plugins.smartsocket.SmartsocketClient);
17
52
  addTag<T extends plugins.typedrequestInterfaces.ITag = any>(nameArg: T['name'], payloadArg: T['payload']): void;
18
- createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(methodName: T['method'], targetConnection?: plugins.smartsocket.SocketConnection): plugins.typedrequest.TypedRequest<T>;
53
+ createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(methodName: T['method'], targetConnection?: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper): plugins.typedrequest.TypedRequest<T>;
19
54
  /**
20
- * returns all matching target connection
21
- * @param asyncFindFuncArg
22
- * @returns
55
+ * returns all matching target connections
56
+ * Works with both Smartsocket and SmartServe backends
57
+ * @param asyncFindFuncArg - async filter function
58
+ * @returns array of matching connections
23
59
  */
24
- findAllTargetConnections(asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>): Promise<plugins.smartsocket.SocketConnection[]>;
60
+ findAllTargetConnections(asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper) => Promise<boolean>): Promise<(plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper)[]>;
25
61
  /**
26
62
  * returns a single target connection by returning the first one of all matching ones
27
63
  * @param asyncFindFuncArg
28
64
  * @returns
29
65
  */
30
- findTargetConnection(asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>): Promise<plugins.smartsocket.SocketConnection>;
31
- findAllTargetConnectionsByTag<TTag extends plugins.typedrequestInterfaces.ITag = any>(keyArg: TTag['name'], payloadArg?: TTag['payload']): Promise<plugins.smartsocket.SocketConnection[]>;
32
- findTargetConnectionByTag<TTag extends plugins.typedrequestInterfaces.ITag = any>(keyArg: TTag['name'], payloadArg?: TTag['payload']): Promise<plugins.smartsocket.SocketConnection>;
66
+ findTargetConnection(asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper) => Promise<boolean>): Promise<plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper | undefined>;
67
+ /**
68
+ * Find all connections that have a specific tag
69
+ * Works with both Smartsocket and SmartServe backends
70
+ */
71
+ findAllTargetConnectionsByTag<TTag extends plugins.typedrequestInterfaces.ITag = any>(keyArg: TTag['name'], payloadArg?: TTag['payload']): Promise<(plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper)[]>;
72
+ /**
73
+ * Find a single connection by tag
74
+ */
75
+ findTargetConnectionByTag<TTag extends plugins.typedrequestInterfaces.ITag = any>(keyArg: TTag['name'], payloadArg?: TTag['payload']): Promise<plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper | undefined>;
76
+ /**
77
+ * Stop the TypedSocket server/client
78
+ * Note: In SmartServe mode, SmartServe manages its own lifecycle
79
+ */
33
80
  stop(): Promise<void>;
34
81
  }
@@ -1,6 +1,22 @@
1
1
  import * as plugins from './typedsocket.plugins.js';
2
2
  const publicRoleName = 'publicRoleName';
3
3
  const publicRolePass = 'publicRolePass';
4
+ /**
5
+ * Creates a wrapper around IWebSocketPeer for tag compatibility
6
+ */
7
+ function wrapSmartServePeer(peer) {
8
+ const TAG_PREFIX = '__typedsocket_tag__';
9
+ return {
10
+ peer,
11
+ async getTagById(tagId) {
12
+ if (!peer.tags.has(tagId)) {
13
+ return undefined;
14
+ }
15
+ const payload = peer.data.get(`${TAG_PREFIX}${tagId}`);
16
+ return { id: tagId, payload };
17
+ },
18
+ };
19
+ }
4
20
  export class TypedSocket {
5
21
  // STATIC
6
22
  /**
@@ -68,10 +84,75 @@ export class TypedSocket {
68
84
  const windowLocationResult = plugins.smarturl.Smarturl.createFromUrl(globalThis.location.origin).toString();
69
85
  return windowLocationResult;
70
86
  }; }
87
+ /**
88
+ * Creates a TypedSocket server from an existing SmartServe instance.
89
+ * Use this when you want TypedSocket to work with SmartServe's WebSocket handling.
90
+ *
91
+ * @param smartServeArg - SmartServe instance with typedRouter configured in websocket options
92
+ * @param typedRouterArg - TypedRouter for handling requests (must match SmartServe's typedRouter)
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const typedRouter = new TypedRouter();
97
+ * const smartServe = new SmartServe({
98
+ * port: 3000,
99
+ * websocket: {
100
+ * typedRouter,
101
+ * onConnectionOpen: (peer) => peer.tags.add('client')
102
+ * }
103
+ * });
104
+ * await smartServe.start();
105
+ * const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
106
+ * ```
107
+ */
108
+ static fromSmartServe(smartServeArg, typedRouterArg) {
109
+ const connectionWrappers = new Map();
110
+ // Create the postMethod for server-initiated requests
111
+ const postMethod = async (dataArg, targetConnectionArg) => {
112
+ if (!targetConnectionArg) {
113
+ const allConnections = smartServeArg.getWebSocketConnections();
114
+ if (allConnections.length === 1) {
115
+ console.log('Since no targetConnection was supplied and there is only one active one present, choosing that one automatically');
116
+ const peer = allConnections[0];
117
+ let wrapper = connectionWrappers.get(peer.id);
118
+ if (!wrapper) {
119
+ wrapper = wrapSmartServePeer(peer);
120
+ connectionWrappers.set(peer.id, wrapper);
121
+ }
122
+ targetConnectionArg = wrapper;
123
+ }
124
+ else if (allConnections.length === 0) {
125
+ throw new Error('No WebSocket connections available');
126
+ }
127
+ else {
128
+ throw new Error('you need to specify the wanted targetConnection. Currently no target is selectable automatically.');
129
+ }
130
+ }
131
+ // Register interest for the response using correlation ID
132
+ const interest = await typedRouterArg.fireEventInterestMap.addInterest(dataArg.correlation.id, dataArg);
133
+ // Send the request to the client
134
+ targetConnectionArg.peer.send(plugins.smartjson.stringify(dataArg));
135
+ // Wait for the response (TypedRouter will fulfill via routeAndAddResponse when response arrives)
136
+ const response = await interest.interestFullfilled;
137
+ return response;
138
+ };
139
+ const typedSocket = new TypedSocket('server', typedRouterArg, postMethod, null // No smartsocket server/client when using SmartServe
140
+ );
141
+ typedSocket.smartServeRef = smartServeArg;
142
+ typedSocket.smartServeConnectionWrappers = connectionWrappers;
143
+ return typedSocket;
144
+ }
71
145
  get eventSubject() {
146
+ if (this.smartServeRef) {
147
+ // SmartServe doesn't provide an eventSubject, return a new Subject
148
+ // In SmartServe mode, connection events are handled via onConnectionOpen/onConnectionClose hooks
149
+ console.warn('eventSubject is not fully supported in SmartServe mode. Use SmartServe hooks instead.');
150
+ return new plugins.smartrx.rxjs.Subject();
151
+ }
72
152
  return this.socketServerOrClient.eventSubject;
73
153
  }
74
154
  constructor(sideArg, typedrouterArg, postMethodArg, socketServerOrClientArg) {
155
+ this.smartServeConnectionWrappers = new Map();
75
156
  this.side = sideArg;
76
157
  this.typedrouter = typedrouterArg;
77
158
  this.postMethod = postMethodArg;
@@ -99,11 +180,28 @@ export class TypedSocket {
99
180
  return typedrequest;
100
181
  }
101
182
  /**
102
- * returns all matching target connection
103
- * @param asyncFindFuncArg
104
- * @returns
183
+ * returns all matching target connections
184
+ * Works with both Smartsocket and SmartServe backends
185
+ * @param asyncFindFuncArg - async filter function
186
+ * @returns array of matching connections
105
187
  */
106
188
  async findAllTargetConnections(asyncFindFuncArg) {
189
+ // SmartServe mode
190
+ if (this.smartServeRef) {
191
+ const matchingConnections = [];
192
+ for (const peer of this.smartServeRef.getWebSocketConnections()) {
193
+ let wrapper = this.smartServeConnectionWrappers.get(peer.id);
194
+ if (!wrapper) {
195
+ wrapper = wrapSmartServePeer(peer);
196
+ this.smartServeConnectionWrappers.set(peer.id, wrapper);
197
+ }
198
+ if (await asyncFindFuncArg(wrapper)) {
199
+ matchingConnections.push(wrapper);
200
+ }
201
+ }
202
+ return matchingConnections;
203
+ }
204
+ // Smartsocket mode
107
205
  if (this.socketServerOrClient instanceof plugins.smartsocket.Smartsocket) {
108
206
  const matchingSockets = [];
109
207
  for (const socketConnection of this.socketServerOrClient.socketConnections.getArray()) {
@@ -113,9 +211,7 @@ export class TypedSocket {
113
211
  }
114
212
  return matchingSockets;
115
213
  }
116
- else {
117
- throw new Error('this method >>findTargetConnection<< is only available from the server');
118
- }
214
+ throw new Error('this method >>findTargetConnection<< is only available from the server');
119
215
  }
120
216
  /**
121
217
  * returns a single target connection by returning the first one of all matching ones
@@ -126,7 +222,33 @@ export class TypedSocket {
126
222
  const allMatching = await this.findAllTargetConnections(asyncFindFuncArg);
127
223
  return allMatching[0];
128
224
  }
225
+ /**
226
+ * Find all connections that have a specific tag
227
+ * Works with both Smartsocket and SmartServe backends
228
+ */
129
229
  async findAllTargetConnectionsByTag(keyArg, payloadArg) {
230
+ // SmartServe mode - use native filtering for better performance
231
+ if (this.smartServeRef) {
232
+ const peers = this.smartServeRef.getWebSocketConnectionsByTag(keyArg);
233
+ const results = [];
234
+ for (const peer of peers) {
235
+ let wrapper = this.smartServeConnectionWrappers.get(peer.id);
236
+ if (!wrapper) {
237
+ wrapper = wrapSmartServePeer(peer);
238
+ this.smartServeConnectionWrappers.set(peer.id, wrapper);
239
+ }
240
+ // If payload specified, also filter by payload stored in peer.data
241
+ if (payloadArg !== undefined) {
242
+ const tag = await wrapper.getTagById(keyArg);
243
+ if (plugins.smartjson.stringify(tag?.payload) !== plugins.smartjson.stringify(payloadArg)) {
244
+ continue;
245
+ }
246
+ }
247
+ results.push(wrapper);
248
+ }
249
+ return results;
250
+ }
251
+ // Smartsocket mode - use existing logic
130
252
  return this.findAllTargetConnections(async (socketConnectionArg) => {
131
253
  let result;
132
254
  if (!payloadArg) {
@@ -139,12 +261,25 @@ export class TypedSocket {
139
261
  return result;
140
262
  });
141
263
  }
264
+ /**
265
+ * Find a single connection by tag
266
+ */
142
267
  async findTargetConnectionByTag(keyArg, payloadArg) {
143
268
  const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg);
144
269
  return allResults[0];
145
270
  }
271
+ /**
272
+ * Stop the TypedSocket server/client
273
+ * Note: In SmartServe mode, SmartServe manages its own lifecycle
274
+ */
146
275
  async stop() {
276
+ if (this.smartServeRef) {
277
+ // SmartServe manages its own lifecycle
278
+ // Clear our connection wrappers
279
+ this.smartServeConnectionWrappers.clear();
280
+ return;
281
+ }
147
282
  await this.socketServerOrClient.stop();
148
283
  }
149
284
  }
150
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZWRzb2NrZXQuY2xhc3Nlcy50eXBlZHNvY2tldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3R5cGVkc29ja2V0LmNsYXNzZXMudHlwZWRzb2NrZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSwwQkFBMEIsQ0FBQztBQUVwRCxNQUFNLGNBQWMsR0FBRyxnQkFBZ0IsQ0FBQztBQUN4QyxNQUFNLGNBQWMsR0FBRyxnQkFBZ0IsQ0FBQztBQUl4QyxNQUFNLE9BQU8sV0FBVztJQUN0QixTQUFTO0lBQ1Q7OztPQUdHO0lBQ0ksTUFBTSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQzlCLGNBQWdELEVBQ2hELHFCQUEyQjtRQUUzQixNQUFNLGlCQUFpQixHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxXQUFXLENBQUM7WUFDNUQsS0FBSyxFQUFFLG1CQUFtQjtZQUMxQixJQUFJLEVBQUUsSUFBSTtTQUNYLENBQUMsQ0FBQztRQUNILElBQUkscUJBQXFCLEVBQUU7WUFDekIsaUJBQWlCLENBQUMsaUJBQWlCLENBQUMsY0FBYyxFQUFFLHFCQUFxQixDQUFDLENBQUM7U0FDNUU7UUFFRCxpQkFBaUIsQ0FBQyxlQUFlLENBQUMsR0FBRyxDQUNuQyxJQUFJ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DSixDQUFDO1lBQ0QsT0FBTyxNQUFNLENBQUM7UUFDaEIsQ0FBQyxDQUFDLENBQUM7SUFDTCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMseUJBQXlCLENBQ3BDLE1BQW9CLEVBQ3BCLFVBQTRCO1FBRTVCLE1BQU0sVUFBVSxHQUFHLE1BQU0sSUFBSSxDQUFDLDZCQUE2QixDQUFDLE1BQU0sRUFBRSxVQUFVLENBQUMsQ0FBQztRQUNoRixPQUFPLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUN2QixDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLElBQUk7UUFDZixJQUFJLElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztZQUN2Qix1Q0FBdUM7WUFDdkMsZ0NBQWdDO1lBQ2hDLElBQUksQ0FBQyw0QkFBNEIsQ0FBQyxLQUFLLEVBQUUsQ0FBQztZQUMxQyxPQUFPO1FBQ1QsQ0FBQztRQUNELE1BQU0sSUFBSSxDQUFDLG9CQUFvQixDQUFDLElBQUksRUFBRSxDQUFDO0lBQ3pDLENBQUMifQ==
@@ -8,3 +8,4 @@ import * as smartsocket from '@push.rocks/smartsocket';
8
8
  import * as smartstring from '@push.rocks/smartstring';
9
9
  import * as smarturl from '@push.rocks/smarturl';
10
10
  export { isohash, smartjson, smartrx, smartsocket, smartstring, smarturl };
11
+ export type { SmartServe, IWebSocketPeer } from '@push.rocks/smartserve';
package/npmextra.json CHANGED
@@ -2,17 +2,28 @@
2
2
  "gitzone": {
3
3
  "projectType": "npm",
4
4
  "module": {
5
- "githost": "gitlab.com",
5
+ "githost": "code.foss.global",
6
6
  "gitscope": "api.global",
7
7
  "gitrepo": "typedsocket",
8
- "description": "a typedrequest extension supporting websockets",
8
+ "description": "A library for creating typed WebSocket connections, supporting bi-directional communication with type safety.",
9
9
  "npmPackagename": "@api.global/typedsocket",
10
10
  "license": "MIT",
11
- "projectDomain": "api.global"
11
+ "projectDomain": "api.global",
12
+ "keywords": [
13
+ "WebSocket",
14
+ "Type Safety",
15
+ "Real-time Communication",
16
+ "Client-Server Architecture",
17
+ "TypeScript",
18
+ "Networking"
19
+ ]
12
20
  }
13
21
  },
14
22
  "npmci": {
15
23
  "npmGlobalTools": [],
16
24
  "npmAccessLevel": "public"
25
+ },
26
+ "tsdoc": {
27
+ "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
17
28
  }
18
29
  }
package/package.json CHANGED
@@ -1,36 +1,40 @@
1
1
  {
2
2
  "name": "@api.global/typedsocket",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "private": false,
5
- "description": "a typedrequest extension supporting websockets",
5
+ "description": "A library for creating typed WebSocket connections, supporting bi-directional communication with type safety.",
6
6
  "main": "dist_ts/index.js",
7
7
  "typings": "dist_ts/index.d.ts",
8
8
  "type": "module",
9
9
  "author": "Lossless GmbH",
10
10
  "license": "MIT",
11
- "scripts": {
12
- "test": "(tstest test/ --web)",
13
- "build": "(tsbuild --web --allowimplicitany)",
14
- "buildDocs": "tsdoc"
15
- },
16
11
  "devDependencies": {
17
- "@gitzone/tsbuild": "^2.1.66",
18
- "@gitzone/tsbundle": "^2.0.8",
19
- "@gitzone/tsrun": "^1.2.44",
20
- "@gitzone/tstest": "^1.0.77",
21
- "@push.rocks/smartenv": "^5.0.5",
22
- "@push.rocks/tapbundle": "^5.0.12",
23
- "@types/node": "^20.4.8"
12
+ "@git.zone/tsbuild": "^3.1.2",
13
+ "@git.zone/tsbundle": "^2.6.2",
14
+ "@git.zone/tsrun": "^2.0.0",
15
+ "@git.zone/tstest": "^3.1.3",
16
+ "@push.rocks/smartenv": "^6.0.0",
17
+ "@push.rocks/smartserve": "^1.1.0",
18
+ "@push.rocks/tapbundle": "^6.0.3",
19
+ "@types/node": "^24.10.1"
24
20
  },
25
21
  "dependencies": {
26
- "@api.global/typedrequest": "^3.0.1",
27
- "@api.global/typedrequest-interfaces": "^3.0.1",
28
- "@push.rocks/isohash": "^2.0.0",
29
- "@push.rocks/smartjson": "^5.0.5",
30
- "@push.rocks/smartrx": "^3.0.6",
31
- "@push.rocks/smartsocket": "^2.0.22",
32
- "@push.rocks/smartstring": "^4.0.2",
33
- "@push.rocks/smarturl": "^3.0.5"
22
+ "@api.global/typedrequest": "^3.1.10",
23
+ "@api.global/typedrequest-interfaces": "^3.0.19",
24
+ "@push.rocks/isohash": "^2.0.1",
25
+ "@push.rocks/smartjson": "^5.2.0",
26
+ "@push.rocks/smartrx": "^3.0.10",
27
+ "@push.rocks/smartsocket": "^2.1.0",
28
+ "@push.rocks/smartstring": "^4.1.0",
29
+ "@push.rocks/smarturl": "^3.1.0"
30
+ },
31
+ "peerDependencies": {
32
+ "@push.rocks/smartserve": ">=1.0.0"
33
+ },
34
+ "peerDependenciesMeta": {
35
+ "@push.rocks/smartserve": {
36
+ "optional": true
37
+ }
34
38
  },
35
39
  "browserslist": [
36
40
  "last 1 chrome versions"
@@ -46,5 +50,18 @@
46
50
  "cli.js",
47
51
  "npmextra.json",
48
52
  "readme.md"
49
- ]
50
- }
53
+ ],
54
+ "keywords": [
55
+ "WebSocket",
56
+ "Type Safety",
57
+ "Real-time Communication",
58
+ "Client-Server Architecture",
59
+ "TypeScript",
60
+ "Networking"
61
+ ],
62
+ "scripts": {
63
+ "test": "(tstest test/ --web)",
64
+ "build": "(tsbuild --web --allowimplicitany --skiplibcheck)",
65
+ "buildDocs": "tsdoc"
66
+ }
67
+ }
@@ -0,0 +1,21 @@
1
+ # TypedSocket Hints
2
+
3
+ ## SmartServe Integration (Added v3.1.0)
4
+
5
+ TypedSocket now supports SmartServe as an alternative WebSocket backend via `TypedSocket.fromSmartServe()`.
6
+
7
+ ### Key Differences from Smartsocket Mode
8
+
9
+ 1. **Tag System**: SmartServe uses `Set<string>` for tags, while Smartsocket uses `{id, payload}`. The wrapper stores payloads in `peer.data` with `__typedsocket_tag__` prefix.
10
+
11
+ 2. **Request/Response**: Uses TypedRouter's `fireEventInterestMap` for async correlation when sending server-initiated requests.
12
+
13
+ 3. **Lifecycle**: SmartServe manages WebSocket lifecycle. `typedSocket.stop()` only clears internal state.
14
+
15
+ 4. **eventSubject**: Not fully supported in SmartServe mode - use SmartServe's `onConnectionOpen`/`onConnectionClose` hooks instead.
16
+
17
+ ### Files Modified for SmartServe Support
18
+
19
+ - `ts/typedsocket.classes.typedsocket.ts` - Main implementation
20
+ - `ts/typedsocket.plugins.ts` - Type imports
21
+ - `package.json` - Optional peer dependency
package/readme.md CHANGED
@@ -1,41 +1,312 @@
1
- # @apiglobal/typedsocket
2
- a typedrequest extension supporting websockets
3
-
4
- ## Availabililty and Links
5
- * [npmjs.org (npm package)](https://www.npmjs.com/package/@apiglobal/typedsocket)
6
- * [gitlab.com (source)](https://gitlab.com/apiglobal/typedsocket)
7
- * [github.com (source mirror)](https://github.com/apiglobal/typedsocket)
8
- * [docs (typedoc)](https://apiglobal.gitlab.io/typedsocket/)
9
-
10
- ## Status for master
11
-
12
- Status Category | Status Badge
13
- -- | --
14
- GitLab Pipelines | [![pipeline status](https://gitlab.com/apiglobal/typedsocket/badges/master/pipeline.svg)](https://lossless.cloud)
15
- GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/apiglobal/typedsocket/badges/master/coverage.svg)](https://lossless.cloud)
16
- npm | [![npm downloads per month](https://badgen.net/npm/dy/@apiglobal/typedsocket)](https://lossless.cloud)
17
- Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/apiglobal/typedsocket)](https://lossless.cloud)
18
- TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
- node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
- Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
- PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@apiglobal/typedsocket)](https://lossless.cloud)
22
- PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@apiglobal/typedsocket)](https://lossless.cloud)
23
- BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@apiglobal/typedsocket)](https://lossless.cloud)
1
+ # @api.global/typedsocket
2
+
3
+ A TypeScript library for creating typed WebSocket connections with bi-directional communication support. Extends `@api.global/typedrequest` to bring type-safe request/response patterns to WebSocket connections.
4
+
5
+ ## Issue Reporting and Security
6
+
7
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
8
+
9
+ ## Features
10
+
11
+ - 🔒 **Full Type Safety** - Leverages TypeScript for compile-time checking of all request/response payloads
12
+ - 🔄 **Bi-directional Communication** - Both server and client can initiate requests
13
+ - 🔌 **Auto-reconnect** - Client automatically reconnects on connection loss
14
+ - 🏷️ **Connection Tagging** - Tag and filter connections for targeted messaging
15
+ - 🌐 **Browser Compatible** - Works in both Node.js and browser environments
16
+ - 🔗 **SmartExpress Integration** - Optional integration with existing SmartExpress servers
17
+ - 🚀 **SmartServe Integration** - Native support for SmartServe's WebSocket handling
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @api.global/typedsocket
23
+ ```
24
+
25
+ Or with pnpm:
26
+
27
+ ```bash
28
+ pnpm add @api.global/typedsocket
29
+ ```
24
30
 
25
31
  ## Usage
26
32
 
27
- Use TypeScript for best in class intellisense.
33
+ ### Prerequisites
34
+
35
+ - TypeScript project setup
36
+ - Basic understanding of async/await patterns
37
+ - Familiarity with `@api.global/typedrequest` concepts
38
+
39
+ ### Define Your Request Interface
40
+
41
+ First, define the typed request interface that both client and server will use:
42
+
43
+ ```typescript
44
+ import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
45
+
46
+ interface IGreetingRequest extends typedrequestInterfaces.implementsTR<
47
+ typedrequestInterfaces.ITypedRequest,
48
+ IGreetingRequest
49
+ > {
50
+ method: 'greet';
51
+ request: {
52
+ name: string;
53
+ };
54
+ response: {
55
+ message: string;
56
+ };
57
+ }
58
+ ```
59
+
60
+ ### Server Setup
61
+
62
+ Create a WebSocket server that handles typed requests:
63
+
64
+ ```typescript
65
+ import { TypedSocket } from '@api.global/typedsocket';
66
+ import * as typedrequest from '@api.global/typedrequest';
67
+
68
+ // Create the router and add handlers
69
+ const typedRouter = new typedrequest.TypedRouter();
70
+
71
+ typedRouter.addTypedHandler<IGreetingRequest>(
72
+ new typedrequest.TypedHandler('greet', async (requestData) => {
73
+ return {
74
+ message: `Hello, ${requestData.name}! 👋`,
75
+ };
76
+ })
77
+ );
78
+
79
+ // Start the TypedSocket server (defaults to port 3000)
80
+ const server = await TypedSocket.createServer(typedRouter);
81
+ ```
82
+
83
+ #### Integration with SmartExpress
84
+
85
+ If you have an existing SmartExpress server, you can attach TypedSocket to it:
86
+
87
+ ```typescript
88
+ import { TypedSocket } from '@api.global/typedsocket';
89
+ import * as smartexpress from '@push.rocks/smartexpress';
90
+
91
+ const smartExpressServer = new smartexpress.Server({ port: 8080 });
92
+ await smartExpressServer.start();
93
+
94
+ const server = await TypedSocket.createServer(typedRouter, smartExpressServer);
95
+ ```
96
+
97
+ #### Integration with SmartServe
98
+
99
+ For SmartServe-based applications, use `fromSmartServe()` for native integration:
100
+
101
+ ```typescript
102
+ import { TypedSocket } from '@api.global/typedsocket';
103
+ import { SmartServe } from '@push.rocks/smartserve';
104
+ import * as typedrequest from '@api.global/typedrequest';
105
+
106
+ const typedRouter = new typedrequest.TypedRouter();
107
+
108
+ // Add handlers for client-to-server requests
109
+ typedRouter.addTypedHandler<IGreetingRequest>(
110
+ new typedrequest.TypedHandler('greet', async (requestData) => {
111
+ return { message: `Hello, ${requestData.name}!` };
112
+ })
113
+ );
114
+
115
+ // Create SmartServe with typedRouter in websocket options
116
+ const smartServe = new SmartServe({
117
+ port: 3000,
118
+ websocket: {
119
+ typedRouter,
120
+ onConnectionOpen: (peer) => {
121
+ // Tag connections for later filtering
122
+ peer.tags.add('client');
123
+ }
124
+ }
125
+ });
126
+
127
+ await smartServe.start();
128
+
129
+ // Create TypedSocket bound to SmartServe
130
+ const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
131
+
132
+ // Push notifications to tagged clients
133
+ const clients = await typedSocket.findAllTargetConnectionsByTag('client');
134
+ for (const client of clients) {
135
+ const request = typedSocket.createTypedRequest<INotifyRequest>('notify', client);
136
+ await request.fire({ message: 'Hello from server!' });
137
+ }
138
+ ```
139
+
140
+ > **Note:** When using SmartServe, the WebSocket transport is managed by SmartServe. TypedSocket acts as a convenience layer for finding connections and sending server-initiated requests.
141
+
142
+ ### Client Setup
143
+
144
+ Connect to the WebSocket server from a client:
145
+
146
+ ```typescript
147
+ import { TypedSocket } from '@api.global/typedsocket';
148
+ import * as typedrequest from '@api.global/typedrequest';
149
+
150
+ // Create a router for handling server-initiated requests (if needed)
151
+ const clientRouter = new typedrequest.TypedRouter();
152
+
153
+ // Connect to the server
154
+ const client = await TypedSocket.createClient(
155
+ clientRouter,
156
+ 'http://localhost:3000'
157
+ );
158
+ ```
159
+
160
+ #### Using Window Location (Browser)
161
+
162
+ In browser environments, you can automatically use the current page's origin:
163
+
164
+ ```typescript
165
+ const client = await TypedSocket.createClient(
166
+ clientRouter,
167
+ TypedSocket.useWindowLocationOriginUrl()
168
+ );
169
+ ```
170
+
171
+ ### Sending Requests
172
+
173
+ #### Client to Server
174
+
175
+ ```typescript
176
+ const request = client.createTypedRequest<IGreetingRequest>('greet');
177
+ const response = await request.fire({
178
+ name: 'World',
179
+ });
180
+
181
+ console.log(response.message); // "Hello, World! 👋"
182
+ ```
183
+
184
+ #### Server to Client
185
+
186
+ The server can also initiate requests to connected clients:
187
+
188
+ ```typescript
189
+ // When only one client is connected, it's automatically selected
190
+ const request = server.createTypedRequest<IGreetingRequest>('greet');
191
+ const response = await request.fire({
192
+ name: 'Client',
193
+ });
194
+
195
+ // For multiple clients, specify the target connection
196
+ const connection = await server.findTargetConnection(async (conn) => {
197
+ // Your filter logic here
198
+ return true;
199
+ });
200
+ const targetedRequest = server.createTypedRequest<IGreetingRequest>('greet', connection);
201
+ ```
202
+
203
+ ### Connection Tagging
204
+
205
+ Tag connections for organized, targeted communication:
206
+
207
+ ```typescript
208
+ // Client side: add a tag
209
+ interface IUserTag extends typedrequestInterfaces.ITag {
210
+ name: 'userRole';
211
+ payload: 'admin' | 'user' | 'guest';
212
+ }
213
+
214
+ client.addTag<IUserTag>('userRole', 'admin');
215
+ ```
216
+
217
+ ```typescript
218
+ // Server side: find connections by tag
219
+ const adminConnections = await server.findAllTargetConnectionsByTag<IUserTag>(
220
+ 'userRole',
221
+ 'admin'
222
+ );
223
+
224
+ // Send to all admins
225
+ for (const conn of adminConnections) {
226
+ const request = server.createTypedRequest<INotificationRequest>('notify', conn);
227
+ await request.fire({ message: 'Admin notification' });
228
+ }
229
+
230
+ // Find a single connection
231
+ const firstAdmin = await server.findTargetConnectionByTag<IUserTag>('userRole', 'admin');
232
+ ```
233
+
234
+ ### Event Handling
235
+
236
+ Subscribe to connection status events:
237
+
238
+ ```typescript
239
+ client.eventSubject.subscribe((status) => {
240
+ console.log('Connection status:', status);
241
+ });
242
+
243
+ server.eventSubject.subscribe((status) => {
244
+ console.log('Server connection event:', status);
245
+ });
246
+ ```
247
+
248
+ ### Cleanup
249
+
250
+ Properly close connections when done:
251
+
252
+ ```typescript
253
+ // Client
254
+ await client.stop();
255
+
256
+ // Server
257
+ await server.stop();
258
+ ```
259
+
260
+ ## API Reference
261
+
262
+ ### TypedSocket
263
+
264
+ #### Static Methods
265
+
266
+ | Method | Description |
267
+ |--------|-------------|
268
+ | `createServer(router, smartExpressServer?)` | Creates a WebSocket server. Optionally attach to an existing SmartExpress server. |
269
+ | `createClient(router, serverUrl, alias?)` | Creates a WebSocket client that connects to the specified server URL. |
270
+ | `fromSmartServe(smartServe, router)` | Creates a TypedSocket bound to an existing SmartServe instance. |
271
+ | `useWindowLocationOriginUrl()` | Returns the current window location origin (browser only). |
272
+
273
+ #### Instance Properties
274
+
275
+ | Property | Description |
276
+ |----------|-------------|
277
+ | `side` | Whether this instance is a `'server'` or `'client'`. |
278
+ | `typedrouter` | The TypedRouter instance handling requests. |
279
+ | `eventSubject` | RxJS Subject for connection status events. |
280
+
281
+ #### Instance Methods
282
+
283
+ | Method | Description |
284
+ |--------|-------------|
285
+ | `createTypedRequest(method, targetConnection?)` | Creates a typed request for the specified method. |
286
+ | `addTag(name, payload)` | Adds a tag to the client connection (client-side only). |
287
+ | `findAllTargetConnections(filterFn)` | Finds all connections matching the filter (server-side only). |
288
+ | `findTargetConnection(filterFn)` | Finds the first connection matching the filter (server-side only). |
289
+ | `findAllTargetConnectionsByTag(key, payload?)` | Finds all connections with the specified tag. |
290
+ | `findTargetConnectionByTag(key, payload?)` | Finds the first connection with the specified tag. |
291
+ | `stop()` | Closes the WebSocket connection. |
292
+
293
+ ## License and Legal Information
294
+
295
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
296
+
297
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
298
+
299
+ ### Trademarks
28
300
 
29
- TypedSocket is the typedrequest you love, just in a bidirectional way.
301
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
30
302
 
31
- See the following examples from our test for reference:
303
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
32
304
 
33
- ## Contribution
305
+ ### Company Information
34
306
 
35
- We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
307
+ Task Venture Capital GmbH
308
+ Registered at District Court Bremen HRB 35230 HB, Germany
36
309
 
37
- For further information read the linked docs at the top of this readme.
310
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
38
311
 
39
- ## Legal
40
- > MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
41
- | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
312
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@api.global/typedsocket',
6
- version: '3.0.0',
7
- description: 'a typedrequest extension supporting websockets'
6
+ version: '3.1.1',
7
+ description: 'A library for creating typed WebSocket connections, supporting bi-directional communication with type safety.'
8
8
  }
@@ -5,6 +5,32 @@ const publicRolePass = 'publicRolePass';
5
5
 
6
6
  export type TTypedSocketSide = 'server' | 'client';
7
7
 
8
+ /**
9
+ * Wrapper for SmartServe's IWebSocketPeer to provide tag compatibility
10
+ * SmartServe uses Set<string> for tags, while TypedSocket uses {id, payload} format
11
+ */
12
+ export interface ISmartServeConnectionWrapper {
13
+ peer: plugins.IWebSocketPeer;
14
+ getTagById(tagId: string): Promise<{ id: string; payload: any } | undefined>;
15
+ }
16
+
17
+ /**
18
+ * Creates a wrapper around IWebSocketPeer for tag compatibility
19
+ */
20
+ function wrapSmartServePeer(peer: plugins.IWebSocketPeer): ISmartServeConnectionWrapper {
21
+ const TAG_PREFIX = '__typedsocket_tag__';
22
+ return {
23
+ peer,
24
+ async getTagById(tagId: string): Promise<{ id: string; payload: any } | undefined> {
25
+ if (!peer.tags.has(tagId)) {
26
+ return undefined;
27
+ }
28
+ const payload = peer.data.get(`${TAG_PREFIX}${tagId}`);
29
+ return { id: tagId, payload };
30
+ },
31
+ };
32
+ }
33
+
8
34
  export class TypedSocket {
9
35
  // STATIC
10
36
  /**
@@ -110,16 +136,108 @@ export class TypedSocket {
110
136
  return windowLocationResult;
111
137
  }
112
138
 
139
+ /**
140
+ * Creates a TypedSocket server from an existing SmartServe instance.
141
+ * Use this when you want TypedSocket to work with SmartServe's WebSocket handling.
142
+ *
143
+ * @param smartServeArg - SmartServe instance with typedRouter configured in websocket options
144
+ * @param typedRouterArg - TypedRouter for handling requests (must match SmartServe's typedRouter)
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const typedRouter = new TypedRouter();
149
+ * const smartServe = new SmartServe({
150
+ * port: 3000,
151
+ * websocket: {
152
+ * typedRouter,
153
+ * onConnectionOpen: (peer) => peer.tags.add('client')
154
+ * }
155
+ * });
156
+ * await smartServe.start();
157
+ * const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
158
+ * ```
159
+ */
160
+ public static fromSmartServe(
161
+ smartServeArg: plugins.SmartServe,
162
+ typedRouterArg: plugins.typedrequest.TypedRouter
163
+ ): TypedSocket {
164
+ const connectionWrappers = new Map<string, ISmartServeConnectionWrapper>();
165
+
166
+ // Create the postMethod for server-initiated requests
167
+ const postMethod = async <T extends plugins.typedrequestInterfaces.ITypedRequest>(
168
+ dataArg: T,
169
+ targetConnectionArg?: ISmartServeConnectionWrapper
170
+ ): Promise<T> => {
171
+ if (!targetConnectionArg) {
172
+ const allConnections = smartServeArg.getWebSocketConnections();
173
+ if (allConnections.length === 1) {
174
+ console.log(
175
+ 'Since no targetConnection was supplied and there is only one active one present, choosing that one automatically'
176
+ );
177
+ const peer = allConnections[0];
178
+ let wrapper = connectionWrappers.get(peer.id);
179
+ if (!wrapper) {
180
+ wrapper = wrapSmartServePeer(peer);
181
+ connectionWrappers.set(peer.id, wrapper);
182
+ }
183
+ targetConnectionArg = wrapper;
184
+ } else if (allConnections.length === 0) {
185
+ throw new Error('No WebSocket connections available');
186
+ } else {
187
+ throw new Error(
188
+ 'you need to specify the wanted targetConnection. Currently no target is selectable automatically.'
189
+ );
190
+ }
191
+ }
192
+
193
+ // Register interest for the response using correlation ID
194
+ const interest = await typedRouterArg.fireEventInterestMap.addInterest(
195
+ dataArg.correlation.id,
196
+ dataArg
197
+ );
198
+
199
+ // Send the request to the client
200
+ targetConnectionArg.peer.send(plugins.smartjson.stringify(dataArg));
201
+
202
+ // Wait for the response (TypedRouter will fulfill via routeAndAddResponse when response arrives)
203
+ const response = await interest.interestFullfilled as T;
204
+ return response;
205
+ };
206
+
207
+ const typedSocket = new TypedSocket(
208
+ 'server',
209
+ typedRouterArg,
210
+ postMethod as any,
211
+ null as any // No smartsocket server/client when using SmartServe
212
+ );
213
+
214
+ typedSocket.smartServeRef = smartServeArg;
215
+ typedSocket.smartServeConnectionWrappers = connectionWrappers;
216
+
217
+ return typedSocket;
218
+ }
219
+
113
220
  // INSTANCE
114
221
  public side: TTypedSocketSide;
115
222
  public typedrouter: plugins.typedrequest.TypedRouter;
223
+
224
+ // SmartServe mode properties
225
+ private smartServeRef?: plugins.SmartServe;
226
+ private smartServeConnectionWrappers: Map<string, ISmartServeConnectionWrapper> = new Map();
227
+
116
228
  public get eventSubject(): plugins.smartrx.rxjs.Subject<plugins.smartsocket.TConnectionStatus> {
229
+ if (this.smartServeRef) {
230
+ // SmartServe doesn't provide an eventSubject, return a new Subject
231
+ // In SmartServe mode, connection events are handled via onConnectionOpen/onConnectionClose hooks
232
+ console.warn('eventSubject is not fully supported in SmartServe mode. Use SmartServe hooks instead.');
233
+ return new plugins.smartrx.rxjs.Subject();
234
+ }
117
235
  return this.socketServerOrClient.eventSubject;
118
236
  }
119
237
  private postMethod: plugins.typedrequest.IPostMethod &
120
238
  ((
121
239
  typedRequestPostObject: plugins.typedrequestInterfaces.ITypedRequest,
122
- socketConnectionArg?: plugins.smartsocket.SocketConnection
240
+ socketConnectionArg?: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper
123
241
  ) => Promise<plugins.typedrequestInterfaces.ITypedRequest>);
124
242
  private socketServerOrClient:
125
243
  | plugins.smartsocket.Smartsocket
@@ -155,12 +273,12 @@ export class TypedSocket {
155
273
 
156
274
  public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(
157
275
  methodName: T['method'],
158
- targetConnection?: plugins.smartsocket.SocketConnection
276
+ targetConnection?: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper
159
277
  ): plugins.typedrequest.TypedRequest<T> {
160
278
  const typedrequest = new plugins.typedrequest.TypedRequest<T>(
161
279
  new plugins.typedrequest.TypedTarget({
162
280
  postMethod: async (requestDataArg) => {
163
- const result = await this.postMethod(requestDataArg, targetConnection);
281
+ const result = await this.postMethod(requestDataArg, targetConnection as any);
164
282
  return result;
165
283
  },
166
284
  }),
@@ -170,13 +288,31 @@ export class TypedSocket {
170
288
  }
171
289
 
172
290
  /**
173
- * returns all matching target connection
174
- * @param asyncFindFuncArg
175
- * @returns
291
+ * returns all matching target connections
292
+ * Works with both Smartsocket and SmartServe backends
293
+ * @param asyncFindFuncArg - async filter function
294
+ * @returns array of matching connections
176
295
  */
177
296
  public async findAllTargetConnections(
178
- asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
179
- ) {
297
+ asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper) => Promise<boolean>
298
+ ): Promise<(plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper)[]> {
299
+ // SmartServe mode
300
+ if (this.smartServeRef) {
301
+ const matchingConnections: ISmartServeConnectionWrapper[] = [];
302
+ for (const peer of this.smartServeRef.getWebSocketConnections()) {
303
+ let wrapper = this.smartServeConnectionWrappers.get(peer.id);
304
+ if (!wrapper) {
305
+ wrapper = wrapSmartServePeer(peer);
306
+ this.smartServeConnectionWrappers.set(peer.id, wrapper);
307
+ }
308
+ if (await asyncFindFuncArg(wrapper)) {
309
+ matchingConnections.push(wrapper);
310
+ }
311
+ }
312
+ return matchingConnections;
313
+ }
314
+
315
+ // Smartsocket mode
180
316
  if (this.socketServerOrClient instanceof plugins.smartsocket.Smartsocket) {
181
317
  const matchingSockets: plugins.smartsocket.SocketConnection[] = [];
182
318
  for (const socketConnection of this.socketServerOrClient.socketConnections.getArray()) {
@@ -185,9 +321,9 @@ export class TypedSocket {
185
321
  }
186
322
  }
187
323
  return matchingSockets;
188
- } else {
189
- throw new Error('this method >>findTargetConnection<< is only available from the server');
190
324
  }
325
+
326
+ throw new Error('this method >>findTargetConnection<< is only available from the server');
191
327
  }
192
328
 
193
329
  /**
@@ -196,22 +332,51 @@ export class TypedSocket {
196
332
  * @returns
197
333
  */
198
334
  public async findTargetConnection(
199
- asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
200
- ) {
335
+ asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper) => Promise<boolean>
336
+ ): Promise<plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper | undefined> {
201
337
  const allMatching = await this.findAllTargetConnections(asyncFindFuncArg);
202
338
  return allMatching[0];
203
339
  }
204
340
 
341
+ /**
342
+ * Find all connections that have a specific tag
343
+ * Works with both Smartsocket and SmartServe backends
344
+ */
205
345
  public async findAllTargetConnectionsByTag<
206
346
  TTag extends plugins.typedrequestInterfaces.ITag = any
207
- >(keyArg: TTag['name'], payloadArg?: TTag['payload']) {
347
+ >(keyArg: TTag['name'], payloadArg?: TTag['payload']): Promise<(plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper)[]> {
348
+ // SmartServe mode - use native filtering for better performance
349
+ if (this.smartServeRef) {
350
+ const peers = this.smartServeRef.getWebSocketConnectionsByTag(keyArg);
351
+ const results: ISmartServeConnectionWrapper[] = [];
352
+
353
+ for (const peer of peers) {
354
+ let wrapper = this.smartServeConnectionWrappers.get(peer.id);
355
+ if (!wrapper) {
356
+ wrapper = wrapSmartServePeer(peer);
357
+ this.smartServeConnectionWrappers.set(peer.id, wrapper);
358
+ }
359
+
360
+ // If payload specified, also filter by payload stored in peer.data
361
+ if (payloadArg !== undefined) {
362
+ const tag = await wrapper.getTagById(keyArg);
363
+ if (plugins.smartjson.stringify(tag?.payload) !== plugins.smartjson.stringify(payloadArg)) {
364
+ continue;
365
+ }
366
+ }
367
+ results.push(wrapper);
368
+ }
369
+ return results;
370
+ }
371
+
372
+ // Smartsocket mode - use existing logic
208
373
  return this.findAllTargetConnections(async (socketConnectionArg) => {
209
374
  let result: boolean;
210
375
  if (!payloadArg) {
211
- result = !!(await socketConnectionArg.getTagById(keyArg));
376
+ result = !!(await (socketConnectionArg as plugins.smartsocket.SocketConnection).getTagById(keyArg));
212
377
  } else {
213
378
  result = !!(
214
- plugins.smartjson.stringify((await socketConnectionArg.getTagById(keyArg))?.payload) ===
379
+ plugins.smartjson.stringify((await (socketConnectionArg as plugins.smartsocket.SocketConnection).getTagById(keyArg))?.payload) ===
215
380
  plugins.smartjson.stringify(payloadArg)
216
381
  );
217
382
  }
@@ -219,15 +384,28 @@ export class TypedSocket {
219
384
  });
220
385
  }
221
386
 
387
+ /**
388
+ * Find a single connection by tag
389
+ */
222
390
  public async findTargetConnectionByTag<TTag extends plugins.typedrequestInterfaces.ITag = any>(
223
391
  keyArg: TTag['name'],
224
392
  payloadArg?: TTag['payload']
225
- ) {
393
+ ): Promise<plugins.smartsocket.SocketConnection | ISmartServeConnectionWrapper | undefined> {
226
394
  const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg);
227
395
  return allResults[0];
228
396
  }
229
397
 
398
+ /**
399
+ * Stop the TypedSocket server/client
400
+ * Note: In SmartServe mode, SmartServe manages its own lifecycle
401
+ */
230
402
  public async stop() {
403
+ if (this.smartServeRef) {
404
+ // SmartServe manages its own lifecycle
405
+ // Clear our connection wrappers
406
+ this.smartServeConnectionWrappers.clear();
407
+ return;
408
+ }
231
409
  await this.socketServerOrClient.stop();
232
410
  }
233
411
  }
@@ -13,3 +13,6 @@ import * as smartstring from '@push.rocks/smartstring';
13
13
  import * as smarturl from '@push.rocks/smarturl';
14
14
 
15
15
  export { isohash, smartjson, smartrx, smartsocket, smartstring, smarturl };
16
+
17
+ // Optional SmartServe support (type-only imports for optional peer dependency)
18
+ export type { SmartServe, IWebSocketPeer } from '@push.rocks/smartserve';