@join-com/grpc
Advanced tools
Comparing version 1.0.3 to 2.0.0
export type { IBidiStreamRequest, IClient, IClientStreamRequest, IExtendedClient, IServerStreamRequest, IUnaryRequest, } from './interfaces/IClient'; | ||
export type { IClientConfig } from './interfaces/IClientConfig'; | ||
export type { IClientConfig, ISimplifiedClientConfig, } from './interfaces/IClientConfig'; | ||
export type { IInfoLogger, IErrorLogger, INoDebugLogger, IWarnLogger, } from './interfaces/ILogger'; | ||
@@ -4,0 +4,0 @@ export type { IServer } from './interfaces/IServer'; |
import * as grpc from '@grpc/grpc-js'; | ||
import { CondCapitalize, UncapitalizedMethodNames } from '../types/CapitalizationAdapters'; | ||
import { ObjectWritable } from '@grpc/grpc-js/build/src/object-stream'; | ||
@@ -36,4 +37,2 @@ import { ServerSurfaceCall } from '@grpc/grpc-js/build/src/server-call'; | ||
declare type ExtractResponseType<ServiceImplementationType, MethodName extends keyof ServiceImplementationType> = ServiceImplementationType[MethodName] extends (call: infer CallType, ...args: any[]) => void ? CallType extends ServerSurfaceCall & ObjectWritable<infer ResponseType> ? Exclude<ResponseType, grpc.Metadata | undefined> : ServiceImplementationType[MethodName] extends (call: CallType, callback: grpc.sendUnaryData<infer ResponseType>) => void ? ResponseType : unknown : never; | ||
declare type UncapitalizedMethodNames<ServiceImplementationType> = keyof ServiceImplementationType extends string ? Uncapitalize<keyof ServiceImplementationType> : keyof ServiceImplementationType; | ||
declare type CondCapitalize<S> = S extends string ? Capitalize<S> : S; | ||
export declare type IExtendedClient<ServiceImplementationType = grpc.UntypedServiceImplementation, ServiceNameType extends string = string> = IClient<ServiceImplementationType, ServiceNameType> & { | ||
@@ -40,0 +39,0 @@ [methodName in UncapitalizedMethodNames<ServiceImplementationType>]: CondCapitalize<methodName> extends keyof ServiceImplementationType ? ClientWrappedHandler<ExtractRequestType<ServiceImplementationType[CondCapitalize<methodName>]>, ExtractResponseType<ServiceImplementationType, CondCapitalize<methodName>>> : never; |
@@ -12,2 +12,5 @@ import * as grpc from '@grpc/grpc-js'; | ||
} | ||
export declare type ISimplifiedClientConfig<ServiceImplementationType = grpc.UntypedServiceImplementation> = Omit<IClientConfig<ServiceImplementationType>, 'serviceDefinition' | 'credentials'> & { | ||
credentials?: grpc.ChannelCredentials; | ||
}; | ||
//# sourceMappingURL=IClientConfig.d.ts.map |
import * as grpc from '@grpc/grpc-js'; | ||
import { CondCapitalize, UncapitalizedMethodNames } from './types/CapitalizationAdapters'; | ||
import { INoDebugLogger } from './interfaces/ILogger'; | ||
@@ -8,2 +9,5 @@ import { IServiceMapping } from './interfaces/IServiceMapping'; | ||
export declare type JoinServiceImplementation<ServiceImplementationType = grpc.UntypedServiceImplementation> = { | ||
[methodName in UncapitalizedMethodNames<ServiceImplementationType>]: CondCapitalize<methodName> extends keyof InternalJoinServiceImplementation<ServiceImplementationType> ? InternalJoinServiceImplementation<ServiceImplementationType>[CondCapitalize<methodName>] : never; | ||
}; | ||
export declare type InternalJoinServiceImplementation<ServiceImplementationType = grpc.UntypedServiceImplementation> = { | ||
[Key in keyof ServiceImplementationType]: ServiceImplementationType[Key] extends grpc.handleUnaryCall<infer RequestType, infer ResponseType> ? JoinGrpcHandler<RequestType, ResponseType, undefined, grpc.ServerUnaryCall<RequestType, ResponseType>> : ServiceImplementationType[Key] extends grpc.handleServerStreamingCall<infer RequestType, infer ResponseType> ? JoinGrpcHandler<RequestType, ResponseType, undefined, grpc.ServerWritableStream<RequestType, ResponseType>> : ServiceImplementationType[Key] extends grpc.handleClientStreamingCall<infer RequestType, infer ResponseType> ? JoinGrpcHandler<RequestType, ResponseType, undefined, grpc.ServerReadableStream<RequestType, ResponseType>> : ServiceImplementationType[Key] extends grpc.handleBidiStreamingCall<infer RequestType, infer ResponseType> ? JoinGrpcHandler<RequestType, ResponseType, undefined, grpc.ServerDuplexStream<RequestType, ResponseType>> : JoinGrpcHandler; | ||
@@ -10,0 +14,0 @@ }; |
@@ -33,7 +33,15 @@ "use strict"; | ||
adaptImplementation(promisifiedImplementation) { | ||
const x = Object.entries(promisifiedImplementation).reduce( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
(acc, [name, _]) => { | ||
return { ...acc, [name]: 42 }; | ||
}, {}); | ||
console.log(x); | ||
return Object.entries(promisifiedImplementation).reduce((acc, [name, handler]) => { | ||
var _a, _b; | ||
const capitalizedName = (_b = (_a = name[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : '' + name.slice(1); | ||
// Obtaining definition | ||
const methodDefinition = this.definition[name]; | ||
const methodDefinition = this.definition[capitalizedName]; | ||
if (!methodDefinition) { | ||
throw new Error('Unable to find method definition'); | ||
throw new Error(`Unable to find method definition '${name}'`); | ||
} | ||
@@ -58,3 +66,3 @@ // Inspecting definition | ||
...acc, | ||
[name]: this.wrapWithTrace(newHandler), | ||
[capitalizedName]: this.wrapWithTrace(newHandler), | ||
}; | ||
@@ -61,0 +69,0 @@ }, {}); |
{ | ||
"name": "@join-com/grpc", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "gRPC library", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=14.17.0" | ||
}, | ||
@@ -25,3 +25,3 @@ "main": "./dist/index.js", | ||
"@coderspirit/nominal": "^3.0.0", | ||
"@grpc/grpc-js": "^1.3.0", | ||
"@grpc/grpc-js": "^1.3.2", | ||
"protobufjs": "^6.11.2" | ||
@@ -32,13 +32,13 @@ }, | ||
"@types/node": "^14.14.41", | ||
"@typescript-eslint/eslint-plugin": "^4.22.1", | ||
"@typescript-eslint/parser": "^4.22.1", | ||
"eslint": "^7.25.0", | ||
"@typescript-eslint/eslint-plugin": "^4.27.0", | ||
"@typescript-eslint/parser": "^4.27.0", | ||
"eslint": "^7.28.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-node": "^11.1.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.5.5", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.4" | ||
"jest": "^27.0.4", | ||
"prettier": "^2.3.1", | ||
"ts-jest": "^27.0.3", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.4" | ||
}, | ||
@@ -45,0 +45,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
64044
55
640
Updated@grpc/grpc-js@^1.3.2