diff --git a/javascript/net/grpc/web/genericclient.js b/javascript/net/grpc/web/genericclient.js new file mode 100644 index 000000000..275149ebe --- /dev/null +++ b/javascript/net/grpc/web/genericclient.js @@ -0,0 +1,29 @@ +/** + * @fileoverview base interface for grpc web GenericClient. + */ + +goog.module('grpc.web.GenericClient'); +goog.module.declareLegacyNamespace(); + +const Metadata = goog.require('grpc.web.Metadata'); +const MethodDescriptor = goog.require('grpc.web.MethodDescriptor'); +const UnaryResponse = goog.require('grpc.web.UnaryResponse'); + +/** + * @interface + */ +const GenericClient = function() {}; + + +/** + * @param {!REQUEST} request The request proto message + * @param {!MethodDescriptor} methodDescriptor Information of + * this RPC method + * @param {!Metadata} metadata The user defined request metadata. + * @return {!Promise>} A promise that resolves to the + * response message + * @template REQUEST, RESPONSE + */ +GenericClient.prototype.unaryCall = goog.abstractMethod; + +exports = GenericClient; diff --git a/javascript/net/grpc/web/metadata.js b/javascript/net/grpc/web/metadata.js new file mode 100644 index 000000000..27dcaa555 --- /dev/null +++ b/javascript/net/grpc/web/metadata.js @@ -0,0 +1,15 @@ +/** + * @fileoverview grpc-web request/response metadata. + * + * Request and response headers will be included in the Metadata. + */ + +goog.module('grpc.web.Metadata'); +goog.module.declareLegacyNamespace(); + +/** + * @typedef {!Object} + */ +let Metadata; + +exports = Metadata; diff --git a/javascript/net/grpc/web/unaryresponse.js b/javascript/net/grpc/web/unaryresponse.js new file mode 100644 index 000000000..a17879ba3 --- /dev/null +++ b/javascript/net/grpc/web/unaryresponse.js @@ -0,0 +1,25 @@ +/** + * @fileoverview gRPC web client UnaryResponse returned the by grpc unary calls. + * It consists of response message and response metadata(headers). + */ + +goog.module('grpc.web.UnaryResponse'); +goog.module.declareLegacyNamespace(); + +const Metadata = goog.require('grpc.web.Metadata'); + +/** + * @constructor + * @struct + * @template RESPONSE + * @param {RESPONSE} message + * @param {!Metadata=} metadata + */ +const UnaryResponse = function(message, metadata) { + /** @const {RESPONSE} */ + this.message = message; + /** @const {!Metadata|undefined} */ + this.metadata = metadata; +}; + +exports = UnaryResponse;