From c520d5befafcfa50058c7aad04fc710d30624e7b Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 15 Mar 2019 11:32:11 -0700 Subject: [PATCH 1/2] Export missing types, fix a couple of incorrect types --- packages/grpc-js/src/client.ts | 11 ++++---- packages/grpc-js/src/index.ts | 47 ++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/packages/grpc-js/src/client.ts b/packages/grpc-js/src/client.ts index 7381f4da..981d1c87 100644 --- a/packages/grpc-js/src/client.ts +++ b/packages/grpc-js/src/client.ts @@ -18,7 +18,8 @@ export interface UnaryCallback { export interface CallOptions { deadline?: Deadline; host?: string; - parent?: Call; + /* There should be a parent option here that will accept a server call, + * but the server is not yet implemented so it makes no sense to have it */ propagate_flags?: number; credentials?: CallCredentials; } @@ -171,7 +172,7 @@ export class Client { this.checkOptionalUnaryResponseArguments( metadata, options, callback)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, options.parent, + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); @@ -213,7 +214,7 @@ export class Client { this.checkOptionalUnaryResponseArguments( metadata, options, callback)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, options.parent, + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); @@ -262,7 +263,7 @@ export class Client { options?: CallOptions): ClientReadableStream { ({metadata, options} = this.checkMetadataAndOptions(metadata, options)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, options.parent, + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); @@ -290,7 +291,7 @@ export class Client { options?: CallOptions): ClientDuplexStream { ({metadata, options} = this.checkMetadataAndOptions(metadata, options)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, options.parent, + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); diff --git a/packages/grpc-js/src/index.ts b/packages/grpc-js/src/index.ts index 1208dc4b..11cf4708 100644 --- a/packages/grpc-js/src/index.ts +++ b/packages/grpc-js/src/index.ts @@ -1,14 +1,16 @@ import * as semver from 'semver'; import {CallCredentials} from './call-credentials'; -import {Channel} from './channel'; +import {Channel, Http2Channel, ConnectivityState} from './channel'; import {ChannelCredentials} from './channel-credentials'; -import {Client} from './client'; +import {Client, CallOptions} from './client'; import {LogVerbosity, Status} from './constants'; import * as logging from './logging'; -import {loadPackageDefinition, makeClientConstructor} from './make-client'; +import {loadPackageDefinition, makeClientConstructor, Serialize, Deserialize} from './make-client'; import {Metadata} from './metadata'; import {StatusBuilder} from './status-builder'; +import { Deadline, StatusObject } from './call-stream'; +import { ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream } from './call'; const supportedNodeVersions = '^8.11.2 || >=9.4'; if (!semver.satisfies(process.version, supportedNodeVersions)) { @@ -121,7 +123,8 @@ export {Metadata}; export { LogVerbosity as logVerbosity, - Status as status + Status as status, + ConnectivityState as connectivityState // TODO: Other constants as well }; @@ -132,7 +135,7 @@ export { loadPackageDefinition, makeClientConstructor, makeClientConstructor as makeGenericClientConstructor, - Channel + Http2Channel as Channel }; /** @@ -146,6 +149,40 @@ export const waitForClientReady = callback: (error?: Error) => void) => client.waitForReady(deadline, callback); +/* Interfaces */ + +export { + ChannelCredentials, + CallCredentials, + Deadline, + Serialize as serialize, + Deserialize as deserialize, + ClientUnaryCall, + ClientReadableStream, + ClientWritableStream, + ClientDuplexStream, + CallOptions, + StatusObject +} + +export type Call = + ClientUnaryCall | + ClientReadableStream | + ClientWritableStream | + ClientDuplexStream; + +export type MetadataListener = (metadata: Metadata, next: Function) => void; + +export type MessageListener = (message: any, next: Function) => void; + +export type StatusListener = (status: StatusObject, next: Function) => void; + +export interface Listener { + onReceiveMetadata?: MetadataListener; + onReceiveMessage?: MessageListener; + onReceiveStatus?: StatusListener; +} + /**** Unimplemented function stubs ****/ /* tslint:disable:no-any variable-name */ From e0a472d9dfe12d8279c1a045b8258edc66149cc1 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 15 Mar 2019 12:09:19 -0700 Subject: [PATCH 2/2] Fix lint errors --- packages/grpc-js/src/client.ts | 12 ++++-------- packages/grpc-js/src/index.ts | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/packages/grpc-js/src/client.ts b/packages/grpc-js/src/client.ts index 981d1c87..a9b99041 100644 --- a/packages/grpc-js/src/client.ts +++ b/packages/grpc-js/src/client.ts @@ -172,8 +172,7 @@ export class Client { this.checkOptionalUnaryResponseArguments( metadata, options, callback)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, null, - options.propagate_flags); + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); } @@ -214,8 +213,7 @@ export class Client { this.checkOptionalUnaryResponseArguments( metadata, options, callback)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, null, - options.propagate_flags); + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); } @@ -263,8 +261,7 @@ export class Client { options?: CallOptions): ClientReadableStream { ({metadata, options} = this.checkMetadataAndOptions(metadata, options)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, null, - options.propagate_flags); + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); } @@ -291,8 +288,7 @@ export class Client { options?: CallOptions): ClientDuplexStream { ({metadata, options} = this.checkMetadataAndOptions(metadata, options)); const call: Call = this[kChannel].createCall( - method, options.deadline, options.host, null, - options.propagate_flags); + method, options.deadline, options.host, null, options.propagate_flags); if (options.credentials) { call.setCredentials(options.credentials); } diff --git a/packages/grpc-js/src/index.ts b/packages/grpc-js/src/index.ts index 11cf4708..d1125c38 100644 --- a/packages/grpc-js/src/index.ts +++ b/packages/grpc-js/src/index.ts @@ -1,16 +1,16 @@ import * as semver from 'semver'; +import {ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream} from './call'; import {CallCredentials} from './call-credentials'; -import {Channel, Http2Channel, ConnectivityState} from './channel'; +import {Deadline, StatusObject} from './call-stream'; +import {Channel, ConnectivityState, Http2Channel} from './channel'; import {ChannelCredentials} from './channel-credentials'; -import {Client, CallOptions} from './client'; +import {CallOptions, Client} from './client'; import {LogVerbosity, Status} from './constants'; import * as logging from './logging'; -import {loadPackageDefinition, makeClientConstructor, Serialize, Deserialize} from './make-client'; +import {Deserialize, loadPackageDefinition, makeClientConstructor, Serialize} from './make-client'; import {Metadata} from './metadata'; import {StatusBuilder} from './status-builder'; -import { Deadline, StatusObject } from './call-stream'; -import { ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream } from './call'; const supportedNodeVersions = '^8.11.2 || >=9.4'; if (!semver.satisfies(process.version, supportedNodeVersions)) { @@ -163,16 +163,16 @@ export { ClientDuplexStream, CallOptions, StatusObject -} +}; -export type Call = - ClientUnaryCall | - ClientReadableStream | - ClientWritableStream | - ClientDuplexStream; +/* tslint:disable:no-any */ +export type Call = ClientUnaryCall|ClientReadableStream| + ClientWritableStream|ClientDuplexStream; +/* tslint:enable:no-any */ export type MetadataListener = (metadata: Metadata, next: Function) => void; +// tslint:disable-next-line:no-any export type MessageListener = (message: any, next: Function) => void; export type StatusListener = (status: StatusObject, next: Function) => void;