Export missing types, fix a couple of incorrect types

This commit is contained in:
murgatroid99 2019-03-15 11:32:11 -07:00
parent 9bbe7057b5
commit c520d5befa
2 changed files with 48 additions and 10 deletions

View File

@ -18,7 +18,8 @@ export interface UnaryCallback<ResponseType> {
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<ResponseType>(
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<ResponseType>(
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<ResponseType> {
({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<RequestType, ResponseType> {
({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);

View File

@ -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<any> |
ClientWritableStream<any> |
ClientDuplexStream<any, any>;
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 */