Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 899a46f9de | |||
| 1412a06f4c | |||
| 51e6c5cf0e | |||
| 8d7eb3ff5f | |||
| a82f8ccc26 | |||
| d934f4b53b | |||
| 54b8a692ba | |||
| 2f39b5662d | |||
| 5b9e785159 | |||
| a5bca90eeb | |||
| 244016faed | |||
| 61719769a0 | |||
| 6e2855cf3c | |||
| 916052ef0b | |||
| 2f51e10fc4 |
24659
package-lock.json
generated
24659
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"name": "@apiglobal/typedsocket",
|
||||
"version": "1.0.25",
|
||||
"version": "2.0.5",
|
||||
"private": false,
|
||||
"description": "a typedrequest extension supporting websockets",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.29",
|
||||
"@gitzone/tsbundle": "^1.0.88",
|
||||
"@gitzone/tstest": "^1.0.60",
|
||||
"@pushrocks/tapbundle": "^3.2.15",
|
||||
"@types/node": "^17.0.10",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsbundle": "^2.0.6",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/smartenv": "^5.0.2",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.65",
|
||||
"@apiglobal/typedrequest": "^2.0.8",
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||
"@pushrocks/isohash": "^1.0.2",
|
||||
"@pushrocks/smartsocket": "^1.2.22",
|
||||
"@pushrocks/smartstring": "^3.0.24"
|
||||
"@pushrocks/isohash": "^2.0.0",
|
||||
"@pushrocks/smartsocket": "^2.0.7",
|
||||
"@pushrocks/smartstring": "^4.0.2"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as typedsocket from '../ts/index';
|
||||
import * as typedsocket from '../ts/index.js';
|
||||
|
||||
tap.test('should create a client', async () => {
|
||||
console.log('Browser test') // TODO: implement browser tests
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||
|
||||
import * as typedsocket from '../ts/index';
|
||||
import * as typedsocket from '../ts/index.js';
|
||||
|
||||
interface IRequest_Client_Server extends typedrequestInterfaces.implementsTR<
|
||||
typedrequestInterfaces.ITypedRequest,
|
||||
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedsocket',
|
||||
version: '2.0.5',
|
||||
description: 'a typedrequest extension supporting websockets'
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export * from './typedsocket.classes.typedsocket';
|
||||
export * from './typedsocket.classes.typedsocket.js';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as plugins from './typedsocket.plugins';
|
||||
import * as plugins from './typedsocket.plugins.js';
|
||||
|
||||
const publicRoleName = 'publicRoleName';
|
||||
const publicRolePass = 'publicRolePass';
|
||||
|
||||
export type TTypedSocketSide = 'server' | 'client';
|
||||
export type TTypedSocketSide = 'server' | 'client';
|
||||
|
||||
export class TypedSocket {
|
||||
// STATIC
|
||||
@@ -11,7 +11,7 @@ export class TypedSocket {
|
||||
* creates a typedsocket server
|
||||
* note: this will fail in browser environments as server libs are not bundled.
|
||||
*/
|
||||
public static async createServer(
|
||||
public static async createServer (
|
||||
typedrouterArg: plugins.typedrequest.TypedRouter,
|
||||
smartexpressServerArg?: any
|
||||
): Promise<TypedSocket> {
|
||||
@@ -22,7 +22,7 @@ export class TypedSocket {
|
||||
if (smartexpressServerArg) {
|
||||
smartsocketServer.setExternalServer('smartexpress', smartexpressServerArg);
|
||||
}
|
||||
|
||||
|
||||
smartsocketServer.socketFunctions.add(
|
||||
new plugins.smartsocket.SocketFunction({
|
||||
funcName: 'processMessage',
|
||||
@@ -34,7 +34,7 @@ export class TypedSocket {
|
||||
const typedsocket = new TypedSocket(
|
||||
'server',
|
||||
typedrouterArg,
|
||||
async <T extends plugins.typedrequestInterfaces.ITypedRequest>(
|
||||
async <T extends plugins.typedrequestInterfaces.ITypedRequest> (
|
||||
dataArg: T,
|
||||
targetConnectionArg?: plugins.smartsocket.SocketConnection
|
||||
): Promise<T> => {
|
||||
@@ -43,7 +43,7 @@ export class TypedSocket {
|
||||
console.log(
|
||||
'Since no targetConnection was supplied and there is only one active one present, choosing that one automatically'
|
||||
);
|
||||
targetConnectionArg = smartsocketServer.socketConnections.getArray()[0];
|
||||
targetConnectionArg = smartsocketServer.socketConnections.getArray()[ 0 ];
|
||||
} else {
|
||||
throw new Error('you need to specify the wanted targetConnection. Currently no target is selectable automatically.');
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export class TypedSocket {
|
||||
return typedsocket;
|
||||
}
|
||||
|
||||
public static async createClient(
|
||||
public static async createClient (
|
||||
typedrouterArg: plugins.typedrequest.TypedRouter,
|
||||
serverUrlArg: string,
|
||||
aliasArg = 'clientArg'
|
||||
@@ -89,7 +89,7 @@ export class TypedSocket {
|
||||
const typedsocket = new TypedSocket(
|
||||
'client',
|
||||
typedrouterArg,
|
||||
async <T extends plugins.typedrequestInterfaces.ITypedRequest>(dataArg: T): Promise<T> => {
|
||||
async <T extends plugins.typedrequestInterfaces.ITypedRequest> (dataArg: T): Promise<T> => {
|
||||
const response: T = (smartsocketClient.serverCall('processMessage', dataArg) as any) as T;
|
||||
return response;
|
||||
},
|
||||
@@ -122,7 +122,7 @@ export class TypedSocket {
|
||||
this.socketServerOrClient = socketServerOrClientArg;
|
||||
}
|
||||
|
||||
public addTag(keyArg: string, payloadArg: any) {
|
||||
public addTag (keyArg: string, payloadArg: any) {
|
||||
if (this.side === 'client' && this.socketServerOrClient instanceof plugins.smartsocket.SmartsocketClient) {
|
||||
this.socketServerOrClient.socketConnection.addTag({
|
||||
id: keyArg,
|
||||
@@ -133,8 +133,8 @@ export class TypedSocket {
|
||||
}
|
||||
}
|
||||
|
||||
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(
|
||||
methodName: T['method'],
|
||||
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest> (
|
||||
methodName: T[ 'method' ],
|
||||
targetConnection?: plugins.smartsocket.SocketConnection
|
||||
): plugins.typedrequest.TypedRequest<T> {
|
||||
const typedrequest = new plugins.typedrequest.TypedRequest<T>(
|
||||
@@ -154,7 +154,7 @@ export class TypedSocket {
|
||||
* @param asyncFindFuncArg
|
||||
* @returns
|
||||
*/
|
||||
public async findAllTargetConnections(
|
||||
public async findAllTargetConnections (
|
||||
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
|
||||
) {
|
||||
if (this.socketServerOrClient instanceof plugins.smartsocket.Smartsocket) {
|
||||
@@ -175,31 +175,31 @@ export class TypedSocket {
|
||||
* @param asyncFindFuncArg
|
||||
* @returns
|
||||
*/
|
||||
public async findTargetConnection(
|
||||
public async findTargetConnection (
|
||||
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
|
||||
) {
|
||||
const allMatching = await this.findAllTargetConnections(asyncFindFuncArg);
|
||||
return allMatching[0];
|
||||
return allMatching[ 0 ];
|
||||
}
|
||||
|
||||
public async findAllTargetConnectionsByTag(keyArg: string, payloadArg?: any) {
|
||||
public async findAllTargetConnectionsByTag (keyArg: string, payloadArg?: any) {
|
||||
return this.findAllTargetConnections(async socketConnectionArg => {
|
||||
let result: boolean;
|
||||
if (!payloadArg) {
|
||||
result = !!(await socketConnectionArg.getTagById(keyArg));
|
||||
} else {
|
||||
result = !!(await socketConnectionArg.getTagById(keyArg)) === payloadArg;
|
||||
result = !!((await socketConnectionArg.getTagById(keyArg))?.payload === payloadArg);
|
||||
}
|
||||
return result;
|
||||
})
|
||||
}
|
||||
|
||||
public async findTargetConnectionByTag(keyArg: string, payloadArg?: any) {
|
||||
public async findTargetConnectionByTag (keyArg: string, payloadArg?: any) {
|
||||
const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg)
|
||||
return allResults[0];
|
||||
return allResults[ 0 ];
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
public async stop () {
|
||||
await this.socketServerOrClient.stop()
|
||||
}
|
||||
}
|
||||
|
||||
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
Reference in New Issue
Block a user