Skip to content

Commit

Permalink
proto: generate ts/js source for proto dependencies
Browse files Browse the repository at this point in the history
With this change, I'm able to import ./gen/orijtech/cosmosloadtester/v1/loadtest_service_pb and build the UI successfully.

Updates #8
  • Loading branch information
kirbyquerby committed Dec 14, 2022
1 parent c6a30a7 commit d599b7f
Show file tree
Hide file tree
Showing 8 changed files with 1,203 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ CGO_ENABLED ?= 0

pb:
(cd proto && buf mod update)
(cd proto && buf generate)
(cd proto && buf generate --template buf.gen.yaml)
(cd proto && buf generate --template buf.gen.ts.grpcweb.yaml --include-imports)
npx --yes swagger-typescript-api -p ./proto/orijtech/cosmosloadtester/v1/loadtest_service.swagger.json -o ./ui/src/gen -n LoadtestApi.ts
server:
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -trimpath -ldflags $(LDFLAGS) -o bin/server ./cmd/server
Expand Down
8 changes: 8 additions & 0 deletions proto/buf.gen.ts.grpcweb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
plugins:
- name: js
out: ../ui/src/gen
opt: import_style=commonjs
- name: grpc-web
out: ../ui/src/gen
opt: import_style=typescript,mode=grpcwebtext
6 changes: 0 additions & 6 deletions proto/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ plugins:
- name: openapiv2
out: .
opt:
- name: js
out: ../ui/src/gen
opt: import_style=commonjs
- name: grpc-web
out: ../ui/src/gen
opt: import_style=typescript,mode=grpcwebtext
2 changes: 1 addition & 1 deletion proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: faacf837d7304c58b7c9020c7807fa6e
commit: 75b4300737fb4efca0831636be94e517
6 changes: 6 additions & 0 deletions ui/src/gen/google/api/annotations_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as jspb from 'google-protobuf'

import * as google_api_http_pb from '../../google/api/http_pb';
import * as google_protobuf_descriptor_pb from 'google-protobuf/google/protobuf/descriptor_pb';


54 changes: 54 additions & 0 deletions ui/src/gen/google/api/annotations_pb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// source: google/api/annotations.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 = (function() {
if (this) { return this; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
if (typeof self !== 'undefined') { return self; }
return Function('return this')();
}.call(null));

var google_api_http_pb = require('../../google/api/http_pb.js');
goog.object.extend(proto, google_api_http_pb);
var google_protobuf_descriptor_pb = require('google-protobuf/google/protobuf/descriptor_pb.js');
goog.object.extend(proto, google_protobuf_descriptor_pb);
goog.exportSymbol('proto.google.api.http', null, global);

/**
* A tuple of {field number, class constructor} for the extension
* field named `http`.
* @type {!jspb.ExtensionFieldInfo<!proto.google.api.HttpRule>}
*/
proto.google.api.http = new jspb.ExtensionFieldInfo(
72295728,
{http: 0},
google_api_http_pb.HttpRule,
/** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ (
google_api_http_pb.HttpRule.toObject),
0);

google_protobuf_descriptor_pb.MethodOptions.extensionsBinary[72295728] = new jspb.ExtensionFieldBinaryInfo(
proto.google.api.http,
jspb.BinaryReader.prototype.readMessage,
jspb.BinaryWriter.prototype.writeMessage,
google_api_http_pb.HttpRule.serializeBinaryToWriter,
google_api_http_pb.HttpRule.deserializeBinaryFromReader,
false);
// This registers the extension field with the extended class, so that
// toObject() will function correctly.
google_protobuf_descriptor_pb.MethodOptions.extensions[72295728] = proto.google.api.http;

goog.object.extend(exports, proto.google.api);
120 changes: 120 additions & 0 deletions ui/src/gen/google/api/http_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import * as jspb from 'google-protobuf'



export class Http extends jspb.Message {
getRulesList(): Array<HttpRule>;
setRulesList(value: Array<HttpRule>): Http;
clearRulesList(): Http;
addRules(value?: HttpRule, index?: number): HttpRule;

getFullyDecodeReservedExpansion(): boolean;
setFullyDecodeReservedExpansion(value: boolean): Http;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Http.AsObject;
static toObject(includeInstance: boolean, msg: Http): Http.AsObject;
static serializeBinaryToWriter(message: Http, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Http;
static deserializeBinaryFromReader(message: Http, reader: jspb.BinaryReader): Http;
}

export namespace Http {
export type AsObject = {
rulesList: Array<HttpRule.AsObject>,
fullyDecodeReservedExpansion: boolean,
}
}

export class HttpRule extends jspb.Message {
getSelector(): string;
setSelector(value: string): HttpRule;

getGet(): string;
setGet(value: string): HttpRule;

getPut(): string;
setPut(value: string): HttpRule;

getPost(): string;
setPost(value: string): HttpRule;

getDelete(): string;
setDelete(value: string): HttpRule;

getPatch(): string;
setPatch(value: string): HttpRule;

getCustom(): CustomHttpPattern | undefined;
setCustom(value?: CustomHttpPattern): HttpRule;
hasCustom(): boolean;
clearCustom(): HttpRule;

getBody(): string;
setBody(value: string): HttpRule;

getResponseBody(): string;
setResponseBody(value: string): HttpRule;

getAdditionalBindingsList(): Array<HttpRule>;
setAdditionalBindingsList(value: Array<HttpRule>): HttpRule;
clearAdditionalBindingsList(): HttpRule;
addAdditionalBindings(value?: HttpRule, index?: number): HttpRule;

getPatternCase(): HttpRule.PatternCase;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): HttpRule.AsObject;
static toObject(includeInstance: boolean, msg: HttpRule): HttpRule.AsObject;
static serializeBinaryToWriter(message: HttpRule, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): HttpRule;
static deserializeBinaryFromReader(message: HttpRule, reader: jspb.BinaryReader): HttpRule;
}

export namespace HttpRule {
export type AsObject = {
selector: string,
get: string,
put: string,
post: string,
pb_delete: string,
patch: string,
custom?: CustomHttpPattern.AsObject,
body: string,
responseBody: string,
additionalBindingsList: Array<HttpRule.AsObject>,
}

export enum PatternCase {
PATTERN_NOT_SET = 0,
GET = 2,
PUT = 3,
POST = 4,
DELETE = 5,
PATCH = 6,
CUSTOM = 8,
}
}

export class CustomHttpPattern extends jspb.Message {
getKind(): string;
setKind(value: string): CustomHttpPattern;

getPath(): string;
setPath(value: string): CustomHttpPattern;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): CustomHttpPattern.AsObject;
static toObject(includeInstance: boolean, msg: CustomHttpPattern): CustomHttpPattern.AsObject;
static serializeBinaryToWriter(message: CustomHttpPattern, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): CustomHttpPattern;
static deserializeBinaryFromReader(message: CustomHttpPattern, reader: jspb.BinaryReader): CustomHttpPattern;
}

export namespace CustomHttpPattern {
export type AsObject = {
kind: string,
path: string,
}
}

Loading

0 comments on commit d599b7f

Please sign in to comment.