Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mains #1470

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

mains #1470

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/grpc-web.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'

tasks:

build:
cmds:
- 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=./ */**.proto \
--js_out=import_style=commonjs:. \
--grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:.
genpb-ts:
cmds:
- >
protoc -I=./ */**.proto \
--js_out=import_style=commonjs:. \
--grpc-web_out=import_style=typescript,mode=grpcwebtext:.
6 changes: 3 additions & 3 deletions net/grpc/gateway/examples/echo/ts-example/client.ts
Original file line number Diff line number Diff line change
@@ -21,12 +21,12 @@ 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 './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
1,149 changes: 1,149 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/echo_pb.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"scripts": {
"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",
Original file line number Diff line number Diff line change
@@ -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: protos/echo.proto


/* eslint-disable */
// @ts-nocheck


import * as grpcWeb from 'grpc-web';

import * as protos_echo_pb from '../protos/echo_pb'; // proto import: "protos/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,
protos_echo_pb.EchoRequest,
protos_echo_pb.EchoResponse,
(request: protos_echo_pb.EchoRequest) => {
return request.serializeBinary();
},
protos_echo_pb.EchoResponse.deserializeBinary
);

echo(
request: protos_echo_pb.EchoRequest,
metadata?: grpcWeb.Metadata | null): Promise<protos_echo_pb.EchoResponse>;

echo(
request: protos_echo_pb.EchoRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.RpcError,
response: protos_echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream<protos_echo_pb.EchoResponse>;

echo(
request: protos_echo_pb.EchoRequest,
metadata?: grpcWeb.Metadata | null,
callback?: (err: grpcWeb.RpcError,
response: protos_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,
protos_echo_pb.EchoRequest,
protos_echo_pb.EchoResponse,
(request: protos_echo_pb.EchoRequest) => {
return request.serializeBinary();
},
protos_echo_pb.EchoResponse.deserializeBinary
);

echoAbort(
request: protos_echo_pb.EchoRequest,
metadata?: grpcWeb.Metadata | null): Promise<protos_echo_pb.EchoResponse>;

echoAbort(
request: protos_echo_pb.EchoRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.RpcError,
response: protos_echo_pb.EchoResponse) => void): grpcWeb.ClientReadableStream<protos_echo_pb.EchoResponse>;

echoAbort(
request: protos_echo_pb.EchoRequest,
metadata?: grpcWeb.Metadata | null,
callback?: (err: grpcWeb.RpcError,
response: protos_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,
protos_echo_pb.Empty,
protos_echo_pb.Empty,
(request: protos_echo_pb.Empty) => {
return request.serializeBinary();
},
protos_echo_pb.Empty.deserializeBinary
);

noOp(
request: protos_echo_pb.Empty,
metadata?: grpcWeb.Metadata | null): Promise<protos_echo_pb.Empty>;

noOp(
request: protos_echo_pb.Empty,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.RpcError,
response: protos_echo_pb.Empty) => void): grpcWeb.ClientReadableStream<protos_echo_pb.Empty>;

noOp(
request: protos_echo_pb.Empty,
metadata?: grpcWeb.Metadata | null,
callback?: (err: grpcWeb.RpcError,
response: protos_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,
protos_echo_pb.ServerStreamingEchoRequest,
protos_echo_pb.ServerStreamingEchoResponse,
(request: protos_echo_pb.ServerStreamingEchoRequest) => {
return request.serializeBinary();
},
protos_echo_pb.ServerStreamingEchoResponse.deserializeBinary
);

serverStreamingEcho(
request: protos_echo_pb.ServerStreamingEchoRequest,
metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<protos_echo_pb.ServerStreamingEchoResponse> {
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,
protos_echo_pb.ServerStreamingEchoRequest,
protos_echo_pb.ServerStreamingEchoResponse,
(request: protos_echo_pb.ServerStreamingEchoRequest) => {
return request.serializeBinary();
},
protos_echo_pb.ServerStreamingEchoResponse.deserializeBinary
);

serverStreamingEchoAbort(
request: protos_echo_pb.ServerStreamingEchoRequest,
metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<protos_echo_pb.ServerStreamingEchoResponse> {
return this.client_.serverStreaming(
this.hostname_ +
'/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort',
request,
metadata || {},
this.methodDescriptorServerStreamingEchoAbort);
}

}

Original file line number Diff line number Diff line change
@@ -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<protos_hello_pb.HelloResponse>;

sayHello(
request: protos_hello_pb.HelloRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.RpcError,
response: protos_hello_pb.HelloResponse) => void): grpcWeb.ClientReadableStream<protos_hello_pb.HelloResponse>;

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<protos_hello_pb.HelloResponse>;

sayGoodbye(
request: protos_hello_pb.HelloRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.RpcError,
response: protos_hello_pb.HelloResponse) => void): grpcWeb.ClientReadableStream<protos_hello_pb.HelloResponse>;

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);
}

}

103 changes: 103 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/echo.proto
Original file line number Diff line number Diff line change
@@ -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);
}
138 changes: 138 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.d.ts
Original file line number Diff line number Diff line change
@@ -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,
}
}

1,149 changes: 1,149 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/echo_pb.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/hello.proto
Original file line number Diff line number Diff line change
@@ -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);

}
44 changes: 44 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.d.ts
Original file line number Diff line number Diff line change
@@ -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,
}
}

358 changes: 358 additions & 0 deletions net/grpc/gateway/examples/echo/ts-example/protos/hello_pb.js
Original file line number Diff line number Diff line change
@@ -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_<name>, 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_<name>, 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);
9 changes: 1 addition & 8 deletions net/grpc/gateway/examples/echo/ts-example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
4 changes: 0 additions & 4 deletions net/grpc/gateway/examples/echo/ts-example/webpack.config.js

This file was deleted.