fix(build): tighten TypeScript compatibility and update project build configuration

This commit is contained in:
2026-04-30 15:22:54 +00:00
parent d75486ac6e
commit 554af7752e
14 changed files with 2389 additions and 1962 deletions
+38
View File
@@ -0,0 +1,38 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartsocket",
"description": "Provides easy and secure websocket communication mechanisms, including server and client implementation, function call routing, connection management, and tagging.",
"npmPackagename": "@push.rocks/smartsocket",
"license": "MIT",
"projectDomain": "push.rocks"
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"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"
},
"@git.zone/tsbundle": {
"bundles": [
{
"from": "./ts/index.ts",
"to": "./dist_bundle/bundle.js",
"outputMode": "bundle",
"bundler": "esbuild"
}
]
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
+9
View File
@@ -1,5 +1,14 @@
# Changelog
## 2026-04-30 - 4.0.1 - fix(build)
tighten TypeScript compatibility and update project build configuration
- enable stricter null and implicit-any-safe typing across client, connection, request, and server classes
- add runtime guards for missing socket connections and missing function request ids
- update build and release configuration for tsbuild/tsbundle and npm publishing metadata
- refresh dependency versions and include smart config and license files in published package
- strengthen reconnect and tagging tests with explicit existence checks
## 2025-12-04 - 4.0.0 - BREAKING CHANGE(socketconnection)
Stricter typings, smartserve hooks, connection fixes, and tag API change
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2026 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+14 -7
View File
@@ -1,5 +1,5 @@
{
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
@@ -21,13 +21,20 @@
"function routing",
"secure"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"@git.zone/tsdoc": {
"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"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
}
+17 -14
View File
@@ -7,7 +7,7 @@
"type": "module",
"scripts": {
"test": "(tstest test/ --verbose)",
"build": "(tsbuild --web --allowimplicitany && tsbundle --from ./ts/index.ts --to dist_bundle/bundle.js)",
"build": "tsbuild --web && tsbundle",
"buildDocs": "tsdoc"
},
"repository": {
@@ -17,30 +17,30 @@
"author": "Task Venture Capital GmbH",
"license": "MIT",
"bugs": {
"url": "https://community.foss.global/"
"url": "https://code.foss.global/push.rocks/smartsocket/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartsocket",
"dependencies": {
"@api.global/typedrequest-interfaces": "^3.0.19",
"@push.rocks/isohash": "^2.0.1",
"@push.rocks/isounique": "^1.0.5",
"@push.rocks/lik": "^6.2.2",
"@push.rocks/lik": "^6.4.1",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartenv": "^6.0.0",
"@push.rocks/smartjson": "^5.2.0",
"@push.rocks/smartlog": "^3.1.10",
"@push.rocks/smartjson": "^6.0.1",
"@push.rocks/smartlog": "^3.2.2",
"@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartrx": "^3.0.10",
"@push.rocks/smarttime": "^4.1.1",
"ws": "^8.18.3"
"@push.rocks/smarttime": "^4.2.3",
"ws": "^8.20.0"
},
"devDependencies": {
"@git.zone/tsbuild": "^3.1.2",
"@git.zone/tsbundle": "^2.6.3",
"@git.zone/tsrun": "^2.0.0",
"@git.zone/tstest": "^3.1.3",
"@push.rocks/smartserve": "^1.1.2",
"@types/node": "^24.10.1",
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsbundle": "^2.10.1",
"@git.zone/tsrun": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@push.rocks/smartserve": "^2.0.4",
"@types/node": "^25.6.0",
"@types/ws": "^8.18.1"
},
"private": false,
@@ -53,6 +53,8 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
],
@@ -71,5 +73,6 @@
"function routing",
"secure",
"rpc"
]
],
"packageManager": "pnpm@10.28.2"
}
+2228 -1917
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -81,6 +81,9 @@ tap.test('should be able to tag a connection from client', async (tools) => {
return true;
})
.getTagById('awesome');
if (!tagOnServerSide) {
throw new Error('Expected server-side tag awesome to exist');
}
expect(tagOnServerSide.payload).toEqual('yes');
});
@@ -93,7 +96,13 @@ tap.test('should be able to tag a connection from server', async (tools) => {
id: 'awesome2',
payload: 'absolutely',
});
if (!testSmartsocketClient.socketConnection) {
throw new Error('Expected client socket connection to exist');
}
const tagOnClientSide = await testSmartsocketClient.socketConnection.getTagById('awesome2');
if (!tagOnClientSide) {
throw new Error('Expected client-side tag awesome2 to exist');
}
expect(tagOnClientSide.payload).toEqual('absolutely');
});
@@ -142,6 +151,9 @@ tap.test('should be able to locate a connection tag after reconnect', async (too
return true;
})
.getTagById('awesome');
if (!tagOnServerSide) {
throw new Error('Expected server-side tag awesome to exist after reconnect');
}
expect(tagOnServerSide.payload).toEqual('yes');
});
+12
View File
@@ -81,6 +81,9 @@ tap.test('should be able to tag a connection from client', async (tools) => {
return true;
})
.getTagById('awesome');
if (!tagOnServerSide) {
throw new Error('Expected server-side tag awesome to exist');
}
expect(tagOnServerSide.payload).toEqual('yes');
});
@@ -93,7 +96,13 @@ tap.test('should be able to tag a connection from server', async (tools) => {
id: 'awesome2',
payload: 'absolutely',
});
if (!testSmartsocketClient.socketConnection) {
throw new Error('Expected client socket connection to exist');
}
const tagOnClientSide = await testSmartsocketClient.socketConnection.getTagById('awesome2');
if (!tagOnClientSide) {
throw new Error('Expected client-side tag awesome2 to exist');
}
expect(tagOnClientSide.payload).toEqual('absolutely');
});
@@ -135,6 +144,9 @@ tap.test('should be able to locate a connection tag after reconnect', async (too
return true;
})
.getTagById('awesome');
if (!tagOnServerSide) {
throw new Error('Expected server-side tag awesome to exist after reconnect');
}
expect(tagOnServerSide.payload).toEqual('yes');
});
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartsocket',
version: '4.0.0',
version: '4.0.1',
description: 'Provides easy and secure websocket communication mechanisms, including server and client implementation, function call routing, connection management, and tagging.'
}
+14 -10
View File
@@ -28,10 +28,10 @@ export class SmartsocketClient {
public shortId = plugins.isounique.uni();
// the shortId of the remote we connect to
public remoteShortId: string = null;
public remoteShortId: string | null = null;
public alias: string;
public socketConnection: SocketConnection;
public socketConnection?: SocketConnection;
public serverUrl: string;
public serverPort: number;
public autoReconnect: boolean;
@@ -50,7 +50,7 @@ export class SmartsocketClient {
// tagStore
private tagStore: { [key: string]: interfaces.ITag } = {};
private tagStoreSubscription: plugins.smartrx.rxjs.Subscription;
private tagStoreSubscription?: plugins.smartrx.rxjs.Subscription;
/**
* adds a tag to a connection
@@ -86,7 +86,7 @@ export class SmartsocketClient {
this.alias = optionsArg.alias;
this.serverUrl = optionsArg.url;
this.serverPort = optionsArg.port;
this.autoReconnect = optionsArg.autoReconnect;
this.autoReconnect = optionsArg.autoReconnect ?? false;
this.maxRetries = optionsArg.maxRetries ?? 100; // Default to 100 retries
this.initialBackoffDelay = optionsArg.initialBackoffDelay ?? 1000; // Default to 1 second
this.maxBackoffDelay = optionsArg.maxBackoffDelay ?? 60000; // Default to 1 minute
@@ -148,6 +148,7 @@ export class SmartsocketClient {
smartsocketHost: this,
socket: socket as any,
});
const socketConnection = this.socketConnection;
// Increment attempt ID to invalidate any pending timers from previous attempts
this.connectionAttemptId++;
@@ -183,7 +184,7 @@ export class SmartsocketClient {
this.remoteShortId = authRequestPayload.serverAlias;
// Send authentication data
this.socketConnection.sendMessage({
socketConnection.sendMessage({
type: 'auth',
payload: { alias: this.alias },
});
@@ -193,7 +194,7 @@ export class SmartsocketClient {
const authResponse = message.payload as interfaces.IAuthResponsePayload;
if (authResponse.success) {
logger.log('info', 'client is authenticated');
this.socketConnection.authenticated = true;
socketConnection.authenticated = true;
} else {
logger.log('warn', `authentication failed: ${authResponse.error}`);
await this.disconnect();
@@ -202,15 +203,15 @@ export class SmartsocketClient {
case 'serverReady':
// Set up function request listening
await this.socketConnection.listenToFunctionRequests();
await socketConnection.listenToFunctionRequests();
// Handle retagging
const oldTagStore = this.tagStore;
this.tagStoreSubscription?.unsubscribe();
for (const keyArg of Object.keys(this.tagStore)) {
this.socketConnection.addTag(this.tagStore[keyArg]);
socketConnection.addTag(this.tagStore[keyArg]);
}
this.tagStoreSubscription = this.socketConnection.tagStoreObservable.subscribe(
this.tagStoreSubscription = socketConnection.tagStoreObservable.subscribe(
(tagStoreArg) => {
this.tagStore = tagStoreArg;
}
@@ -226,7 +227,7 @@ export class SmartsocketClient {
default:
// Other messages are handled by SocketConnection
this.socketConnection.handleMessage(message);
socketConnection.handleMessage(message);
break;
}
} catch (err) {
@@ -341,6 +342,9 @@ export class SmartsocketClient {
functionNameArg: T['method'],
dataArg: T['request']
): Promise<T['response']> {
if (!this.socketConnection) {
throw new Error('Cannot call server without an active socket connection');
}
const socketRequest = new SocketRequest<T>(this, {
side: 'requesting',
originSocketConnection: this.socketConnection,
+10 -2
View File
@@ -22,7 +22,7 @@ export type TSocketConnectionSide = 'server' | 'client';
* interface for constructor of class SocketConnection
*/
export interface ISocketConnectionConstructorOptions {
alias: string;
alias?: string;
authenticated: boolean;
side: TSocketConnectionSide;
smartsocketHost: Smartsocket | SmartsocketClient;
@@ -43,7 +43,7 @@ export let allSocketConnections = new plugins.lik.ObjectMap<SocketConnection>();
* class SocketConnection represents a websocket connection
*/
export class SocketConnection {
public alias: string;
public alias?: string;
public side: TSocketConnectionSide;
public authenticated: boolean = false;
public smartsocketRef: Smartsocket | SmartsocketClient;
@@ -97,6 +97,10 @@ export class SocketConnection {
}
private handleFunctionCall(messageData: interfaces.ISocketMessage<interfaces.IFunctionCallPayload>): void {
if (!messageData.id) {
logger.log('warn', 'received function call without request id');
return;
}
const requestData: ISocketRequestDataObject<any> = {
funcCallData: {
funcName: messageData.payload.funcName,
@@ -124,6 +128,10 @@ export class SocketConnection {
}
private handleFunctionResponse(messageData: interfaces.ISocketMessage<interfaces.IFunctionCallPayload>): void {
if (!messageData.id) {
logger.log('warn', 'received function response without request id');
return;
}
const responseData: ISocketRequestDataObject<any> = {
funcCallData: {
funcName: messageData.payload.funcName,
+1 -1
View File
@@ -27,7 +27,7 @@ export interface ISocketRequestConstructorOptions<
side: TSocketRequestSide;
originSocketConnection: SocketConnection;
shortId: string;
funcCallData?: ISocketFunctionCallDataRequest<T>;
funcCallData: ISocketFunctionCallDataRequest<T>;
}
/**
+8 -6
View File
@@ -11,8 +11,8 @@ import { logger } from './smartsocket.logging.js';
*/
export class SocketServer {
private smartsocket: Smartsocket;
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server;
private wsServer: pluginsTyped.ws.WebSocketServer;
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server | null = null;
private wsServer: pluginsTyped.ws.WebSocketServer | null = null;
/**
* whether httpServer is standalone (created by us)
@@ -38,17 +38,19 @@ export class SocketServer {
const httpModule = await this.smartsocket.smartenv.getSafeNodeModule('http');
const wsModule = await this.smartsocket.smartenv.getSafeNodeModule('ws');
this.httpServer = httpModule.createServer();
const httpServer = httpModule.createServer();
this.httpServer = httpServer;
this.standaloneServer = true;
// Create WebSocket server attached to HTTP server
this.wsServer = new wsModule.WebSocketServer({ server: this.httpServer });
const wsServer = new wsModule.WebSocketServer({ server: httpServer });
this.wsServer = wsServer;
this.wsServer.on('connection', (ws: pluginsTyped.ws.WebSocket) => {
wsServer.on('connection', (ws: pluginsTyped.ws.WebSocket) => {
this.smartsocket.handleNewConnection(ws);
});
this.httpServer.listen(this.smartsocket.options.port, () => {
httpServer.listen(this.smartsocket.options.port, () => {
logger.log(
'success',
`Server started in standalone mode on port ${this.smartsocket.options.port}`
+4 -4
View File
@@ -5,10 +5,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"
]
"exclude": ["dist_*/**/*.d.ts"]
}