From bec2acaa282130238cd2d91ecfebabca0379a0b2 Mon Sep 17 00:00:00 2001 From: Ivan Zuev Date: Wed, 12 Jan 2022 14:25:18 +0300 Subject: [PATCH] feat: export generic type of wrapped service client --- src/index.ts | 1 + src/session.ts | 4 ++-- src/types.ts | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index f6f36f5b..0bd23339 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,3 +3,4 @@ export * as cloudApi from './generated/yandex/cloud'; export * from './session'; export * from './utils/operation'; export * from './utils/decode-message'; +export { WrappedServiceClientType } from './types'; diff --git a/src/session.ts b/src/session.ts index c9a8fea2..6102c020 100644 --- a/src/session.ts +++ b/src/session.ts @@ -7,7 +7,7 @@ import { GeneratedServiceClientCtor, IamTokenCredentialsConfig, OAuthCredentialsConfig, - ServiceAccountCredentialsConfig, + ServiceAccountCredentialsConfig, WrappedServiceClientType, SessionConfig, } from './types'; import { IamTokenService } from './token-service/iam-token-service'; @@ -94,7 +94,7 @@ export class Session { return this.config.pollInterval; } - client(clientClass: GeneratedServiceClientCtor) { + client(clientClass: GeneratedServiceClientCtor): WrappedServiceClientType { const endpoint = getServiceClientEndpoint(clientClass); const channel = createChannel(endpoint, this.channelCredentials); diff --git a/src/types.ts b/src/types.ts index f9560d51..9ed25f58 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,9 @@ import { ChannelCredentials, ChannelOptions, Client, ServiceDefinition, } from '@grpc/grpc-js'; +import { RawClient } from 'nice-grpc'; +import { NormalizedServiceDefinition } from 'nice-grpc/lib/service-definitions'; +import { DeadlineOptions } from 'nice-grpc-client-middleware-deadline'; export interface TokenService { getToken: () => Promise; @@ -48,3 +51,5 @@ export type SessionConfig = | IamTokenCredentialsConfig | ServiceAccountCredentialsConfig | GenericCredentialsConfig; + +export type WrappedServiceClientType = RawClient, DeadlineOptions>;