Compare commits

..

No commits in common. "e15ce1f0a0f8dc0ef083e3ac1eb0e162bcffc295" and "f401d58f078a4dbd0befc5e2fba4b22e7dee86da" have entirely different histories.

4 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/jrpcgen", "name": "@hibas123/jrpcgen",
"version": "1.2.16", "version": "1.2.14",
"main": "lib/index.js", "main": "lib/index.js",
"license": "MIT", "license": "MIT",
"packageManager": "yarn@3.1.1", "packageManager": "yarn@3.1.1",
@ -48,4 +48,4 @@
"dependencies": { "dependencies": {
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
} }
} }

View File

@ -33,7 +33,7 @@ export class TypescriptTarget extends CompileTarget {
} }
private generateImport(imports: string, path: string) { private generateImport(imports: string, path: string) {
return `import ${imports} from "${path + (this.flavour === "esm" ? ".js" : "") return `import ${imports} from "${path + (this.flavour === "esm" ? ".ts" : "")
}";\n`; }";\n`;
} }
@ -207,7 +207,7 @@ export class TypescriptTarget extends CompileTarget {
this.writeFormattedFile( this.writeFormattedFile(
"service_client.ts", "service_client.ts",
this.generateImport( this.generateImport(
"{ type RequestObject, type ResponseObject, ErrorCodes, Logging }", "{ RequestObject, ResponseObject, ErrorCodes, Logging }",
"./service_base" "./service_base"
) + ) +
this.generateImport(" { VerificationError }", "./ts_base") + this.generateImport(" { VerificationError }", "./ts_base") +
@ -304,7 +304,7 @@ export class TypescriptTarget extends CompileTarget {
this.writeFormattedFile( this.writeFormattedFile(
"service_server.ts", "service_server.ts",
this.generateImport( this.generateImport(
"{ type RequestObject, type ResponseObject, ErrorCodes, Logging }", "{ RequestObject, ResponseObject, ErrorCodes, Logging }",
"./service_base" "./service_base"
) + ) +
this.generateImport(" { VerificationError }", "./ts_base") + this.generateImport(" { VerificationError }", "./ts_base") +

View File

@ -1,3 +1,5 @@
import { isGeneratorFunction } from "util/types";
function form_verficiation_error_message(type?: string, field?: string) { function form_verficiation_error_message(type?: string, field?: string) {
let msg = "Parameter verification failed! "; let msg = "Parameter verification failed! ";
if (type && field) { if (type && field) {

View File

@ -1,14 +1,14 @@
//@template-ignore //@template-ignore
import { VerificationError } from "./ts_base"; import { VerificationError } from "./ts_base";
//@template-ignore //@template-ignore
import { type RequestObject, type ResponseObject, ErrorCodes, Logging } from "./ts_service_base"; import { RequestObject, ResponseObject, ErrorCodes, Logging } from "./ts_service_base";
export class Service<T> { export class Service<T> {
public name: string = null as any; public name: string = null as any;
public functions = new Set<string>(); public functions = new Set<string>();
constructor() { } constructor() {}
} }
type ISendMessageCB = (data: any, catchedErr?: Error) => void; type ISendMessageCB = (data: any, catchedErr?: Error) => void;
@ -37,7 +37,7 @@ class Session<T> {
this.ctx = ctx || {}; this.ctx = ctx || {};
} }
send(data: any, catchedErr?: Error) { send(data: any, catchedErr?:Error) {
Logging.log("SERVER: Sending Message", data) Logging.log("SERVER: Sending Message", data)
this._send(data, catchedErr); this._send(data, catchedErr);
} }
@ -95,7 +95,7 @@ class Session<T> {
} }
let result = await (service as any)["_" + fncName](data.params, this.ctx); let result = await (service as any)["_" + fncName](data.params, this.ctx);
if (data.id) { //Request if(data.id) { //Request
this.send({ this.send({
jsonrpc: "2.0", jsonrpc: "2.0",
id: data.id, id: data.id,