From 3c9c1f288aa5719dbd2310a36cb8bd16fb738745 Mon Sep 17 00:00:00 2001 From: LE VAN THANH Date: Tue, 24 Dec 2024 14:17:40 +0700 Subject: [PATCH 1/3] update for build --- .idea/.gitignore | 8 + .idea/grpc-web.iml | 12 + .idea/inspectionProfiles/Project_Default.xml | 10 + .idea/jsLibraryMappings.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 10 + net/grpc/gateway/examples/echo/Taskfile.yaml | 8 + .../echo/ts-example/EchoServiceClientPb.ts | 216 ++++++++++++++++++ .../examples/echo/ts-example/Taskfile.yaml | 18 ++ .../examples/echo/ts-example/client.ts | 4 +- .../examples/echo/ts-example/echo_pb.d.ts | 138 +++++++++++ .../examples/echo/ts-example/package.json | 3 + 12 files changed, 439 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/grpc-web.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 net/grpc/gateway/examples/echo/Taskfile.yaml create mode 100644 net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts create mode 100644 net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml create mode 100644 net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/grpc-web.iml b/.idea/grpc-web.iml new file mode 100644 index 00000000..24643cc3 --- /dev/null +++ b/.idea/grpc-web.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..146ab09b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 00000000..d23208fb --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..f316c489 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..3156a3f2 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/Taskfile.yaml b/net/grpc/gateway/examples/echo/Taskfile.yaml new file mode 100644 index 00000000..6582898c --- /dev/null +++ b/net/grpc/gateway/examples/echo/Taskfile.yaml @@ -0,0 +1,8 @@ +version: '3' + +tasks: + +includes: + docs: + taskfile: ./ts-example/Taskfile.yml + dir: ./ts-example \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts b/net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts new file mode 100644 index 00000000..9fced9b6 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts @@ -0,0 +1,216 @@ +/** + * @fileoverview gRPC-Web generated client stub for grpc.gateway.testing + * @enhanceable + * @public + */ + +// Code generated by protoc-gen-grpc-web. DO NOT EDIT. +// versions: +// protoc-gen-grpc-web v1.5.0 +// protoc v5.29.2 +// source: echo.proto + + +/* eslint-disable */ +// @ts-nocheck + + +import * as grpcWeb from 'grpc-web'; + +import * as echo_pb from './echo_pb'; // proto import: "echo.proto" + + +export class EchoServiceClient { + client_: grpcWeb.AbstractClientBase; + hostname_: string; + credentials_: null | { [index: string]: string; }; + options_: null | { [index: string]: any; }; + + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: any; }) { + if (!options) options = {}; + if (!credentials) credentials = {}; + options['format'] = 'text'; + + this.client_ = new grpcWeb.GrpcWebClientBase(options); + this.hostname_ = hostname.replace(/\/+$/, ''); + this.credentials_ = credentials; + this.options_ = options; + } + + methodDescriptorEcho = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.EchoService/Echo', + grpcWeb.MethodType.UNARY, + echo_pb.EchoRequest, + echo_pb.EchoResponse, + (request: echo_pb.EchoRequest) => { + return request.serializeBinary(); + }, + echo_pb.EchoResponse.deserializeBinary + ); + + echo( + request: echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null): Promise; + + echo( + request: echo_pb.EchoRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.RpcError, + response: echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; + + echo( + request: echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null, + callback?: (err: grpcWeb.RpcError, + response: echo_pb.EchoResponse) => void) { + if (callback !== undefined) { + return this.client_.rpcCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/Echo', + request, + metadata || {}, + this.methodDescriptorEcho, + callback); + } + return this.client_.unaryCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/Echo', + request, + metadata || {}, + this.methodDescriptorEcho); + } + + methodDescriptorEchoAbort = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.EchoService/EchoAbort', + grpcWeb.MethodType.UNARY, + echo_pb.EchoRequest, + echo_pb.EchoResponse, + (request: echo_pb.EchoRequest) => { + return request.serializeBinary(); + }, + echo_pb.EchoResponse.deserializeBinary + ); + + echoAbort( + request: echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null): Promise; + + echoAbort( + request: echo_pb.EchoRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.RpcError, + response: echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; + + echoAbort( + request: echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null, + callback?: (err: grpcWeb.RpcError, + response: echo_pb.EchoResponse) => void) { + if (callback !== undefined) { + return this.client_.rpcCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/EchoAbort', + request, + metadata || {}, + this.methodDescriptorEchoAbort, + callback); + } + return this.client_.unaryCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/EchoAbort', + request, + metadata || {}, + this.methodDescriptorEchoAbort); + } + + methodDescriptorNoOp = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.EchoService/NoOp', + grpcWeb.MethodType.UNARY, + echo_pb.Empty, + echo_pb.Empty, + (request: echo_pb.Empty) => { + return request.serializeBinary(); + }, + echo_pb.Empty.deserializeBinary + ); + + noOp( + request: echo_pb.Empty, + metadata?: grpcWeb.Metadata | null): Promise; + + noOp( + request: echo_pb.Empty, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.RpcError, + response: echo_pb.Empty) => void): grpcWeb.ClientReadableStream; + + noOp( + request: echo_pb.Empty, + metadata?: grpcWeb.Metadata | null, + callback?: (err: grpcWeb.RpcError, + response: echo_pb.Empty) => void) { + if (callback !== undefined) { + return this.client_.rpcCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/NoOp', + request, + metadata || {}, + this.methodDescriptorNoOp, + callback); + } + return this.client_.unaryCall( + this.hostname_ + + '/grpc.gateway.testing.EchoService/NoOp', + request, + metadata || {}, + this.methodDescriptorNoOp); + } + + methodDescriptorServerStreamingEcho = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.EchoService/ServerStreamingEcho', + grpcWeb.MethodType.SERVER_STREAMING, + echo_pb.ServerStreamingEchoRequest, + echo_pb.ServerStreamingEchoResponse, + (request: echo_pb.ServerStreamingEchoRequest) => { + return request.serializeBinary(); + }, + echo_pb.ServerStreamingEchoResponse.deserializeBinary + ); + + serverStreamingEcho( + request: echo_pb.ServerStreamingEchoRequest, + metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { + return this.client_.serverStreaming( + this.hostname_ + + '/grpc.gateway.testing.EchoService/ServerStreamingEcho', + request, + metadata || {}, + this.methodDescriptorServerStreamingEcho); + } + + methodDescriptorServerStreamingEchoAbort = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort', + grpcWeb.MethodType.SERVER_STREAMING, + echo_pb.ServerStreamingEchoRequest, + echo_pb.ServerStreamingEchoResponse, + (request: echo_pb.ServerStreamingEchoRequest) => { + return request.serializeBinary(); + }, + echo_pb.ServerStreamingEchoResponse.deserializeBinary + ); + + serverStreamingEchoAbort( + request: echo_pb.ServerStreamingEchoRequest, + metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { + return this.client_.serverStreaming( + this.hostname_ + + '/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort', + request, + metadata || {}, + this.methodDescriptorServerStreamingEchoAbort); + } + +} + diff --git a/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml new file mode 100644 index 00000000..01d4bcbe --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml @@ -0,0 +1,18 @@ +version: '3' + +tasks: + build: + cmds: + - npx tsc && mv *_pb.js dist/ && npx webpack + genpb-cdts: + cmds: + - > + protoc -I=../ echo.proto \ + --js_out=import_style=commonjs:. \ + --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:. + genpb-ts: + cmds: + - > + protoc -I=../ echo.proto \ + --js_out=import_style=commonjs:. \ + --grpc-web_out=import_style=typescript,mode=grpcwebtext:. \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/ts-example/client.ts b/net/grpc/gateway/examples/echo/ts-example/client.ts index 22f0c559..f92b44c6 100644 --- a/net/grpc/gateway/examples/echo/ts-example/client.ts +++ b/net/grpc/gateway/examples/echo/ts-example/client.ts @@ -21,10 +21,10 @@ import * as $ from 'jquery'; // Uncomment either one of the following: // Option 1: import_style=commonjs+dts -import {EchoServiceClient} from './echo_grpc_web_pb'; +// import {EchoServiceClient} from './echo_grpc_web_pb'; // Option 2: import_style=typescript -// import {EchoServiceClient} from './EchoServiceClientPb'; +import {EchoServiceClient} from './EchoServiceClientPb'; import {EchoRequest, EchoResponse, ServerStreamingEchoRequest, ServerStreamingEchoResponse} from './echo_pb'; diff --git a/net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts b/net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts new file mode 100644 index 00000000..b6dbcc30 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts @@ -0,0 +1,138 @@ +import * as jspb from 'google-protobuf' + + + +export class Empty extends jspb.Message { + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Empty.AsObject; + static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject; + static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Empty; + static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty; +} + +export namespace Empty { + export type AsObject = { + } +} + +export class EchoRequest extends jspb.Message { + getMessage(): string; + setMessage(value: string): EchoRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): EchoRequest.AsObject; + static toObject(includeInstance: boolean, msg: EchoRequest): EchoRequest.AsObject; + static serializeBinaryToWriter(message: EchoRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): EchoRequest; + static deserializeBinaryFromReader(message: EchoRequest, reader: jspb.BinaryReader): EchoRequest; +} + +export namespace EchoRequest { + export type AsObject = { + message: string, + } +} + +export class EchoResponse extends jspb.Message { + getMessage(): string; + setMessage(value: string): EchoResponse; + + getMessageCount(): number; + setMessageCount(value: number): EchoResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): EchoResponse.AsObject; + static toObject(includeInstance: boolean, msg: EchoResponse): EchoResponse.AsObject; + static serializeBinaryToWriter(message: EchoResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): EchoResponse; + static deserializeBinaryFromReader(message: EchoResponse, reader: jspb.BinaryReader): EchoResponse; +} + +export namespace EchoResponse { + export type AsObject = { + message: string, + messageCount: number, + } +} + +export class ServerStreamingEchoRequest extends jspb.Message { + getMessage(): string; + setMessage(value: string): ServerStreamingEchoRequest; + + getMessageCount(): number; + setMessageCount(value: number): ServerStreamingEchoRequest; + + getMessageInterval(): number; + setMessageInterval(value: number): ServerStreamingEchoRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ServerStreamingEchoRequest.AsObject; + static toObject(includeInstance: boolean, msg: ServerStreamingEchoRequest): ServerStreamingEchoRequest.AsObject; + static serializeBinaryToWriter(message: ServerStreamingEchoRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ServerStreamingEchoRequest; + static deserializeBinaryFromReader(message: ServerStreamingEchoRequest, reader: jspb.BinaryReader): ServerStreamingEchoRequest; +} + +export namespace ServerStreamingEchoRequest { + export type AsObject = { + message: string, + messageCount: number, + messageInterval: number, + } +} + +export class ServerStreamingEchoResponse extends jspb.Message { + getMessage(): string; + setMessage(value: string): ServerStreamingEchoResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ServerStreamingEchoResponse.AsObject; + static toObject(includeInstance: boolean, msg: ServerStreamingEchoResponse): ServerStreamingEchoResponse.AsObject; + static serializeBinaryToWriter(message: ServerStreamingEchoResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ServerStreamingEchoResponse; + static deserializeBinaryFromReader(message: ServerStreamingEchoResponse, reader: jspb.BinaryReader): ServerStreamingEchoResponse; +} + +export namespace ServerStreamingEchoResponse { + export type AsObject = { + message: string, + } +} + +export class ClientStreamingEchoRequest extends jspb.Message { + getMessage(): string; + setMessage(value: string): ClientStreamingEchoRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ClientStreamingEchoRequest.AsObject; + static toObject(includeInstance: boolean, msg: ClientStreamingEchoRequest): ClientStreamingEchoRequest.AsObject; + static serializeBinaryToWriter(message: ClientStreamingEchoRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ClientStreamingEchoRequest; + static deserializeBinaryFromReader(message: ClientStreamingEchoRequest, reader: jspb.BinaryReader): ClientStreamingEchoRequest; +} + +export namespace ClientStreamingEchoRequest { + export type AsObject = { + message: string, + } +} + +export class ClientStreamingEchoResponse extends jspb.Message { + getMessageCount(): number; + setMessageCount(value: number): ClientStreamingEchoResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ClientStreamingEchoResponse.AsObject; + static toObject(includeInstance: boolean, msg: ClientStreamingEchoResponse): ClientStreamingEchoResponse.AsObject; + static serializeBinaryToWriter(message: ClientStreamingEchoResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ClientStreamingEchoResponse; + static deserializeBinaryFromReader(message: ClientStreamingEchoResponse, reader: jspb.BinaryReader): ClientStreamingEchoResponse; +} + +export namespace ClientStreamingEchoResponse { + export type AsObject = { + messageCount: number, + } +} + diff --git a/net/grpc/gateway/examples/echo/ts-example/package.json b/net/grpc/gateway/examples/echo/ts-example/package.json index dab31758..f4b4b51d 100644 --- a/net/grpc/gateway/examples/echo/ts-example/package.json +++ b/net/grpc/gateway/examples/echo/ts-example/package.json @@ -1,4 +1,7 @@ { + "scripts": { + "build": "task build" + }, "devDependencies": { "@types/google-protobuf": "~3.15.12", "@types/jquery": "~3.3.6", From c9795bf0d9811a2ba5b7722626aab6510296e6d6 Mon Sep 17 00:00:00 2001 From: LE VAN THANH Date: Tue, 24 Dec 2024 14:37:15 +0700 Subject: [PATCH 2/3] add echo_pb.js --- net/grpc/gateway/examples/echo/Taskfile.yaml | 8 - .../examples/echo/ts-example/Taskfile.yaml | 2 +- .../examples/echo/ts-example/echo_pb.js | 1149 +++++++++++++++++ 3 files changed, 1150 insertions(+), 9 deletions(-) delete mode 100644 net/grpc/gateway/examples/echo/Taskfile.yaml create mode 100644 net/grpc/gateway/examples/echo/ts-example/echo_pb.js diff --git a/net/grpc/gateway/examples/echo/Taskfile.yaml b/net/grpc/gateway/examples/echo/Taskfile.yaml deleted file mode 100644 index 6582898c..00000000 --- a/net/grpc/gateway/examples/echo/Taskfile.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' - -tasks: - -includes: - docs: - taskfile: ./ts-example/Taskfile.yml - dir: ./ts-example \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml index 01d4bcbe..00e85eb0 100644 --- a/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml +++ b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml @@ -3,7 +3,7 @@ version: '3' tasks: build: cmds: - - npx tsc && mv *_pb.js dist/ && npx webpack + - task genpb-ts && npx tsc && cp *_pb.js dist/ && npx webpack genpb-cdts: cmds: - > diff --git a/net/grpc/gateway/examples/echo/ts-example/echo_pb.js b/net/grpc/gateway/examples/echo/ts-example/echo_pb.js new file mode 100644 index 00000000..cf6ccb0c --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/echo_pb.js @@ -0,0 +1,1149 @@ +// source: echo.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); + +goog.exportSymbol('proto.grpc.gateway.testing.ClientStreamingEchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ClientStreamingEchoResponse', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.EchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.EchoResponse', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.Empty', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ServerStreamingEchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ServerStreamingEchoResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.Empty = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.Empty, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.Empty.displayName = 'proto.grpc.gateway.testing.Empty'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.EchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.EchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.EchoRequest.displayName = 'proto.grpc.gateway.testing.EchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.EchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.EchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.EchoResponse.displayName = 'proto.grpc.gateway.testing.EchoResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ServerStreamingEchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ServerStreamingEchoRequest.displayName = 'proto.grpc.gateway.testing.ServerStreamingEchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ServerStreamingEchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ServerStreamingEchoResponse.displayName = 'proto.grpc.gateway.testing.ServerStreamingEchoResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ClientStreamingEchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ClientStreamingEchoRequest.displayName = 'proto.grpc.gateway.testing.ClientStreamingEchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ClientStreamingEchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ClientStreamingEchoResponse.displayName = 'proto.grpc.gateway.testing.ClientStreamingEchoResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.Empty.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.Empty.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.Empty} + */ +proto.grpc.gateway.testing.Empty.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.Empty; + return proto.grpc.gateway.testing.Empty.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.Empty} + */ +proto.grpc.gateway.testing.Empty.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.Empty.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.Empty.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.EchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.EchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.EchoRequest} + */ +proto.grpc.gateway.testing.EchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.EchoRequest; + return proto.grpc.gateway.testing.EchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.EchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.EchoRequest} + */ +proto.grpc.gateway.testing.EchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.EchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.EchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.EchoRequest} returns this + */ +proto.grpc.gateway.testing.EchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.EchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.EchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, ""), +messageCount: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.EchoResponse} + */ +proto.grpc.gateway.testing.EchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.EchoResponse; + return proto.grpc.gateway.testing.EchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.EchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.EchoResponse} + */ +proto.grpc.gateway.testing.EchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.EchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.EchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.EchoResponse} returns this + */ +proto.grpc.gateway.testing.EchoResponse.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 message_count = 2; + * @return {number} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.EchoResponse} returns this + */ +proto.grpc.gateway.testing.EchoResponse.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ServerStreamingEchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, ""), +messageCount: jspb.Message.getFieldWithDefault(msg, 2, 0), +messageInterval: jspb.Message.getFieldWithDefault(msg, 3, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ServerStreamingEchoRequest; + return proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageInterval(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ServerStreamingEchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } + f = message.getMessageInterval(); + if (f !== 0) { + writer.writeInt32( + 3, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 message_count = 2; + * @return {number} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional int32 message_interval = 3; + * @return {number} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessageInterval = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessageInterval = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ServerStreamingEchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ServerStreamingEchoResponse; + return proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ServerStreamingEchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ClientStreamingEchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ClientStreamingEchoRequest; + return proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ClientStreamingEchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ClientStreamingEchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +messageCount: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ClientStreamingEchoResponse; + return proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ClientStreamingEchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 message_count = 1; + * @return {number} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} returns this + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +goog.object.extend(exports, proto.grpc.gateway.testing); From 981e0dbc36ea8ebc8f1595381488be18eab7bb4f Mon Sep 17 00:00:00 2001 From: LE VAN THANH Date: Tue, 24 Dec 2024 14:37:15 +0700 Subject: [PATCH 3/3] update some scripts --- .idea/grpc-web.iml | 2 + .idea/jsLibraryMappings.xml | 1 + net/grpc/gateway/examples/echo/Taskfile.yaml | 8 - .../examples/echo/ts-example/Taskfile.yaml | 17 +- .../examples/echo/ts-example/client.ts | 4 +- .../examples/echo/ts-example/package.json | 5 +- .../{ => protos}/EchoServiceClientPb.ts | 88 +- .../ts-example/protos/HelloServiceClientPb.ts | 129 ++ .../echo/ts-example/protos/echo.proto | 103 ++ .../echo/ts-example/{ => protos}/echo_pb.d.ts | 0 .../echo/ts-example/protos/echo_pb.js | 1149 +++++++++++++++++ .../echo/ts-example/protos/hello.proto | 34 + .../echo/ts-example/protos/hello_pb.d.ts | 44 + .../echo/ts-example/protos/hello_pb.js | 358 +++++ .../examples/echo/ts-example/tsconfig.json | 9 +- .../echo/ts-example/webpack.config.js | 4 - 16 files changed, 1885 insertions(+), 70 deletions(-) delete mode 100644 net/grpc/gateway/examples/echo/Taskfile.yaml rename net/grpc/gateway/examples/echo/ts-example/{ => protos}/EchoServiceClientPb.ts (63%) create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/HelloServiceClientPb.ts create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/echo.proto rename net/grpc/gateway/examples/echo/ts-example/{ => protos}/echo_pb.d.ts (100%) create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.js create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/hello.proto create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.d.ts create mode 100644 net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.js delete mode 100644 net/grpc/gateway/examples/echo/ts-example/webpack.config.js diff --git a/.idea/grpc-web.iml b/.idea/grpc-web.iml index 24643cc3..37538919 100644 --- a/.idea/grpc-web.iml +++ b/.idea/grpc-web.iml @@ -8,5 +8,7 @@ + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml index d23208fb..6350fb0b 100644 --- a/.idea/jsLibraryMappings.xml +++ b/.idea/jsLibraryMappings.xml @@ -1,6 +1,7 @@ + \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/Taskfile.yaml b/net/grpc/gateway/examples/echo/Taskfile.yaml deleted file mode 100644 index 6582898c..00000000 --- a/net/grpc/gateway/examples/echo/Taskfile.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' - -tasks: - -includes: - docs: - taskfile: ./ts-example/Taskfile.yml - dir: ./ts-example \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml index 01d4bcbe..1ff7beaa 100644 --- a/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml +++ b/net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml @@ -1,18 +1,29 @@ version: '3' tasks: + build: cmds: - - npx tsc && mv *_pb.js dist/ && npx webpack + - rm -fr dist/ && task genpb-ts && npx tsc && esbuild dist/client.js --outfile=dist/main.js --bundle --minify --sourcemap + + start-web: + cmds: + - python3 -m http.server 8081 + + start-servers: + cmds: + - cd $(git rev-parse --show-toplevel) && docker-compose pull prereqs node-server envoy + - cd $(git rev-parse --show-toplevel) && docker-compose up node-server envoy + genpb-cdts: cmds: - > - protoc -I=../ echo.proto \ + protoc -I=./ */**.proto \ --js_out=import_style=commonjs:. \ --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:. genpb-ts: cmds: - > - protoc -I=../ echo.proto \ + protoc -I=./ */**.proto \ --js_out=import_style=commonjs:. \ --grpc-web_out=import_style=typescript,mode=grpcwebtext:. \ No newline at end of file diff --git a/net/grpc/gateway/examples/echo/ts-example/client.ts b/net/grpc/gateway/examples/echo/ts-example/client.ts index f92b44c6..a88189cd 100644 --- a/net/grpc/gateway/examples/echo/ts-example/client.ts +++ b/net/grpc/gateway/examples/echo/ts-example/client.ts @@ -24,9 +24,9 @@ import * as $ from 'jquery'; // import {EchoServiceClient} from './echo_grpc_web_pb'; // Option 2: import_style=typescript -import {EchoServiceClient} from './EchoServiceClientPb'; +import {EchoServiceClient} from './protos/EchoServiceClientPb'; -import {EchoRequest, EchoResponse, ServerStreamingEchoRequest, ServerStreamingEchoResponse} from './echo_pb'; +import {EchoRequest, EchoResponse, ServerStreamingEchoRequest, ServerStreamingEchoResponse} from './protos/echo_pb'; class EchoApp { static readonly INTERVAL = 500; // ms diff --git a/net/grpc/gateway/examples/echo/ts-example/package.json b/net/grpc/gateway/examples/echo/ts-example/package.json index f4b4b51d..18b77f55 100644 --- a/net/grpc/gateway/examples/echo/ts-example/package.json +++ b/net/grpc/gateway/examples/echo/ts-example/package.json @@ -1,11 +1,14 @@ { "scripts": { - "build": "task build" + "build": "task build", + "start-web": "task start-web", + "start-servers": "task start-servers" }, "devDependencies": { "@types/google-protobuf": "~3.15.12", "@types/jquery": "~3.3.6", "@types/node": "~10.17.0", + "esbuild": "^0.24.2", "google-protobuf": "~3.21.4", "grpc-web": "~1.5.0", "jquery": "~3.5.1", diff --git a/net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts b/net/grpc/gateway/examples/echo/ts-example/protos/EchoServiceClientPb.ts similarity index 63% rename from net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts rename to net/grpc/gateway/examples/echo/ts-example/protos/EchoServiceClientPb.ts index 9fced9b6..4ff1425c 100644 --- a/net/grpc/gateway/examples/echo/ts-example/EchoServiceClientPb.ts +++ b/net/grpc/gateway/examples/echo/ts-example/protos/EchoServiceClientPb.ts @@ -8,7 +8,7 @@ // versions: // protoc-gen-grpc-web v1.5.0 // protoc v5.29.2 -// source: echo.proto +// source: protos/echo.proto /* eslint-disable */ @@ -17,7 +17,7 @@ import * as grpcWeb from 'grpc-web'; -import * as echo_pb from './echo_pb'; // proto import: "echo.proto" +import * as protos_echo_pb from '../protos/echo_pb'; // proto import: "protos/echo.proto" export class EchoServiceClient { @@ -42,29 +42,29 @@ export class EchoServiceClient { methodDescriptorEcho = new grpcWeb.MethodDescriptor( '/grpc.gateway.testing.EchoService/Echo', grpcWeb.MethodType.UNARY, - echo_pb.EchoRequest, - echo_pb.EchoResponse, - (request: echo_pb.EchoRequest) => { + protos_echo_pb.EchoRequest, + protos_echo_pb.EchoResponse, + (request: protos_echo_pb.EchoRequest) => { return request.serializeBinary(); }, - echo_pb.EchoResponse.deserializeBinary + protos_echo_pb.EchoResponse.deserializeBinary ); echo( - request: echo_pb.EchoRequest, - metadata?: grpcWeb.Metadata | null): Promise; + request: protos_echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null): Promise; echo( - request: echo_pb.EchoRequest, + request: protos_echo_pb.EchoRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, - response: echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; + response: protos_echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; echo( - request: echo_pb.EchoRequest, + request: protos_echo_pb.EchoRequest, metadata?: grpcWeb.Metadata | null, callback?: (err: grpcWeb.RpcError, - response: echo_pb.EchoResponse) => void) { + response: protos_echo_pb.EchoResponse) => void) { if (callback !== undefined) { return this.client_.rpcCall( this.hostname_ + @@ -85,29 +85,29 @@ export class EchoServiceClient { methodDescriptorEchoAbort = new grpcWeb.MethodDescriptor( '/grpc.gateway.testing.EchoService/EchoAbort', grpcWeb.MethodType.UNARY, - echo_pb.EchoRequest, - echo_pb.EchoResponse, - (request: echo_pb.EchoRequest) => { + protos_echo_pb.EchoRequest, + protos_echo_pb.EchoResponse, + (request: protos_echo_pb.EchoRequest) => { return request.serializeBinary(); }, - echo_pb.EchoResponse.deserializeBinary + protos_echo_pb.EchoResponse.deserializeBinary ); echoAbort( - request: echo_pb.EchoRequest, - metadata?: grpcWeb.Metadata | null): Promise; + request: protos_echo_pb.EchoRequest, + metadata?: grpcWeb.Metadata | null): Promise; echoAbort( - request: echo_pb.EchoRequest, + request: protos_echo_pb.EchoRequest, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, - response: echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; + response: protos_echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream; echoAbort( - request: echo_pb.EchoRequest, + request: protos_echo_pb.EchoRequest, metadata?: grpcWeb.Metadata | null, callback?: (err: grpcWeb.RpcError, - response: echo_pb.EchoResponse) => void) { + response: protos_echo_pb.EchoResponse) => void) { if (callback !== undefined) { return this.client_.rpcCall( this.hostname_ + @@ -128,29 +128,29 @@ export class EchoServiceClient { methodDescriptorNoOp = new grpcWeb.MethodDescriptor( '/grpc.gateway.testing.EchoService/NoOp', grpcWeb.MethodType.UNARY, - echo_pb.Empty, - echo_pb.Empty, - (request: echo_pb.Empty) => { + protos_echo_pb.Empty, + protos_echo_pb.Empty, + (request: protos_echo_pb.Empty) => { return request.serializeBinary(); }, - echo_pb.Empty.deserializeBinary + protos_echo_pb.Empty.deserializeBinary ); noOp( - request: echo_pb.Empty, - metadata?: grpcWeb.Metadata | null): Promise; + request: protos_echo_pb.Empty, + metadata?: grpcWeb.Metadata | null): Promise; noOp( - request: echo_pb.Empty, + request: protos_echo_pb.Empty, metadata: grpcWeb.Metadata | null, callback: (err: grpcWeb.RpcError, - response: echo_pb.Empty) => void): grpcWeb.ClientReadableStream; + response: protos_echo_pb.Empty) => void): grpcWeb.ClientReadableStream; noOp( - request: echo_pb.Empty, + request: protos_echo_pb.Empty, metadata?: grpcWeb.Metadata | null, callback?: (err: grpcWeb.RpcError, - response: echo_pb.Empty) => void) { + response: protos_echo_pb.Empty) => void) { if (callback !== undefined) { return this.client_.rpcCall( this.hostname_ + @@ -171,17 +171,17 @@ export class EchoServiceClient { methodDescriptorServerStreamingEcho = new grpcWeb.MethodDescriptor( '/grpc.gateway.testing.EchoService/ServerStreamingEcho', grpcWeb.MethodType.SERVER_STREAMING, - echo_pb.ServerStreamingEchoRequest, - echo_pb.ServerStreamingEchoResponse, - (request: echo_pb.ServerStreamingEchoRequest) => { + protos_echo_pb.ServerStreamingEchoRequest, + protos_echo_pb.ServerStreamingEchoResponse, + (request: protos_echo_pb.ServerStreamingEchoRequest) => { return request.serializeBinary(); }, - echo_pb.ServerStreamingEchoResponse.deserializeBinary + protos_echo_pb.ServerStreamingEchoResponse.deserializeBinary ); serverStreamingEcho( - request: echo_pb.ServerStreamingEchoRequest, - metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { + request: protos_echo_pb.ServerStreamingEchoRequest, + metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { return this.client_.serverStreaming( this.hostname_ + '/grpc.gateway.testing.EchoService/ServerStreamingEcho', @@ -193,17 +193,17 @@ export class EchoServiceClient { methodDescriptorServerStreamingEchoAbort = new grpcWeb.MethodDescriptor( '/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort', grpcWeb.MethodType.SERVER_STREAMING, - echo_pb.ServerStreamingEchoRequest, - echo_pb.ServerStreamingEchoResponse, - (request: echo_pb.ServerStreamingEchoRequest) => { + protos_echo_pb.ServerStreamingEchoRequest, + protos_echo_pb.ServerStreamingEchoResponse, + (request: protos_echo_pb.ServerStreamingEchoRequest) => { return request.serializeBinary(); }, - echo_pb.ServerStreamingEchoResponse.deserializeBinary + protos_echo_pb.ServerStreamingEchoResponse.deserializeBinary ); serverStreamingEchoAbort( - request: echo_pb.ServerStreamingEchoRequest, - metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { + request: protos_echo_pb.ServerStreamingEchoRequest, + metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream { return this.client_.serverStreaming( this.hostname_ + '/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort', diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/HelloServiceClientPb.ts b/net/grpc/gateway/examples/echo/ts-example/protos/HelloServiceClientPb.ts new file mode 100644 index 00000000..9490c1c3 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/HelloServiceClientPb.ts @@ -0,0 +1,129 @@ +/** + * @fileoverview gRPC-Web generated client stub for grpc.gateway.testing + * @enhanceable + * @public + */ + +// Code generated by protoc-gen-grpc-web. DO NOT EDIT. +// versions: +// protoc-gen-grpc-web v1.5.0 +// protoc v5.29.2 +// source: protos/hello.proto + + +/* eslint-disable */ +// @ts-nocheck + + +import * as grpcWeb from 'grpc-web'; + +import * as protos_hello_pb from '../protos/hello_pb'; // proto import: "protos/hello.proto" + + +export class HelloServiceClient { + client_: grpcWeb.AbstractClientBase; + hostname_: string; + credentials_: null | { [index: string]: string; }; + options_: null | { [index: string]: any; }; + + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: any; }) { + if (!options) options = {}; + if (!credentials) credentials = {}; + options['format'] = 'text'; + + this.client_ = new grpcWeb.GrpcWebClientBase(options); + this.hostname_ = hostname.replace(/\/+$/, ''); + this.credentials_ = credentials; + this.options_ = options; + } + + methodDescriptorsayHello = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.HelloService/sayHello', + grpcWeb.MethodType.UNARY, + protos_hello_pb.HelloRequest, + protos_hello_pb.HelloResponse, + (request: protos_hello_pb.HelloRequest) => { + return request.serializeBinary(); + }, + protos_hello_pb.HelloResponse.deserializeBinary + ); + + sayHello( + request: protos_hello_pb.HelloRequest, + metadata?: grpcWeb.Metadata | null): Promise; + + sayHello( + request: protos_hello_pb.HelloRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.RpcError, + response: protos_hello_pb.HelloResponse) => void): grpcWeb.ClientReadableStream; + + sayHello( + request: protos_hello_pb.HelloRequest, + metadata?: grpcWeb.Metadata | null, + callback?: (err: grpcWeb.RpcError, + response: protos_hello_pb.HelloResponse) => void) { + if (callback !== undefined) { + return this.client_.rpcCall( + this.hostname_ + + '/grpc.gateway.testing.HelloService/sayHello', + request, + metadata || {}, + this.methodDescriptorsayHello, + callback); + } + return this.client_.unaryCall( + this.hostname_ + + '/grpc.gateway.testing.HelloService/sayHello', + request, + metadata || {}, + this.methodDescriptorsayHello); + } + + methodDescriptorsayGoodbye = new grpcWeb.MethodDescriptor( + '/grpc.gateway.testing.HelloService/sayGoodbye', + grpcWeb.MethodType.UNARY, + protos_hello_pb.HelloRequest, + protos_hello_pb.HelloResponse, + (request: protos_hello_pb.HelloRequest) => { + return request.serializeBinary(); + }, + protos_hello_pb.HelloResponse.deserializeBinary + ); + + sayGoodbye( + request: protos_hello_pb.HelloRequest, + metadata?: grpcWeb.Metadata | null): Promise; + + sayGoodbye( + request: protos_hello_pb.HelloRequest, + metadata: grpcWeb.Metadata | null, + callback: (err: grpcWeb.RpcError, + response: protos_hello_pb.HelloResponse) => void): grpcWeb.ClientReadableStream; + + sayGoodbye( + request: protos_hello_pb.HelloRequest, + metadata?: grpcWeb.Metadata | null, + callback?: (err: grpcWeb.RpcError, + response: protos_hello_pb.HelloResponse) => void) { + if (callback !== undefined) { + return this.client_.rpcCall( + this.hostname_ + + '/grpc.gateway.testing.HelloService/sayGoodbye', + request, + metadata || {}, + this.methodDescriptorsayGoodbye, + callback); + } + return this.client_.unaryCall( + this.hostname_ + + '/grpc.gateway.testing.HelloService/sayGoodbye', + request, + metadata || {}, + this.methodDescriptorsayGoodbye); + } + +} + diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/echo.proto b/net/grpc/gateway/examples/echo/ts-example/protos/echo.proto new file mode 100644 index 00000000..d26e6f6d --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/echo.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.gateway.testing; + +message Empty {} + +message EchoRequest { + string message = 1; +} + +message EchoResponse { + string message = 1; + int32 message_count = 2; +} + +// Request type for server side streaming echo. +message ServerStreamingEchoRequest { + // Message string for server streaming request. + string message = 1; + + // The total number of messages to be generated before the server + // closes the stream; default is 10. + int32 message_count = 2; + + // The interval (ms) between two server messages. The server implementation + // may enforce some minimum interval (e.g. 100ms) to avoid message overflow. + int32 message_interval = 3; +} + +// Response type for server streaming response. +message ServerStreamingEchoResponse { + // Response message. + string message = 1; +} + +// Request type for client side streaming echo. +message ClientStreamingEchoRequest { + // A special value "" indicates that there's no further messages. + string message = 1; +} + +// Response type for client side streaming echo. +message ClientStreamingEchoResponse { + // Total number of client messages that have been received. + int32 message_count = 1; +} + +// A simple echo service. +service EchoService { + // One request followed by one response + // The server returns the client message as-is. + rpc Echo(EchoRequest) returns (EchoResponse); + + // Sends back abort status. + rpc EchoAbort(EchoRequest) returns (EchoResponse) {} + + // One empty request, ZERO processing, followed by one empty response + // (minimum effort to do message serialization). + rpc NoOp(Empty) returns (Empty); + + // One request followed by a sequence of responses (streamed download). + // The server will return the same client message repeatedly. + rpc ServerStreamingEcho(ServerStreamingEchoRequest) + returns (stream ServerStreamingEchoResponse); + + // One request followed by a sequence of responses (streamed download). + // The server abort directly. + rpc ServerStreamingEchoAbort(ServerStreamingEchoRequest) + returns (stream ServerStreamingEchoResponse) {} + + // A sequence of requests followed by one response (streamed upload). + // The server returns the total number of messages as the result. + // Notice: Client side streaming and Bidi streaming are not supported at the moment. + rpc ClientStreamingEcho(stream ClientStreamingEchoRequest) + returns (ClientStreamingEchoResponse); + + // A sequence of requests with each message echoed by the server immediately. + // The server returns the same client messages in order. + // E.g. this is how the speech API works. + // Notice: Client side streaming and Bidi streaming are not supported at the moment. + rpc FullDuplexEcho(stream EchoRequest) returns (stream EchoResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client messages and then returns the same + // client messages one by one after the client half-closes the stream. + // This is how an image recognition API may work. + // Notice: Client side streaming and Bidi streaming are not supported at the moment. + rpc HalfDuplexEcho(stream EchoRequest) returns (stream EchoResponse); +} diff --git a/net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts b/net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.d.ts similarity index 100% rename from net/grpc/gateway/examples/echo/ts-example/echo_pb.d.ts rename to net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.d.ts diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.js b/net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.js new file mode 100644 index 00000000..9e4607c3 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.js @@ -0,0 +1,1149 @@ +// source: protos/echo.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); + +goog.exportSymbol('proto.grpc.gateway.testing.ClientStreamingEchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ClientStreamingEchoResponse', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.EchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.EchoResponse', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.Empty', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ServerStreamingEchoRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.ServerStreamingEchoResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.Empty = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.Empty, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.Empty.displayName = 'proto.grpc.gateway.testing.Empty'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.EchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.EchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.EchoRequest.displayName = 'proto.grpc.gateway.testing.EchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.EchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.EchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.EchoResponse.displayName = 'proto.grpc.gateway.testing.EchoResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ServerStreamingEchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ServerStreamingEchoRequest.displayName = 'proto.grpc.gateway.testing.ServerStreamingEchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ServerStreamingEchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ServerStreamingEchoResponse.displayName = 'proto.grpc.gateway.testing.ServerStreamingEchoResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ClientStreamingEchoRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ClientStreamingEchoRequest.displayName = 'proto.grpc.gateway.testing.ClientStreamingEchoRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.ClientStreamingEchoResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.ClientStreamingEchoResponse.displayName = 'proto.grpc.gateway.testing.ClientStreamingEchoResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.Empty.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.Empty.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.Empty} + */ +proto.grpc.gateway.testing.Empty.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.Empty; + return proto.grpc.gateway.testing.Empty.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.Empty} + */ +proto.grpc.gateway.testing.Empty.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.Empty.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.Empty.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.EchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.EchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.EchoRequest} + */ +proto.grpc.gateway.testing.EchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.EchoRequest; + return proto.grpc.gateway.testing.EchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.EchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.EchoRequest} + */ +proto.grpc.gateway.testing.EchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.EchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.EchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.EchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.EchoRequest} returns this + */ +proto.grpc.gateway.testing.EchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.EchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.EchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, ""), +messageCount: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.EchoResponse} + */ +proto.grpc.gateway.testing.EchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.EchoResponse; + return proto.grpc.gateway.testing.EchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.EchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.EchoResponse} + */ +proto.grpc.gateway.testing.EchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.EchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.EchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.EchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.EchoResponse} returns this + */ +proto.grpc.gateway.testing.EchoResponse.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 message_count = 2; + * @return {number} + */ +proto.grpc.gateway.testing.EchoResponse.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.EchoResponse} returns this + */ +proto.grpc.gateway.testing.EchoResponse.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ServerStreamingEchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, ""), +messageCount: jspb.Message.getFieldWithDefault(msg, 2, 0), +messageInterval: jspb.Message.getFieldWithDefault(msg, 3, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ServerStreamingEchoRequest; + return proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageInterval(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ServerStreamingEchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } + f = message.getMessageInterval(); + if (f !== 0) { + writer.writeInt32( + 3, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 message_count = 2; + * @return {number} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional int32 message_interval = 3; + * @return {number} + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.getMessageInterval = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoRequest.prototype.setMessageInterval = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ServerStreamingEchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ServerStreamingEchoResponse; + return proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ServerStreamingEchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ServerStreamingEchoResponse} returns this + */ +proto.grpc.gateway.testing.ServerStreamingEchoResponse.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ClientStreamingEchoRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ClientStreamingEchoRequest; + return proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ClientStreamingEchoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoRequest} returns this + */ +proto.grpc.gateway.testing.ClientStreamingEchoRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.ClientStreamingEchoResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.toObject = function(includeInstance, msg) { + var f, obj = { +messageCount: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.ClientStreamingEchoResponse; + return proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.ClientStreamingEchoResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 message_count = 1; + * @return {number} + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.ClientStreamingEchoResponse} returns this + */ +proto.grpc.gateway.testing.ClientStreamingEchoResponse.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +goog.object.extend(exports, proto.grpc.gateway.testing); diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/hello.proto b/net/grpc/gateway/examples/echo/ts-example/protos/hello.proto new file mode 100644 index 00000000..8169bdc7 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/hello.proto @@ -0,0 +1,34 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.gateway.testing; + +message HelloRequest { + string message = 1; +} + +message HelloResponse { + string message = 1; + int32 message_count = 2; +} +// A simple Hello service. +service HelloService { + // One request followed by one response + // The server returns the client message as-is. + rpc sayHello(HelloRequest) returns (HelloResponse); + rpc sayGoodbye(HelloRequest) returns ( HelloResponse); + +} diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.d.ts b/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.d.ts new file mode 100644 index 00000000..e35257e4 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.d.ts @@ -0,0 +1,44 @@ +import * as jspb from 'google-protobuf' + + + +export class HelloRequest extends jspb.Message { + getMessage(): string; + setMessage(value: string): HelloRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HelloRequest.AsObject; + static toObject(includeInstance: boolean, msg: HelloRequest): HelloRequest.AsObject; + static serializeBinaryToWriter(message: HelloRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HelloRequest; + static deserializeBinaryFromReader(message: HelloRequest, reader: jspb.BinaryReader): HelloRequest; +} + +export namespace HelloRequest { + export type AsObject = { + message: string, + } +} + +export class HelloResponse extends jspb.Message { + getMessage(): string; + setMessage(value: string): HelloResponse; + + getMessageCount(): number; + setMessageCount(value: number): HelloResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HelloResponse.AsObject; + static toObject(includeInstance: boolean, msg: HelloResponse): HelloResponse.AsObject; + static serializeBinaryToWriter(message: HelloResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HelloResponse; + static deserializeBinaryFromReader(message: HelloResponse, reader: jspb.BinaryReader): HelloResponse; +} + +export namespace HelloResponse { + export type AsObject = { + message: string, + messageCount: number, + } +} + diff --git a/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.js b/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.js new file mode 100644 index 00000000..a93247a3 --- /dev/null +++ b/net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.js @@ -0,0 +1,358 @@ +// source: protos/hello.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); + +goog.exportSymbol('proto.grpc.gateway.testing.HelloRequest', null, global); +goog.exportSymbol('proto.grpc.gateway.testing.HelloResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.HelloRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.HelloRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.HelloRequest.displayName = 'proto.grpc.gateway.testing.HelloRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.grpc.gateway.testing.HelloResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.grpc.gateway.testing.HelloResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.grpc.gateway.testing.HelloResponse.displayName = 'proto.grpc.gateway.testing.HelloResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.HelloRequest.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.HelloRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.HelloRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.HelloRequest.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.HelloRequest} + */ +proto.grpc.gateway.testing.HelloRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.HelloRequest; + return proto.grpc.gateway.testing.HelloRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.HelloRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.HelloRequest} + */ +proto.grpc.gateway.testing.HelloRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.HelloRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.HelloRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.HelloRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.HelloRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.HelloRequest.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.HelloRequest} returns this + */ +proto.grpc.gateway.testing.HelloRequest.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.grpc.gateway.testing.HelloResponse.prototype.toObject = function(opt_includeInstance) { + return proto.grpc.gateway.testing.HelloResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.grpc.gateway.testing.HelloResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.HelloResponse.toObject = function(includeInstance, msg) { + var f, obj = { +message: jspb.Message.getFieldWithDefault(msg, 1, ""), +messageCount: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.grpc.gateway.testing.HelloResponse} + */ +proto.grpc.gateway.testing.HelloResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.grpc.gateway.testing.HelloResponse; + return proto.grpc.gateway.testing.HelloResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.grpc.gateway.testing.HelloResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.grpc.gateway.testing.HelloResponse} + */ +proto.grpc.gateway.testing.HelloResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMessageCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.grpc.gateway.testing.HelloResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.grpc.gateway.testing.HelloResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.grpc.gateway.testing.HelloResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.grpc.gateway.testing.HelloResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessageCount(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.grpc.gateway.testing.HelloResponse.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.grpc.gateway.testing.HelloResponse} returns this + */ +proto.grpc.gateway.testing.HelloResponse.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 message_count = 2; + * @return {number} + */ +proto.grpc.gateway.testing.HelloResponse.prototype.getMessageCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.grpc.gateway.testing.HelloResponse} returns this + */ +proto.grpc.gateway.testing.HelloResponse.prototype.setMessageCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +goog.object.extend(exports, proto.grpc.gateway.testing); diff --git a/net/grpc/gateway/examples/echo/ts-example/tsconfig.json b/net/grpc/gateway/examples/echo/ts-example/tsconfig.json index 81cb22c0..fd855680 100644 --- a/net/grpc/gateway/examples/echo/ts-example/tsconfig.json +++ b/net/grpc/gateway/examples/echo/ts-example/tsconfig.json @@ -6,15 +6,8 @@ "allowJs": true, "outDir": "./dist", "types": ["node"], + "sourceMap": true }, - "include": [ - "client.ts", - "echo_pb.js", - "echo_pb.d.ts", - "echo_grpc_web_pb.js", - "echo_grpc_web_pb.d.ts", - "EchoServiceClientPb.ts" - ], "exclude": [ "node_modules" ] diff --git a/net/grpc/gateway/examples/echo/ts-example/webpack.config.js b/net/grpc/gateway/examples/echo/ts-example/webpack.config.js deleted file mode 100644 index 6831e7b4..00000000 --- a/net/grpc/gateway/examples/echo/ts-example/webpack.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - mode: 'production', - entry: './dist/client.js', -};