Skip to content

Commit 3ae5fdd

Browse files
authored
Merge pull request #787 from murgatroid99/grpc-js_missing_types
Export missing types, fix a couple of incorrect types
2 parents 1ce091d + e0a472d commit 3ae5fdd

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

packages/grpc-js/src/client.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export interface UnaryCallback<ResponseType> {
3535
export interface CallOptions {
3636
deadline?: Deadline;
3737
host?: string;
38-
parent?: Call;
38+
/* There should be a parent option here that will accept a server call,
39+
* but the server is not yet implemented so it makes no sense to have it */
3940
propagate_flags?: number;
4041
credentials?: CallCredentials;
4142
}
@@ -188,8 +189,7 @@ export class Client {
188189
this.checkOptionalUnaryResponseArguments<ResponseType>(
189190
metadata, options, callback));
190191
const call: Call = this[kChannel].createCall(
191-
method, options.deadline, options.host, options.parent,
192-
options.propagate_flags);
192+
method, options.deadline, options.host, null, options.propagate_flags);
193193
if (options.credentials) {
194194
call.setCredentials(options.credentials);
195195
}
@@ -230,8 +230,7 @@ export class Client {
230230
this.checkOptionalUnaryResponseArguments<ResponseType>(
231231
metadata, options, callback));
232232
const call: Call = this[kChannel].createCall(
233-
method, options.deadline, options.host, options.parent,
234-
options.propagate_flags);
233+
method, options.deadline, options.host, null, options.propagate_flags);
235234
if (options.credentials) {
236235
call.setCredentials(options.credentials);
237236
}
@@ -279,8 +278,7 @@ export class Client {
279278
options?: CallOptions): ClientReadableStream<ResponseType> {
280279
({metadata, options} = this.checkMetadataAndOptions(metadata, options));
281280
const call: Call = this[kChannel].createCall(
282-
method, options.deadline, options.host, options.parent,
283-
options.propagate_flags);
281+
method, options.deadline, options.host, null, options.propagate_flags);
284282
if (options.credentials) {
285283
call.setCredentials(options.credentials);
286284
}
@@ -307,8 +305,7 @@ export class Client {
307305
options?: CallOptions): ClientDuplexStream<RequestType, ResponseType> {
308306
({metadata, options} = this.checkMetadataAndOptions(metadata, options));
309307
const call: Call = this[kChannel].createCall(
310-
method, options.deadline, options.host, options.parent,
311-
options.propagate_flags);
308+
method, options.deadline, options.host, null, options.propagate_flags);
312309
if (options.credentials) {
313310
call.setCredentials(options.credentials);
314311
}

packages/grpc-js/src/index.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
import * as semver from 'semver';
1919

20+
import {ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream} from './call';
2021
import {CallCredentials} from './call-credentials';
21-
import {Channel} from './channel';
22+
import {Deadline, StatusObject} from './call-stream';
23+
import {Channel, ConnectivityState, Http2Channel} from './channel';
2224
import {ChannelCredentials} from './channel-credentials';
23-
import {Client} from './client';
25+
import {CallOptions, Client} from './client';
2426
import {LogVerbosity, Status} from './constants';
2527
import * as logging from './logging';
26-
import {loadPackageDefinition, makeClientConstructor} from './make-client';
28+
import {Deserialize, loadPackageDefinition, makeClientConstructor, Serialize} from './make-client';
2729
import {Metadata} from './metadata';
2830
import {StatusBuilder} from './status-builder';
2931

@@ -138,7 +140,8 @@ export {Metadata};
138140

139141
export {
140142
LogVerbosity as logVerbosity,
141-
Status as status
143+
Status as status,
144+
ConnectivityState as connectivityState
142145
// TODO: Other constants as well
143146
};
144147

@@ -149,7 +152,7 @@ export {
149152
loadPackageDefinition,
150153
makeClientConstructor,
151154
makeClientConstructor as makeGenericClientConstructor,
152-
Channel
155+
Http2Channel as Channel
153156
};
154157

155158
/**
@@ -163,6 +166,40 @@ export const waitForClientReady =
163166
callback: (error?: Error) => void) =>
164167
client.waitForReady(deadline, callback);
165168

169+
/* Interfaces */
170+
171+
export {
172+
ChannelCredentials,
173+
CallCredentials,
174+
Deadline,
175+
Serialize as serialize,
176+
Deserialize as deserialize,
177+
ClientUnaryCall,
178+
ClientReadableStream,
179+
ClientWritableStream,
180+
ClientDuplexStream,
181+
CallOptions,
182+
StatusObject
183+
};
184+
185+
/* tslint:disable:no-any */
186+
export type Call = ClientUnaryCall|ClientReadableStream<any>|
187+
ClientWritableStream<any>|ClientDuplexStream<any, any>;
188+
/* tslint:enable:no-any */
189+
190+
export type MetadataListener = (metadata: Metadata, next: Function) => void;
191+
192+
// tslint:disable-next-line:no-any
193+
export type MessageListener = (message: any, next: Function) => void;
194+
195+
export type StatusListener = (status: StatusObject, next: Function) => void;
196+
197+
export interface Listener {
198+
onReceiveMetadata?: MetadataListener;
199+
onReceiveMessage?: MessageListener;
200+
onReceiveStatus?: StatusListener;
201+
}
202+
166203
/**** Unimplemented function stubs ****/
167204

168205
/* tslint:disable:no-any variable-name */

0 commit comments

Comments
 (0)