From 58ab3e5adc68e3a1cda6065131d6d2d49f01e498 Mon Sep 17 00:00:00 2001 From: colton Date: Tue, 29 May 2018 15:23:24 -0600 Subject: [PATCH 1/5] Added custom bazel rule. Also needed to change around import paths to better align with bazel's ideology. --- BUILD.bazel | 10 ++ README.md | 65 ++++++++ WORKSPACE | 18 +-- defs.bzl | 131 +++++++++++++++ .../examplecom/simple_service_pb_service.d.ts | 77 --------- .../examplecom/enum_message_pb.d.ts | 18 +-- .../{ => proto}/examplecom/enum_message_pb.js | 2 +- .../examplecom/map_message_pb.d.ts | 14 +- .../{ => proto}/examplecom/map_message_pb.js | 4 +- .../examplecom/oneof_message_pb.d.ts | 10 +- .../examplecom/oneof_message_pb.js | 12 +- .../examplecom/parent_message_v2_pb.d.ts | 24 +-- .../examplecom/parent_message_v2_pb.js | 32 ++-- .../examplecom/parent_message_v3_pb.d.ts | 18 +-- .../examplecom/parent_message_v3_pb.js | 22 +-- .../examplecom/primitive_message_v2_pb.d.ts | 2 +- .../examplecom/primitive_message_v2_pb.js | 0 .../examplecom/primitive_message_v3_pb.d.ts | 2 +- .../examplecom/primitive_message_v3_pb.js | 0 .../repeated_primitive_message_pb.d.ts | 2 +- .../repeated_primitive_message_pb.js | 0 .../examplecom/reserved_words_pb.d.ts | 2 +- .../examplecom/reserved_words_pb.js | 0 .../{ => proto}/examplecom/simple_pb.d.ts | 2 +- .../{ => proto}/examplecom/simple_pb.js | 0 .../examplecom/simple_service_pb.d.ts | 4 +- .../examplecom/simple_service_pb.js | 2 +- .../examplecom/simple_service_pb_service.d.ts | 77 +++++++++ .../examplecom/simple_service_pb_service.js | 18 +-- .../examplecom/simplevalue_pb.d.ts | 2 +- .../{ => proto}/examplecom/simplevalue_pb.js | 0 .../examplecom/well_known_message_pb.d.ts | 2 +- .../examplecom/well_known_message_pb.js | 0 examples/generated/{ => proto}/orphan_pb.d.ts | 2 +- examples/generated/{ => proto}/orphan_pb.js | 0 .../{ => proto}/orphan_pb_service.d.ts | 22 +-- .../{ => proto}/orphan_pb_service.js | 12 +- .../othercom/external_child_message_pb.d.ts | 2 +- .../othercom/external_child_message_pb.js | 0 .../othercom/external_enum_pb.d.ts | 2 +- .../{ => proto}/othercom/external_enum_pb.js | 0 generate.sh | 5 +- package-lock.json | 150 +++++++++--------- proto/BUILD | 22 +++ proto/examplecom/BUILD | 37 +++++ proto/examplecom/enum_message.proto | 2 +- proto/examplecom/map_message.proto | 4 +- proto/examplecom/oneof_message.proto | 2 +- proto/examplecom/parent_message_v2.proto | 2 +- proto/examplecom/parent_message_v3.proto | 2 +- proto/examplecom/simple_service.proto | 2 +- proto/othercom/BUILD | 19 +++ test/integration/enums.ts | 6 +- test/integration/maps.ts | 8 +- test/integration/nestedMessagesV2.ts | 4 +- test/integration/nestedMessagesV3.ts | 4 +- test/integration/oneof.ts | 4 +- test/integration/orphan.ts | 4 +- test/integration/primitivesV2.ts | 2 +- test/integration/primitivesV3.ts | 2 +- test/integration/repeatedPrimitives.ts | 2 +- test/integration/reservedWords.ts | 2 +- test/integration/service/grpcweb.ts | 12 +- test/integration/wellKnownTypes.ts | 2 +- test/unit/util.ts | 2 +- 65 files changed, 596 insertions(+), 317 deletions(-) create mode 100644 defs.bzl delete mode 100644 examples/generated/examplecom/simple_service_pb_service.d.ts rename examples/generated/{ => proto}/examplecom/enum_message_pb.d.ts (65%) rename examples/generated/{ => proto}/examplecom/enum_message_pb.js (98%) rename examples/generated/{ => proto}/examplecom/map_message_pb.d.ts (78%) rename examples/generated/{ => proto}/examplecom/map_message_pb.js (98%) rename examples/generated/{ => proto}/examplecom/oneof_message_pb.d.ts (89%) rename examples/generated/{ => proto}/examplecom/oneof_message_pb.js (97%) rename examples/generated/{ => proto}/examplecom/parent_message_v2_pb.d.ts (70%) rename examples/generated/{ => proto}/examplecom/parent_message_v2_pb.js (91%) rename examples/generated/{ => proto}/examplecom/parent_message_v3_pb.d.ts (72%) rename examples/generated/{ => proto}/examplecom/parent_message_v3_pb.js (93%) rename examples/generated/{ => proto}/examplecom/primitive_message_v2_pb.d.ts (99%) rename examples/generated/{ => proto}/examplecom/primitive_message_v2_pb.js (100%) rename examples/generated/{ => proto}/examplecom/primitive_message_v3_pb.d.ts (97%) rename examples/generated/{ => proto}/examplecom/primitive_message_v3_pb.js (100%) rename examples/generated/{ => proto}/examplecom/repeated_primitive_message_pb.d.ts (98%) rename examples/generated/{ => proto}/examplecom/repeated_primitive_message_pb.js (100%) rename examples/generated/{ => proto}/examplecom/reserved_words_pb.d.ts (99%) rename examples/generated/{ => proto}/examplecom/reserved_words_pb.js (100%) rename examples/generated/{ => proto}/examplecom/simple_pb.d.ts (99%) rename examples/generated/{ => proto}/examplecom/simple_pb.js (100%) rename examples/generated/{ => proto}/examplecom/simple_service_pb.d.ts (94%) rename examples/generated/{ => proto}/examplecom/simple_service_pb.js (99%) create mode 100644 examples/generated/proto/examplecom/simple_service_pb_service.d.ts rename examples/generated/{ => proto}/examplecom/simple_service_pb_service.js (82%) rename examples/generated/{ => proto}/examplecom/simplevalue_pb.d.ts (98%) rename examples/generated/{ => proto}/examplecom/simplevalue_pb.js (100%) rename examples/generated/{ => proto}/examplecom/well_known_message_pb.d.ts (99%) rename examples/generated/{ => proto}/examplecom/well_known_message_pb.js (100%) rename examples/generated/{ => proto}/orphan_pb.d.ts (99%) rename examples/generated/{ => proto}/orphan_pb.js (100%) rename examples/generated/{ => proto}/orphan_pb_service.d.ts (61%) rename examples/generated/{ => proto}/orphan_pb_service.js (89%) rename examples/generated/{ => proto}/othercom/external_child_message_pb.d.ts (94%) rename examples/generated/{ => proto}/othercom/external_child_message_pb.js (100%) rename examples/generated/{ => proto}/othercom/external_enum_pb.d.ts (75%) rename examples/generated/{ => proto}/othercom/external_enum_pb.js (100%) create mode 100644 proto/BUILD create mode 100644 proto/examplecom/BUILD create mode 100644 proto/othercom/BUILD diff --git a/BUILD.bazel b/BUILD.bazel index 7fef3c0f..fb22b2ef 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,2 +1,12 @@ package(default_visibility = ["//visibility:public"]) + exports_files(["tsconfig.json"]) + +filegroup( + name = "generate_ts", + srcs = [ + "//proto:generate", + "//proto/examplecom:generate", + "//proto/othercom:generate", + ], +) diff --git a/README.md b/README.md index 726c78b0..1e4f1a8f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ also output service definitions as both `.js` and `.d.ts` files in the structure This plugin is tested and written using TypeScript 2.7. ## Installation + +### npm As a prerequisite, download or install `protoc` (the protocol buffer compiler) for your platform from the [github releases page](https://github.com/google/protobuf/releases) or via a package manager (ie: [brew](http://brewformulas.org/Protobuf), [apt](https://www.ubuntuupdates.org/pm/protobuf-compiler)). For the latest stable version of the ts-protoc-gen plugin: @@ -26,6 +28,69 @@ For our latest build straight from master: ```bash npm install ts-protoc-gen@next ``` +### bazel +Include the following in your `WORKSPACE`: +```python +git_repository( + name = "io_bazel_rules_go", + commit = "6bee898391a42971289a7989c0f459ab5a4a84dd", # master as of May 10th, 2018 + remote = "https://github.com/bazelbuild/rules_go.git", + ) + load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") + go_rules_dependencies() +go_register_toolchains() + +http_archive( + name = "io_bazel_rules_webtesting", + strip_prefix = "rules_webtesting-master", + urls = [ + "https://github.com/bazelbuild/rules_webtesting/archive/master.tar.gz", + ], +) +load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories") +web_test_repositories() + +git_repository( + name = "build_bazel_rules_nodejs", + remote = "https://github.com/bazelbuild/rules_nodejs.git", + commit = "d334fd8e2274fb939cf447106dced97472534e80", +) +load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") +node_repositories(package_json = ["//:package.json"]) + +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_dependencies") +typescript_proto_dependencies() + +git_repository( + name = "build_bazel_rules_typescript", + remote = "https://github.com/bazelbuild/rules_typescript.git", + commit = "3488d4fb89c6a02d79875d217d1029182fbcd797", +) +load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") +ts_setup_workspace() +``` + +Now in your `BUILD.bazel`: +```python +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_library") + +filegroup( + name = "proto_files", + srcs = glob(["*.proto"]), +) + +proto_library( + name = "proto", + srcs = [ + ":proto_files", + ], +) + +typescript_proto_library( + name = "generate", + proto = ":proto", +) +``` ## Contributing Contributions are welcome! Please refer to [CONTRIBUTING.md](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CONTRIBUTING.md) for more information. diff --git a/WORKSPACE b/WORKSPACE index a9969f9b..2b1ed42f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,29 +16,25 @@ http_archive( urls = [ "https://github.com/bazelbuild/rules_webtesting/archive/master.tar.gz", ], -) + ) load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories") web_test_repositories() git_repository( name = "build_bazel_rules_nodejs", remote = "https://github.com/bazelbuild/rules_nodejs.git", - tag = "0.9.1", + commit = "d334fd8e2274fb939cf447106dced97472534e80", ) -load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "npm_install") +load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") node_repositories(package_json = ["//:package.json"]) -# installs our node_modules -npm_install( - name = "deps", - package_json = "//:package.json", - package_lock_json = "//:package-lock.json", -) +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_dependencies") +typescript_proto_dependencies() git_repository( name = "build_bazel_rules_typescript", remote = "https://github.com/bazelbuild/rules_typescript.git", - tag = "0.14.0", -) + commit = "3488d4fb89c6a02d79875d217d1029182fbcd797", + ) load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") ts_setup_workspace() diff --git a/defs.bzl b/defs.bzl new file mode 100644 index 00000000..8c671b89 --- /dev/null +++ b/defs.bzl @@ -0,0 +1,131 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load("@build_bazel_rules_nodejs//:defs.bzl", "npm_install") + + +def declare_file(ctx, filename, file_modifications): + f = ctx.actions.declare_file(filename) + + # Removes an import that protoc-gen-ts adds that is not needed + for removal in ctx.attr.remove_dependencies: + file_modifications.append("echo \"$(grep -v \"%s\" %s)\" > %s" % (removal, f.path, f.path)) + + return f + +def proto_path(proto): + """ + The proto path is not really a file path + It's the path to the proto that was seen when the descriptor file was generated. + """ + path = proto.path + root = proto.root.path + ws = proto.owner.workspace_root + if path.startswith(root): path = path[len(root):] + if path.startswith("/"): path = path[1:] + if path.startswith(ws): path = path[len(ws):] + if path.startswith("/"): path = path[1:] + return path + +def append_to_outputs(ctx, file_name, outputs, file_modifications): + generated_filenames = ["_pb.d.ts", "_pb.js"] + + if file_name in ctx.attr.services: + generated_filenames += ["_pb_service.js", "_pb_service.d.ts"] + + for f in generated_filenames: + outputs.append(declare_file(ctx, file_name + f, file_modifications)) + +def _typescript_proto_library_impl(ctx): + outputs = [] + proto_inputs = [] + file_modifications = [] + + for src in ctx.attr.proto.proto.direct_sources: + if src.extension != "proto": + fail("Input must be a proto file") + + file_name = src.basename[:-len(src.extension) - 1] + normalized_file = proto_path(src) + proto_inputs.append(normalized_file) + append_to_outputs(ctx, file_name, outputs, file_modifications) + + if not file_modifications: + file_modifications.append("echo \"No services generated\"") + + inputs = depset([ctx.file._protoc]) + inputs += ctx.files._ts_protoc_gen + inputs += ctx.attr.proto.proto.transitive_descriptor_sets + + descriptor_sets = [desc.path for desc in ctx.attr.proto.proto.transitive_descriptor_sets] + + ts_out = "" + if ctx.attr.services: + ts_out = "service=true:" + + protoc_command = "%s --plugin=protoc-gen-ts=%s --ts_out=%s%s --js_out=import_style=commonjs,binary:%s --descriptor_set_in=%s %s" % (ctx.file._protoc.path, ctx.files._ts_protoc_gen[1].path, ts_out, ctx.var["BINDIR"], ctx.var["BINDIR"], ":".join(descriptor_sets), " ".join(proto_inputs)) + + ctx.actions.run_shell( + inputs = inputs, + outputs = outputs, + progress_message = "Creating Typescript pb files %s" % ctx.label, + command = "%s && %s" % (protoc_command, " && ".join(file_modifications)), + ) + + if ctx.attr.debug: + print("protoc command: ", protoc_command) + print("service file modification: ", file_modifications) + print("ctx.var['BINDIR']: ", ctx.var["BINDIR"]) + print("normalized_file: ", normalized_file) + + return DefaultInfo( + files = depset(outputs), + ) + +typescript_proto_library = rule( + attrs = { + "proto": attr.label( + mandatory = True, + allow_files = True, + single_file = True, + providers = ["proto"], + ), + "services": attr.string_list( + doc="An array of service names. Protoc-gen-ts can output additional files for grpc-web. Each element of this array should be the name of the service that will be generated. This is derived from the name of the service. If this proto service is named 'SimpleService', the correct value would be 'simple_service'.", + default = [], + allow_empty = True, + ), + "remove_dependencies": attr.string_list( + doc = "Each string given will be grepped and removed from the generated files. This can be useful if your proto files are importing a dependency that the generated Typescript does not use.", + default = [], + allow_empty = True, + ), + "debug": attr.bool( + doc="Set for additional logging", + mandatory = False, + default = False, + ), + "_ts_protoc_gen": attr.label( + allow_files = True, + executable = True, + cfg = "host", + default = Label("@ts_protoc_gen//bin:protoc-gen-ts"), + ), + "_protoc": attr.label( + allow_files = True, + single_file = True, + executable = True, + cfg = "host", + default = Label("@com_google_protobuf//:protoc"), + ), + }, + implementation = _typescript_proto_library_impl, +) + +def typescript_proto_dependencies(): + """To be run in user's WORKSPACE to install ts-protoc-gen dependencies. +""" + + npm_install( + name = "deps", + package_json = "@ts_protoc_gen//:package.json", + package_lock_json = "@ts_protoc_gen//:package-lock.json", + ) diff --git a/examples/generated/examplecom/simple_service_pb_service.d.ts b/examples/generated/examplecom/simple_service_pb_service.d.ts deleted file mode 100644 index baae01fc..00000000 --- a/examples/generated/examplecom/simple_service_pb_service.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -// package: examplecom -// file: examplecom/simple_service.proto - -import * as examplecom_simple_service_pb from "../examplecom/simple_service_pb"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; -import {grpc} from "grpc-web-client"; - -type SimpleServiceDoUnary = { - readonly methodName: string; - readonly service: typeof SimpleService; - readonly requestStream: false; - readonly responseStream: false; - readonly requestType: typeof examplecom_simple_service_pb.UnaryRequest; - readonly responseType: typeof othercom_external_child_message_pb.ExternalChildMessage; -}; - -type SimpleServiceDoStream = { - readonly methodName: string; - readonly service: typeof SimpleService; - readonly requestStream: false; - readonly responseStream: true; - readonly requestType: typeof examplecom_simple_service_pb.StreamRequest; - readonly responseType: typeof othercom_external_child_message_pb.ExternalChildMessage; -}; - -type SimpleServiceDelete = { - readonly methodName: string; - readonly service: typeof SimpleService; - readonly requestStream: false; - readonly responseStream: false; - readonly requestType: typeof examplecom_simple_service_pb.UnaryRequest; - readonly responseType: typeof examplecom_simple_service_pb.UnaryResponse; -}; - -export class SimpleService { - static readonly serviceName: string; - static readonly DoUnary: SimpleServiceDoUnary; - static readonly DoStream: SimpleServiceDoStream; - static readonly Delete: SimpleServiceDelete; -} - -export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } -export type Status = { details: string, code: number; metadata: grpc.Metadata } -export type ServiceClientOptions = { transport: grpc.TransportConstructor } - -interface ResponseStream { - cancel(): void; - on(type: 'data', handler: (message: T) => void): ResponseStream; - on(type: 'end', handler: () => void): ResponseStream; - on(type: 'status', handler: (status: Status) => void): ResponseStream; -} - -export class SimpleServiceClient { - readonly serviceHost: string; - - constructor(serviceHost: string, options?: ServiceClientOptions); - doUnary( - requestMessage: examplecom_simple_service_pb.UnaryRequest, - metadata: grpc.Metadata, - callback: (error: ServiceError, responseMessage: othercom_external_child_message_pb.ExternalChildMessage|null) => void - ): void; - doUnary( - requestMessage: examplecom_simple_service_pb.UnaryRequest, - callback: (error: ServiceError, responseMessage: othercom_external_child_message_pb.ExternalChildMessage|null) => void - ): void; - doStream(requestMessage: examplecom_simple_service_pb.StreamRequest, metadata?: grpc.Metadata): ResponseStream; - delete( - requestMessage: examplecom_simple_service_pb.UnaryRequest, - metadata: grpc.Metadata, - callback: (error: ServiceError, responseMessage: examplecom_simple_service_pb.UnaryResponse|null) => void - ): void; - delete( - requestMessage: examplecom_simple_service_pb.UnaryRequest, - callback: (error: ServiceError, responseMessage: examplecom_simple_service_pb.UnaryResponse|null) => void - ): void; -} - diff --git a/examples/generated/examplecom/enum_message_pb.d.ts b/examples/generated/proto/examplecom/enum_message_pb.d.ts similarity index 65% rename from examples/generated/examplecom/enum_message_pb.d.ts rename to examples/generated/proto/examplecom/enum_message_pb.d.ts index f7685a16..c1bc93cc 100644 --- a/examples/generated/examplecom/enum_message_pb.d.ts +++ b/examples/generated/proto/examplecom/enum_message_pb.d.ts @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/enum_message.proto +// file: proto/examplecom/enum_message.proto import * as jspb from "google-protobuf"; -import * as othercom_external_enum_pb from "../othercom/external_enum_pb"; +import * as proto_othercom_external_enum_pb from "../../proto/othercom/external_enum_pb"; export class EnumMessage extends jspb.Message { getInternalEnum(): EnumMessage.InternalEnum; @@ -13,13 +13,13 @@ export class EnumMessage extends jspb.Message { setInternalEnumsList(value: Array): void; addInternalEnums(value: EnumMessage.InternalEnum, index?: number): EnumMessage.InternalEnum; - getExternalEnum(): othercom_external_enum_pb.ExternalEnum; - setExternalEnum(value: othercom_external_enum_pb.ExternalEnum): void; + getExternalEnum(): proto_othercom_external_enum_pb.ExternalEnum; + setExternalEnum(value: proto_othercom_external_enum_pb.ExternalEnum): void; clearExternalEnumsList(): void; - getExternalEnumsList(): Array; - setExternalEnumsList(value: Array): void; - addExternalEnums(value: othercom_external_enum_pb.ExternalEnum, index?: number): othercom_external_enum_pb.ExternalEnum; + getExternalEnumsList(): Array; + setExternalEnumsList(value: Array): void; + addExternalEnums(value: proto_othercom_external_enum_pb.ExternalEnum, index?: number): proto_othercom_external_enum_pb.ExternalEnum; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): EnumMessage.AsObject; @@ -35,8 +35,8 @@ export namespace EnumMessage { export type AsObject = { internalEnum: EnumMessage.InternalEnum, internalEnumsList: Array, - externalEnum: othercom_external_enum_pb.ExternalEnum, - externalEnumsList: Array, + externalEnum: proto_othercom_external_enum_pb.ExternalEnum, + externalEnumsList: Array, } export enum InternalEnum { diff --git a/examples/generated/examplecom/enum_message_pb.js b/examples/generated/proto/examplecom/enum_message_pb.js similarity index 98% rename from examples/generated/examplecom/enum_message_pb.js rename to examples/generated/proto/examplecom/enum_message_pb.js index 1581cae1..a84b3503 100644 --- a/examples/generated/examplecom/enum_message_pb.js +++ b/examples/generated/proto/examplecom/enum_message_pb.js @@ -11,7 +11,7 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_enum_pb = require('../othercom/external_enum_pb.js'); +var proto_othercom_external_enum_pb = require('../../proto/othercom/external_enum_pb.js'); goog.exportSymbol('proto.examplecom.EnumMessage', null, global); goog.exportSymbol('proto.examplecom.EnumMessage.InternalEnum', null, global); diff --git a/examples/generated/examplecom/map_message_pb.d.ts b/examples/generated/proto/examplecom/map_message_pb.d.ts similarity index 78% rename from examples/generated/examplecom/map_message_pb.d.ts rename to examples/generated/proto/examplecom/map_message_pb.d.ts index 253138ec..5e74ee8b 100644 --- a/examples/generated/examplecom/map_message_pb.d.ts +++ b/examples/generated/proto/examplecom/map_message_pb.d.ts @@ -1,18 +1,18 @@ // package: examplecom -// file: examplecom/map_message.proto +// file: proto/examplecom/map_message.proto import * as jspb from "google-protobuf"; -import * as othercom_external_enum_pb from "../othercom/external_enum_pb"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; +import * as proto_othercom_external_enum_pb from "../../proto/othercom/external_enum_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; export class MapMessage extends jspb.Message { getInternalEnumsMap(): jspb.Map; clearInternalEnumsMap(): void; getInternalChildrenMap(): jspb.Map; clearInternalChildrenMap(): void; - getExternalEnumsMap(): jspb.Map; + getExternalEnumsMap(): jspb.Map; clearExternalEnumsMap(): void; - getExternalChildrenMap(): jspb.Map; + getExternalChildrenMap(): jspb.Map; clearExternalChildrenMap(): void; getPrimitiveIntsMap(): jspb.Map; clearPrimitiveIntsMap(): void; @@ -30,8 +30,8 @@ export namespace MapMessage { export type AsObject = { internalEnumsMap: Array<[number, MapMessage.InternalEnum]>, internalChildrenMap: Array<[string, MapMessage.InternalChildMessage.AsObject]>, - externalEnumsMap: Array<[number, othercom_external_enum_pb.ExternalEnum]>, - externalChildrenMap: Array<[string, othercom_external_child_message_pb.ExternalChildMessage.AsObject]>, + externalEnumsMap: Array<[number, proto_othercom_external_enum_pb.ExternalEnum]>, + externalChildrenMap: Array<[string, proto_othercom_external_child_message_pb.ExternalChildMessage.AsObject]>, primitiveIntsMap: Array<[string, number]>, } diff --git a/examples/generated/examplecom/map_message_pb.js b/examples/generated/proto/examplecom/map_message_pb.js similarity index 98% rename from examples/generated/examplecom/map_message_pb.js rename to examples/generated/proto/examplecom/map_message_pb.js index a6224ff4..f9ae62cb 100644 --- a/examples/generated/examplecom/map_message_pb.js +++ b/examples/generated/proto/examplecom/map_message_pb.js @@ -11,8 +11,8 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_enum_pb = require('../othercom/external_enum_pb.js'); -var othercom_external_child_message_pb = require('../othercom/external_child_message_pb.js'); +var proto_othercom_external_enum_pb = require('../../proto/othercom/external_enum_pb.js'); +var proto_othercom_external_child_message_pb = require('../../proto/othercom/external_child_message_pb.js'); goog.exportSymbol('proto.examplecom.MapMessage', null, global); goog.exportSymbol('proto.examplecom.MapMessage.InternalChildMessage', null, global); goog.exportSymbol('proto.examplecom.MapMessage.InternalEnum', null, global); diff --git a/examples/generated/examplecom/oneof_message_pb.d.ts b/examples/generated/proto/examplecom/oneof_message_pb.d.ts similarity index 89% rename from examples/generated/examplecom/oneof_message_pb.d.ts rename to examples/generated/proto/examplecom/oneof_message_pb.d.ts index 989bb2e0..c641ba6a 100644 --- a/examples/generated/examplecom/oneof_message_pb.d.ts +++ b/examples/generated/proto/examplecom/oneof_message_pb.d.ts @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/oneof_message.proto +// file: proto/examplecom/oneof_message.proto import * as jspb from "google-protobuf"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; export class OneOfMessage extends jspb.Message { hasInternalChildMessage(): boolean; @@ -12,8 +12,8 @@ export class OneOfMessage extends jspb.Message { hasExternalChildMessage(): boolean; clearExternalChildMessage(): void; - getExternalChildMessage(): othercom_external_child_message_pb.ExternalChildMessage | undefined; - setExternalChildMessage(value?: othercom_external_child_message_pb.ExternalChildMessage): void; + getExternalChildMessage(): proto_othercom_external_child_message_pb.ExternalChildMessage | undefined; + setExternalChildMessage(value?: proto_othercom_external_child_message_pb.ExternalChildMessage): void; hasMyString(): boolean; clearMyString(): void; @@ -39,7 +39,7 @@ export class OneOfMessage extends jspb.Message { export namespace OneOfMessage { export type AsObject = { internalChildMessage?: OneOfMessage.InternalChildMessage.AsObject, - externalChildMessage?: othercom_external_child_message_pb.ExternalChildMessage.AsObject, + externalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage.AsObject, myString: string, myInt64: number, } diff --git a/examples/generated/examplecom/oneof_message_pb.js b/examples/generated/proto/examplecom/oneof_message_pb.js similarity index 97% rename from examples/generated/examplecom/oneof_message_pb.js rename to examples/generated/proto/examplecom/oneof_message_pb.js index cf70a39e..56b080bf 100644 --- a/examples/generated/examplecom/oneof_message_pb.js +++ b/examples/generated/proto/examplecom/oneof_message_pb.js @@ -11,7 +11,7 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_child_message_pb = require('../othercom/external_child_message_pb.js'); +var proto_othercom_external_child_message_pb = require('../../proto/othercom/external_child_message_pb.js'); goog.exportSymbol('proto.examplecom.CamelCasedOneOfMessage', null, global); goog.exportSymbol('proto.examplecom.OneOfMessage', null, global); goog.exportSymbol('proto.examplecom.OneOfMessage.InternalChildMessage', null, global); @@ -91,7 +91,7 @@ proto.examplecom.OneOfMessage.prototype.toObject = function(opt_includeInstance) proto.examplecom.OneOfMessage.toObject = function(includeInstance, msg) { var f, obj = { internalChildMessage: (f = msg.getInternalChildMessage()) && proto.examplecom.OneOfMessage.InternalChildMessage.toObject(includeInstance, f), - externalChildMessage: (f = msg.getExternalChildMessage()) && othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), + externalChildMessage: (f = msg.getExternalChildMessage()) && proto_othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), myString: jspb.Message.getFieldWithDefault(msg, 3, ""), myInt64: jspb.Message.getFieldWithDefault(msg, 4, 0) }; @@ -136,8 +136,8 @@ proto.examplecom.OneOfMessage.deserializeBinaryFromReader = function(msg, reader msg.setInternalChildMessage(value); break; case 2: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.setExternalChildMessage(value); break; case 3: @@ -190,7 +190,7 @@ proto.examplecom.OneOfMessage.serializeBinaryToWriter = function(message, writer writer.writeMessage( 2, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } f = /** @type {string} */ (jspb.Message.getField(message, 3)); @@ -388,7 +388,7 @@ proto.examplecom.OneOfMessage.prototype.hasInternalChildMessage = function() { */ proto.examplecom.OneOfMessage.prototype.getExternalChildMessage = function() { return /** @type{?proto.othercom.ExternalChildMessage} */ ( - jspb.Message.getWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 2)); + jspb.Message.getWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 2)); }; diff --git a/examples/generated/examplecom/parent_message_v2_pb.d.ts b/examples/generated/proto/examplecom/parent_message_v2_pb.d.ts similarity index 70% rename from examples/generated/examplecom/parent_message_v2_pb.d.ts rename to examples/generated/proto/examplecom/parent_message_v2_pb.d.ts index 1c11e6b9..809372f5 100644 --- a/examples/generated/examplecom/parent_message_v2_pb.d.ts +++ b/examples/generated/proto/examplecom/parent_message_v2_pb.d.ts @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/parent_message_v2.proto +// file: proto/examplecom/parent_message_v2.proto import * as jspb from "google-protobuf"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; export class ParentMessageV2 extends jspb.Message { hasInternalChildMessage(): boolean; @@ -22,18 +22,18 @@ export class ParentMessageV2 extends jspb.Message { hasExternalChildMessage(): boolean; clearExternalChildMessage(): void; - getExternalChildMessage(): othercom_external_child_message_pb.ExternalChildMessage; - setExternalChildMessage(value?: othercom_external_child_message_pb.ExternalChildMessage): void; + getExternalChildMessage(): proto_othercom_external_child_message_pb.ExternalChildMessage; + setExternalChildMessage(value?: proto_othercom_external_child_message_pb.ExternalChildMessage): void; hasOptExternalChildMessage(): boolean; clearOptExternalChildMessage(): void; - getOptExternalChildMessage(): othercom_external_child_message_pb.ExternalChildMessage | undefined; - setOptExternalChildMessage(value?: othercom_external_child_message_pb.ExternalChildMessage): void; + getOptExternalChildMessage(): proto_othercom_external_child_message_pb.ExternalChildMessage | undefined; + setOptExternalChildMessage(value?: proto_othercom_external_child_message_pb.ExternalChildMessage): void; clearExternalChildrenList(): void; - getExternalChildrenList(): Array; - setExternalChildrenList(value: Array): void; - addExternalChildren(value?: othercom_external_child_message_pb.ExternalChildMessage, index?: number): othercom_external_child_message_pb.ExternalChildMessage; + getExternalChildrenList(): Array; + setExternalChildrenList(value: Array): void; + addExternalChildren(value?: proto_othercom_external_child_message_pb.ExternalChildMessage, index?: number): proto_othercom_external_child_message_pb.ExternalChildMessage; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ParentMessageV2.AsObject; @@ -50,9 +50,9 @@ export namespace ParentMessageV2 { internalChildMessage: ParentMessageV2.InternalChildMessage.AsObject, optInternalChildMessage?: ParentMessageV2.InternalChildMessage.AsObject, internalChildrenList: Array, - externalChildMessage: othercom_external_child_message_pb.ExternalChildMessage.AsObject, - optExternalChildMessage?: othercom_external_child_message_pb.ExternalChildMessage.AsObject, - externalChildrenList: Array, + externalChildMessage: proto_othercom_external_child_message_pb.ExternalChildMessage.AsObject, + optExternalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage.AsObject, + externalChildrenList: Array, } export class InternalChildMessage extends jspb.Message { diff --git a/examples/generated/examplecom/parent_message_v2_pb.js b/examples/generated/proto/examplecom/parent_message_v2_pb.js similarity index 91% rename from examples/generated/examplecom/parent_message_v2_pb.js rename to examples/generated/proto/examplecom/parent_message_v2_pb.js index 7f6f1256..c343dfc2 100644 --- a/examples/generated/examplecom/parent_message_v2_pb.js +++ b/examples/generated/proto/examplecom/parent_message_v2_pb.js @@ -11,7 +11,7 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_child_message_pb = require('../othercom/external_child_message_pb.js'); +var proto_othercom_external_child_message_pb = require('../../proto/othercom/external_child_message_pb.js'); goog.exportSymbol('proto.examplecom.ParentMessageV2', null, global); goog.exportSymbol('proto.examplecom.ParentMessageV2.InternalChildMessage', null, global); @@ -72,10 +72,10 @@ proto.examplecom.ParentMessageV2.toObject = function(includeInstance, msg) { optInternalChildMessage: (f = msg.getOptInternalChildMessage()) && proto.examplecom.ParentMessageV2.InternalChildMessage.toObject(includeInstance, f), internalChildrenList: jspb.Message.toObjectList(msg.getInternalChildrenList(), proto.examplecom.ParentMessageV2.InternalChildMessage.toObject, includeInstance), - externalChildMessage: (f = msg.getExternalChildMessage()) && othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), - optExternalChildMessage: (f = msg.getOptExternalChildMessage()) && othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), + externalChildMessage: (f = msg.getExternalChildMessage()) && proto_othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), + optExternalChildMessage: (f = msg.getOptExternalChildMessage()) && proto_othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), externalChildrenList: jspb.Message.toObjectList(msg.getExternalChildrenList(), - othercom_external_child_message_pb.ExternalChildMessage.toObject, includeInstance) + proto_othercom_external_child_message_pb.ExternalChildMessage.toObject, includeInstance) }; if (includeInstance) { @@ -128,18 +128,18 @@ proto.examplecom.ParentMessageV2.deserializeBinaryFromReader = function(msg, rea msg.addInternalChildren(value); break; case 4: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.setExternalChildMessage(value); break; case 5: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.setOptExternalChildMessage(value); break; case 6: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.addExternalChildren(value); break; default: @@ -200,7 +200,7 @@ proto.examplecom.ParentMessageV2.serializeBinaryToWriter = function(message, wri writer.writeMessage( 4, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } f = message.getOptExternalChildMessage(); @@ -208,7 +208,7 @@ proto.examplecom.ParentMessageV2.serializeBinaryToWriter = function(message, wri writer.writeMessage( 5, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } f = message.getExternalChildrenList(); @@ -216,7 +216,7 @@ proto.examplecom.ParentMessageV2.serializeBinaryToWriter = function(message, wri writer.writeRepeatedMessage( 6, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } }; @@ -475,7 +475,7 @@ proto.examplecom.ParentMessageV2.prototype.clearInternalChildrenList = function( */ proto.examplecom.ParentMessageV2.prototype.getExternalChildMessage = function() { return /** @type{!proto.othercom.ExternalChildMessage} */ ( - jspb.Message.getWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 4, 1)); + jspb.Message.getWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 4, 1)); }; @@ -505,7 +505,7 @@ proto.examplecom.ParentMessageV2.prototype.hasExternalChildMessage = function() */ proto.examplecom.ParentMessageV2.prototype.getOptExternalChildMessage = function() { return /** @type{?proto.othercom.ExternalChildMessage} */ ( - jspb.Message.getWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 5)); + jspb.Message.getWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 5)); }; @@ -535,7 +535,7 @@ proto.examplecom.ParentMessageV2.prototype.hasOptExternalChildMessage = function */ proto.examplecom.ParentMessageV2.prototype.getExternalChildrenList = function() { return /** @type{!Array.} */ ( - jspb.Message.getRepeatedWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 6)); + jspb.Message.getRepeatedWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 6)); }; diff --git a/examples/generated/examplecom/parent_message_v3_pb.d.ts b/examples/generated/proto/examplecom/parent_message_v3_pb.d.ts similarity index 72% rename from examples/generated/examplecom/parent_message_v3_pb.d.ts rename to examples/generated/proto/examplecom/parent_message_v3_pb.d.ts index 2e237397..8aa18ea7 100644 --- a/examples/generated/examplecom/parent_message_v3_pb.d.ts +++ b/examples/generated/proto/examplecom/parent_message_v3_pb.d.ts @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/parent_message_v3.proto +// file: proto/examplecom/parent_message_v3.proto import * as jspb from "google-protobuf"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; export class ParentMessageV3 extends jspb.Message { hasInternalChildMessage(): boolean; @@ -17,13 +17,13 @@ export class ParentMessageV3 extends jspb.Message { hasExternalChildMessage(): boolean; clearExternalChildMessage(): void; - getExternalChildMessage(): othercom_external_child_message_pb.ExternalChildMessage | undefined; - setExternalChildMessage(value?: othercom_external_child_message_pb.ExternalChildMessage): void; + getExternalChildMessage(): proto_othercom_external_child_message_pb.ExternalChildMessage | undefined; + setExternalChildMessage(value?: proto_othercom_external_child_message_pb.ExternalChildMessage): void; clearExternalChildrenList(): void; - getExternalChildrenList(): Array; - setExternalChildrenList(value: Array): void; - addExternalChildren(value?: othercom_external_child_message_pb.ExternalChildMessage, index?: number): othercom_external_child_message_pb.ExternalChildMessage; + getExternalChildrenList(): Array; + setExternalChildrenList(value: Array): void; + addExternalChildren(value?: proto_othercom_external_child_message_pb.ExternalChildMessage, index?: number): proto_othercom_external_child_message_pb.ExternalChildMessage; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ParentMessageV3.AsObject; @@ -39,8 +39,8 @@ export namespace ParentMessageV3 { export type AsObject = { internalChildMessage?: ParentMessageV3.InternalChildMessage.AsObject, internalChildrenList: Array, - externalChildMessage?: othercom_external_child_message_pb.ExternalChildMessage.AsObject, - externalChildrenList: Array, + externalChildMessage?: proto_othercom_external_child_message_pb.ExternalChildMessage.AsObject, + externalChildrenList: Array, } export class InternalChildMessage extends jspb.Message { diff --git a/examples/generated/examplecom/parent_message_v3_pb.js b/examples/generated/proto/examplecom/parent_message_v3_pb.js similarity index 93% rename from examples/generated/examplecom/parent_message_v3_pb.js rename to examples/generated/proto/examplecom/parent_message_v3_pb.js index df5f000d..f194fc79 100644 --- a/examples/generated/examplecom/parent_message_v3_pb.js +++ b/examples/generated/proto/examplecom/parent_message_v3_pb.js @@ -11,7 +11,7 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_child_message_pb = require('../othercom/external_child_message_pb.js'); +var proto_othercom_external_child_message_pb = require('../../proto/othercom/external_child_message_pb.js'); goog.exportSymbol('proto.examplecom.ParentMessageV3', null, global); goog.exportSymbol('proto.examplecom.ParentMessageV3.InternalChildMessage', null, global); @@ -71,9 +71,9 @@ proto.examplecom.ParentMessageV3.toObject = function(includeInstance, msg) { internalChildMessage: (f = msg.getInternalChildMessage()) && proto.examplecom.ParentMessageV3.InternalChildMessage.toObject(includeInstance, f), internalChildrenList: jspb.Message.toObjectList(msg.getInternalChildrenList(), proto.examplecom.ParentMessageV3.InternalChildMessage.toObject, includeInstance), - externalChildMessage: (f = msg.getExternalChildMessage()) && othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), + externalChildMessage: (f = msg.getExternalChildMessage()) && proto_othercom_external_child_message_pb.ExternalChildMessage.toObject(includeInstance, f), externalChildrenList: jspb.Message.toObjectList(msg.getExternalChildrenList(), - othercom_external_child_message_pb.ExternalChildMessage.toObject, includeInstance) + proto_othercom_external_child_message_pb.ExternalChildMessage.toObject, includeInstance) }; if (includeInstance) { @@ -121,13 +121,13 @@ proto.examplecom.ParentMessageV3.deserializeBinaryFromReader = function(msg, rea msg.addInternalChildren(value); break; case 3: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.setExternalChildMessage(value); break; case 4: - var value = new othercom_external_child_message_pb.ExternalChildMessage; - reader.readMessage(value,othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); + var value = new proto_othercom_external_child_message_pb.ExternalChildMessage; + reader.readMessage(value,proto_othercom_external_child_message_pb.ExternalChildMessage.deserializeBinaryFromReader); msg.addExternalChildren(value); break; default: @@ -180,7 +180,7 @@ proto.examplecom.ParentMessageV3.serializeBinaryToWriter = function(message, wri writer.writeMessage( 3, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } f = message.getExternalChildrenList(); @@ -188,7 +188,7 @@ proto.examplecom.ParentMessageV3.serializeBinaryToWriter = function(message, wri writer.writeRepeatedMessage( 4, f, - othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter + proto_othercom_external_child_message_pb.ExternalChildMessage.serializeBinaryToWriter ); } }; @@ -403,7 +403,7 @@ proto.examplecom.ParentMessageV3.prototype.clearInternalChildrenList = function( */ proto.examplecom.ParentMessageV3.prototype.getExternalChildMessage = function() { return /** @type{?proto.othercom.ExternalChildMessage} */ ( - jspb.Message.getWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 3)); + jspb.Message.getWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 3)); }; @@ -433,7 +433,7 @@ proto.examplecom.ParentMessageV3.prototype.hasExternalChildMessage = function() */ proto.examplecom.ParentMessageV3.prototype.getExternalChildrenList = function() { return /** @type{!Array.} */ ( - jspb.Message.getRepeatedWrapperField(this, othercom_external_child_message_pb.ExternalChildMessage, 4)); + jspb.Message.getRepeatedWrapperField(this, proto_othercom_external_child_message_pb.ExternalChildMessage, 4)); }; diff --git a/examples/generated/examplecom/primitive_message_v2_pb.d.ts b/examples/generated/proto/examplecom/primitive_message_v2_pb.d.ts similarity index 99% rename from examples/generated/examplecom/primitive_message_v2_pb.d.ts rename to examples/generated/proto/examplecom/primitive_message_v2_pb.d.ts index fb999013..8cd1dfe1 100644 --- a/examples/generated/examplecom/primitive_message_v2_pb.d.ts +++ b/examples/generated/proto/examplecom/primitive_message_v2_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/primitive_message_v2.proto +// file: proto/examplecom/primitive_message_v2.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/examplecom/primitive_message_v2_pb.js b/examples/generated/proto/examplecom/primitive_message_v2_pb.js similarity index 100% rename from examples/generated/examplecom/primitive_message_v2_pb.js rename to examples/generated/proto/examplecom/primitive_message_v2_pb.js diff --git a/examples/generated/examplecom/primitive_message_v3_pb.d.ts b/examples/generated/proto/examplecom/primitive_message_v3_pb.d.ts similarity index 97% rename from examples/generated/examplecom/primitive_message_v3_pb.d.ts rename to examples/generated/proto/examplecom/primitive_message_v3_pb.d.ts index 3595ad9a..2f8b1f49 100644 --- a/examples/generated/examplecom/primitive_message_v3_pb.d.ts +++ b/examples/generated/proto/examplecom/primitive_message_v3_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/primitive_message_v3.proto +// file: proto/examplecom/primitive_message_v3.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/examplecom/primitive_message_v3_pb.js b/examples/generated/proto/examplecom/primitive_message_v3_pb.js similarity index 100% rename from examples/generated/examplecom/primitive_message_v3_pb.js rename to examples/generated/proto/examplecom/primitive_message_v3_pb.js diff --git a/examples/generated/examplecom/repeated_primitive_message_pb.d.ts b/examples/generated/proto/examplecom/repeated_primitive_message_pb.d.ts similarity index 98% rename from examples/generated/examplecom/repeated_primitive_message_pb.d.ts rename to examples/generated/proto/examplecom/repeated_primitive_message_pb.d.ts index b7cab6e6..2492a87c 100644 --- a/examples/generated/examplecom/repeated_primitive_message_pb.d.ts +++ b/examples/generated/proto/examplecom/repeated_primitive_message_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/repeated_primitive_message.proto +// file: proto/examplecom/repeated_primitive_message.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/examplecom/repeated_primitive_message_pb.js b/examples/generated/proto/examplecom/repeated_primitive_message_pb.js similarity index 100% rename from examples/generated/examplecom/repeated_primitive_message_pb.js rename to examples/generated/proto/examplecom/repeated_primitive_message_pb.js diff --git a/examples/generated/examplecom/reserved_words_pb.d.ts b/examples/generated/proto/examplecom/reserved_words_pb.d.ts similarity index 99% rename from examples/generated/examplecom/reserved_words_pb.d.ts rename to examples/generated/proto/examplecom/reserved_words_pb.d.ts index 99547c63..b6b11613 100644 --- a/examples/generated/examplecom/reserved_words_pb.d.ts +++ b/examples/generated/proto/examplecom/reserved_words_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/reserved_words.proto +// file: proto/examplecom/reserved_words.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/examplecom/reserved_words_pb.js b/examples/generated/proto/examplecom/reserved_words_pb.js similarity index 100% rename from examples/generated/examplecom/reserved_words_pb.js rename to examples/generated/proto/examplecom/reserved_words_pb.js diff --git a/examples/generated/examplecom/simple_pb.d.ts b/examples/generated/proto/examplecom/simple_pb.d.ts similarity index 99% rename from examples/generated/examplecom/simple_pb.d.ts rename to examples/generated/proto/examplecom/simple_pb.d.ts index debb2dd4..9384ef61 100644 --- a/examples/generated/examplecom/simple_pb.d.ts +++ b/examples/generated/proto/examplecom/simple_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/simple.proto +// file: proto/examplecom/simple.proto import * as jspb from "google-protobuf"; import * as google_protobuf_compiler_plugin_pb from "google-protobuf/google/protobuf/compiler/plugin_pb"; diff --git a/examples/generated/examplecom/simple_pb.js b/examples/generated/proto/examplecom/simple_pb.js similarity index 100% rename from examples/generated/examplecom/simple_pb.js rename to examples/generated/proto/examplecom/simple_pb.js diff --git a/examples/generated/examplecom/simple_service_pb.d.ts b/examples/generated/proto/examplecom/simple_service_pb.d.ts similarity index 94% rename from examples/generated/examplecom/simple_service_pb.d.ts rename to examples/generated/proto/examplecom/simple_service_pb.d.ts index eaf21250..f8c9f620 100644 --- a/examples/generated/examplecom/simple_service_pb.d.ts +++ b/examples/generated/proto/examplecom/simple_service_pb.d.ts @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/simple_service.proto +// file: proto/examplecom/simple_service.proto import * as jspb from "google-protobuf"; -import * as othercom_external_child_message_pb from "../othercom/external_child_message_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; export class UnaryRequest extends jspb.Message { diff --git a/examples/generated/examplecom/simple_service_pb.js b/examples/generated/proto/examplecom/simple_service_pb.js similarity index 99% rename from examples/generated/examplecom/simple_service_pb.js rename to examples/generated/proto/examplecom/simple_service_pb.js index 2ad02d30..1b4b5107 100644 --- a/examples/generated/examplecom/simple_service_pb.js +++ b/examples/generated/proto/examplecom/simple_service_pb.js @@ -11,7 +11,7 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); -var othercom_external_child_message_pb = require('../othercom/external_child_message_pb.js'); +var proto_othercom_external_child_message_pb = require('../../proto/othercom/external_child_message_pb.js'); var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); goog.exportSymbol('proto.examplecom.StreamRequest', null, global); goog.exportSymbol('proto.examplecom.UnaryRequest', null, global); diff --git a/examples/generated/proto/examplecom/simple_service_pb_service.d.ts b/examples/generated/proto/examplecom/simple_service_pb_service.d.ts new file mode 100644 index 00000000..ddafbea9 --- /dev/null +++ b/examples/generated/proto/examplecom/simple_service_pb_service.d.ts @@ -0,0 +1,77 @@ +// package: examplecom +// file: proto/examplecom/simple_service.proto + +import * as proto_examplecom_simple_service_pb from "../../proto/examplecom/simple_service_pb"; +import * as proto_othercom_external_child_message_pb from "../../proto/othercom/external_child_message_pb"; +import {grpc} from "grpc-web-client"; + +type SimpleServiceDoUnary = { + readonly methodName: string; + readonly service: typeof SimpleService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof proto_examplecom_simple_service_pb.UnaryRequest; + readonly responseType: typeof proto_othercom_external_child_message_pb.ExternalChildMessage; +}; + +type SimpleServiceDoStream = { + readonly methodName: string; + readonly service: typeof SimpleService; + readonly requestStream: false; + readonly responseStream: true; + readonly requestType: typeof proto_examplecom_simple_service_pb.StreamRequest; + readonly responseType: typeof proto_othercom_external_child_message_pb.ExternalChildMessage; +}; + +type SimpleServiceDelete = { + readonly methodName: string; + readonly service: typeof SimpleService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof proto_examplecom_simple_service_pb.UnaryRequest; + readonly responseType: typeof proto_examplecom_simple_service_pb.UnaryResponse; +}; + +export class SimpleService { + static readonly serviceName: string; + static readonly DoUnary: SimpleServiceDoUnary; + static readonly DoStream: SimpleServiceDoStream; + static readonly Delete: SimpleServiceDelete; +} + +export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } +export type Status = { details: string, code: number; metadata: grpc.Metadata } +export type ServiceClientOptions = { transport: grpc.TransportConstructor } + +interface ResponseStream { + cancel(): void; + on(type: 'data', handler: (message: T) => void): ResponseStream; + on(type: 'end', handler: () => void): ResponseStream; + on(type: 'status', handler: (status: Status) => void): ResponseStream; +} + +export class SimpleServiceClient { + readonly serviceHost: string; + + constructor(serviceHost: string, options?: ServiceClientOptions); + doUnary( + requestMessage: proto_examplecom_simple_service_pb.UnaryRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError, responseMessage: proto_othercom_external_child_message_pb.ExternalChildMessage|null) => void + ): void; + doUnary( + requestMessage: proto_examplecom_simple_service_pb.UnaryRequest, + callback: (error: ServiceError, responseMessage: proto_othercom_external_child_message_pb.ExternalChildMessage|null) => void + ): void; + doStream(requestMessage: proto_examplecom_simple_service_pb.StreamRequest, metadata?: grpc.Metadata): ResponseStream; + delete( + requestMessage: proto_examplecom_simple_service_pb.UnaryRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError, responseMessage: proto_examplecom_simple_service_pb.UnaryResponse|null) => void + ): void; + delete( + requestMessage: proto_examplecom_simple_service_pb.UnaryRequest, + callback: (error: ServiceError, responseMessage: proto_examplecom_simple_service_pb.UnaryResponse|null) => void + ): void; +} + diff --git a/examples/generated/examplecom/simple_service_pb_service.js b/examples/generated/proto/examplecom/simple_service_pb_service.js similarity index 82% rename from examples/generated/examplecom/simple_service_pb_service.js rename to examples/generated/proto/examplecom/simple_service_pb_service.js index 999d0079..0fa10b35 100644 --- a/examples/generated/examplecom/simple_service_pb_service.js +++ b/examples/generated/proto/examplecom/simple_service_pb_service.js @@ -1,8 +1,8 @@ // package: examplecom -// file: examplecom/simple_service.proto +// file: proto/examplecom/simple_service.proto -var examplecom_simple_service_pb = require("../examplecom/simple_service_pb"); -var othercom_external_child_message_pb = require("../othercom/external_child_message_pb"); +var proto_examplecom_simple_service_pb = require("../../proto/examplecom/simple_service_pb"); +var proto_othercom_external_child_message_pb = require("../../proto/othercom/external_child_message_pb"); var grpc = require("grpc-web-client").grpc; var SimpleService = (function () { @@ -16,8 +16,8 @@ SimpleService.DoUnary = { service: SimpleService, requestStream: false, responseStream: false, - requestType: examplecom_simple_service_pb.UnaryRequest, - responseType: othercom_external_child_message_pb.ExternalChildMessage + requestType: proto_examplecom_simple_service_pb.UnaryRequest, + responseType: proto_othercom_external_child_message_pb.ExternalChildMessage }; SimpleService.DoStream = { @@ -25,8 +25,8 @@ SimpleService.DoStream = { service: SimpleService, requestStream: false, responseStream: true, - requestType: examplecom_simple_service_pb.StreamRequest, - responseType: othercom_external_child_message_pb.ExternalChildMessage + requestType: proto_examplecom_simple_service_pb.StreamRequest, + responseType: proto_othercom_external_child_message_pb.ExternalChildMessage }; SimpleService.Delete = { @@ -34,8 +34,8 @@ SimpleService.Delete = { service: SimpleService, requestStream: false, responseStream: false, - requestType: examplecom_simple_service_pb.UnaryRequest, - responseType: examplecom_simple_service_pb.UnaryResponse + requestType: proto_examplecom_simple_service_pb.UnaryRequest, + responseType: proto_examplecom_simple_service_pb.UnaryResponse }; exports.SimpleService = SimpleService; diff --git a/examples/generated/examplecom/simplevalue_pb.d.ts b/examples/generated/proto/examplecom/simplevalue_pb.d.ts similarity index 98% rename from examples/generated/examplecom/simplevalue_pb.d.ts rename to examples/generated/proto/examplecom/simplevalue_pb.d.ts index 14ef2f49..79da301f 100644 --- a/examples/generated/examplecom/simplevalue_pb.d.ts +++ b/examples/generated/proto/examplecom/simplevalue_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/simplevalue.proto +// file: proto/examplecom/simplevalue.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/examplecom/simplevalue_pb.js b/examples/generated/proto/examplecom/simplevalue_pb.js similarity index 100% rename from examples/generated/examplecom/simplevalue_pb.js rename to examples/generated/proto/examplecom/simplevalue_pb.js diff --git a/examples/generated/examplecom/well_known_message_pb.d.ts b/examples/generated/proto/examplecom/well_known_message_pb.d.ts similarity index 99% rename from examples/generated/examplecom/well_known_message_pb.d.ts rename to examples/generated/proto/examplecom/well_known_message_pb.d.ts index 32d5639d..a970a7e1 100644 --- a/examples/generated/examplecom/well_known_message_pb.d.ts +++ b/examples/generated/proto/examplecom/well_known_message_pb.d.ts @@ -1,5 +1,5 @@ // package: examplecom -// file: examplecom/well_known_message.proto +// file: proto/examplecom/well_known_message.proto import * as jspb from "google-protobuf"; import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb"; diff --git a/examples/generated/examplecom/well_known_message_pb.js b/examples/generated/proto/examplecom/well_known_message_pb.js similarity index 100% rename from examples/generated/examplecom/well_known_message_pb.js rename to examples/generated/proto/examplecom/well_known_message_pb.js diff --git a/examples/generated/orphan_pb.d.ts b/examples/generated/proto/orphan_pb.d.ts similarity index 99% rename from examples/generated/orphan_pb.d.ts rename to examples/generated/proto/orphan_pb.d.ts index e918cec7..24026c84 100644 --- a/examples/generated/orphan_pb.d.ts +++ b/examples/generated/proto/orphan_pb.d.ts @@ -1,5 +1,5 @@ // package: -// file: orphan.proto +// file: proto/orphan.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/orphan_pb.js b/examples/generated/proto/orphan_pb.js similarity index 100% rename from examples/generated/orphan_pb.js rename to examples/generated/proto/orphan_pb.js diff --git a/examples/generated/orphan_pb_service.d.ts b/examples/generated/proto/orphan_pb_service.d.ts similarity index 61% rename from examples/generated/orphan_pb_service.d.ts rename to examples/generated/proto/orphan_pb_service.d.ts index 1cfd54c2..ede90559 100644 --- a/examples/generated/orphan_pb_service.d.ts +++ b/examples/generated/proto/orphan_pb_service.d.ts @@ -1,7 +1,7 @@ // package: -// file: orphan.proto +// file: proto/orphan.proto -import * as orphan_pb from "./orphan_pb"; +import * as proto_orphan_pb from "../proto/orphan_pb"; import {grpc} from "grpc-web-client"; type OrphanServiceDoUnary = { @@ -9,8 +9,8 @@ type OrphanServiceDoUnary = { readonly service: typeof OrphanService; readonly requestStream: false; readonly responseStream: false; - readonly requestType: typeof orphan_pb.OrphanUnaryRequest; - readonly responseType: typeof orphan_pb.OrphanMessage; + readonly requestType: typeof proto_orphan_pb.OrphanUnaryRequest; + readonly responseType: typeof proto_orphan_pb.OrphanMessage; }; type OrphanServiceDoStream = { @@ -18,8 +18,8 @@ type OrphanServiceDoStream = { readonly service: typeof OrphanService; readonly requestStream: false; readonly responseStream: true; - readonly requestType: typeof orphan_pb.OrphanStreamRequest; - readonly responseType: typeof orphan_pb.OrphanMessage; + readonly requestType: typeof proto_orphan_pb.OrphanStreamRequest; + readonly responseType: typeof proto_orphan_pb.OrphanMessage; }; export class OrphanService { @@ -44,14 +44,14 @@ export class OrphanServiceClient { constructor(serviceHost: string, options?: ServiceClientOptions); doUnary( - requestMessage: orphan_pb.OrphanUnaryRequest, + requestMessage: proto_orphan_pb.OrphanUnaryRequest, metadata: grpc.Metadata, - callback: (error: ServiceError, responseMessage: orphan_pb.OrphanMessage|null) => void + callback: (error: ServiceError, responseMessage: proto_orphan_pb.OrphanMessage|null) => void ): void; doUnary( - requestMessage: orphan_pb.OrphanUnaryRequest, - callback: (error: ServiceError, responseMessage: orphan_pb.OrphanMessage|null) => void + requestMessage: proto_orphan_pb.OrphanUnaryRequest, + callback: (error: ServiceError, responseMessage: proto_orphan_pb.OrphanMessage|null) => void ): void; - doStream(requestMessage: orphan_pb.OrphanStreamRequest, metadata?: grpc.Metadata): ResponseStream; + doStream(requestMessage: proto_orphan_pb.OrphanStreamRequest, metadata?: grpc.Metadata): ResponseStream; } diff --git a/examples/generated/orphan_pb_service.js b/examples/generated/proto/orphan_pb_service.js similarity index 89% rename from examples/generated/orphan_pb_service.js rename to examples/generated/proto/orphan_pb_service.js index fad256d4..c8c4583c 100644 --- a/examples/generated/orphan_pb_service.js +++ b/examples/generated/proto/orphan_pb_service.js @@ -1,7 +1,7 @@ // package: -// file: orphan.proto +// file: proto/orphan.proto -var orphan_pb = require("./orphan_pb"); +var proto_orphan_pb = require("../proto/orphan_pb"); var grpc = require("grpc-web-client").grpc; var OrphanService = (function () { @@ -15,8 +15,8 @@ OrphanService.DoUnary = { service: OrphanService, requestStream: false, responseStream: false, - requestType: orphan_pb.OrphanUnaryRequest, - responseType: orphan_pb.OrphanMessage + requestType: proto_orphan_pb.OrphanUnaryRequest, + responseType: proto_orphan_pb.OrphanMessage }; OrphanService.DoStream = { @@ -24,8 +24,8 @@ OrphanService.DoStream = { service: OrphanService, requestStream: false, responseStream: true, - requestType: orphan_pb.OrphanStreamRequest, - responseType: orphan_pb.OrphanMessage + requestType: proto_orphan_pb.OrphanStreamRequest, + responseType: proto_orphan_pb.OrphanMessage }; exports.OrphanService = OrphanService; diff --git a/examples/generated/othercom/external_child_message_pb.d.ts b/examples/generated/proto/othercom/external_child_message_pb.d.ts similarity index 94% rename from examples/generated/othercom/external_child_message_pb.d.ts rename to examples/generated/proto/othercom/external_child_message_pb.d.ts index 01adaec8..569e5857 100644 --- a/examples/generated/othercom/external_child_message_pb.d.ts +++ b/examples/generated/proto/othercom/external_child_message_pb.d.ts @@ -1,5 +1,5 @@ // package: othercom -// file: othercom/external_child_message.proto +// file: proto/othercom/external_child_message.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/othercom/external_child_message_pb.js b/examples/generated/proto/othercom/external_child_message_pb.js similarity index 100% rename from examples/generated/othercom/external_child_message_pb.js rename to examples/generated/proto/othercom/external_child_message_pb.js diff --git a/examples/generated/othercom/external_enum_pb.d.ts b/examples/generated/proto/othercom/external_enum_pb.d.ts similarity index 75% rename from examples/generated/othercom/external_enum_pb.d.ts rename to examples/generated/proto/othercom/external_enum_pb.d.ts index d28ec159..e9e8b3af 100644 --- a/examples/generated/othercom/external_enum_pb.d.ts +++ b/examples/generated/proto/othercom/external_enum_pb.d.ts @@ -1,5 +1,5 @@ // package: othercom -// file: othercom/external_enum.proto +// file: proto/othercom/external_enum.proto import * as jspb from "google-protobuf"; diff --git a/examples/generated/othercom/external_enum_pb.js b/examples/generated/proto/othercom/external_enum_pb.js similarity index 100% rename from examples/generated/othercom/external_enum_pb.js rename to examples/generated/proto/othercom/external_enum_pb.js diff --git a/generate.sh b/generate.sh index 4714a03c..0e22382a 100755 --- a/generate.sh +++ b/generate.sh @@ -40,16 +40,15 @@ if [ -d "$EXAMPLES_GENERATED_DIR" ] then rm -rf "$EXAMPLES_GENERATED_DIR" fi -mkdir "$EXAMPLES_GENERATED_DIR" +mkdir -p "$EXAMPLES_GENERATED_DIR" $PROTOC \ --plugin=protoc-gen-ts=./bin/protoc-gen-ts \ --js_out=import_style=commonjs,binary:$EXAMPLES_GENERATED_DIR \ --ts_out=service=true:$EXAMPLES_GENERATED_DIR \ - -I ./proto \ ./proto/othercom/*.proto \ ./proto/examplecom/*.proto \ ./proto/*.proto # Cleanup downloaded proto directory -rm -r protoc \ No newline at end of file +rm -r protoc diff --git a/package-lock.json b/package-lock.json index da33c2c9..fd772715 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.1" } }, "argparse": { @@ -55,7 +55,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "arrify": { @@ -82,9 +82,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" }, "dependencies": { "ansi-styles": { @@ -99,11 +99,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "supports-color": { @@ -126,7 +126,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -160,9 +160,9 @@ "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "deep-eql": "^0.1.3", - "type-detect": "^1.0.0" + "assertion-error": "1.1.0", + "deep-eql": "0.1.3", + "type-detect": "1.0.0" } }, "chalk": { @@ -171,9 +171,9 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" }, "dependencies": { "has-flag": { @@ -188,7 +188,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } } } @@ -199,7 +199,7 @@ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -282,12 +282,12 @@ "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.2", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "google-protobuf": { @@ -307,7 +307,7 @@ "integrity": "sha512-AcLecuqaDp5STYXGViTQmNTCoZVfM6gi3+hvfTGXGP5YTIimASesNi39jnP8dox3x8QBelMWDdOck5/4UJaZdg==", "dev": true, "requires": { - "browser-headers": "^0.4.0" + "browser-headers": "0.4.0" } }, "has-ansi": { @@ -316,7 +316,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-flag": { @@ -337,8 +337,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -359,8 +359,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.10", + "esprima": "4.0.0" } }, "lodash": { @@ -387,7 +387,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -436,12 +436,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } } } @@ -452,8 +452,8 @@ "integrity": "sha1-iBxKCDcKn3bbFQ+yMFTjDMPjcnA=", "dev": true, "requires": { - "mocha": "^5.0.2", - "moment": "^2.21.0" + "mocha": "5.2.0", + "moment": "2.22.1" }, "dependencies": { "browser-stdout": { @@ -489,12 +489,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "growl": { @@ -534,7 +534,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } } } @@ -557,7 +557,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "path-is-absolute": { @@ -578,7 +578,7 @@ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } }, "semver": { @@ -599,7 +599,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "^0.5.6" + "source-map": "0.5.7" } }, "sprintf-js": { @@ -614,7 +614,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "supports-color": { @@ -623,7 +623,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } }, "ts-node": { @@ -632,14 +632,14 @@ "integrity": "sha512-XK7QmDcNHVmZkVtkiwNDWiERRHPyU8nBqZB1+iv2UhOG0q3RQ9HsZ2CMqISlFbxjrYFGfG2mX7bW4dAyxBVzUw==", "dev": true, "requires": { - "arrify": "^1.0.0", - "chalk": "^2.3.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.3", - "yn": "^2.0.0" + "arrify": "1.0.1", + "chalk": "2.4.1", + "diff": "3.2.0", + "make-error": "1.3.4", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "source-map-support": "0.5.6", + "yn": "2.0.0" }, "dependencies": { "minimist": { @@ -660,8 +660,8 @@ "integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" + "buffer-from": "1.0.0", + "source-map": "0.6.1" } } } @@ -678,18 +678,18 @@ "integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=", "dev": true, "requires": { - "babel-code-frame": "^6.22.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.7.0", - "minimatch": "^3.0.4", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.12.1" + "babel-code-frame": "6.26.0", + "builtin-modules": "1.1.1", + "chalk": "2.4.1", + "commander": "2.15.1", + "diff": "3.2.0", + "glob": "7.1.1", + "js-yaml": "3.11.0", + "minimatch": "3.0.4", + "resolve": "1.7.1", + "semver": "5.5.0", + "tslib": "1.9.1", + "tsutils": "2.27.1" }, "dependencies": { "commander": { @@ -706,7 +706,7 @@ "integrity": "sha512-AE/7uzp32MmaHvNNFES85hhUDHFdFZp6OAiZcd6y4ZKKIg6orJTm8keYWBhIhrJQH3a4LzNKat7ZPXZt5aTf6w==", "dev": true, "requires": { - "tslib": "^1.8.1" + "tslib": "1.9.1" } }, "type-detect": { diff --git a/proto/BUILD b/proto/BUILD new file mode 100644 index 00000000..f997fec0 --- /dev/null +++ b/proto/BUILD @@ -0,0 +1,22 @@ +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_library") +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "proto_files", + srcs = glob(["*.proto"]), +) + +proto_library( + name = "proto", + srcs = [ + ":proto_files", + ], +) + +typescript_proto_library( + name = "generate", + proto = ":proto", + services = [ + "orphan", + ], +) diff --git a/proto/examplecom/BUILD b/proto/examplecom/BUILD new file mode 100644 index 00000000..29e1eea5 --- /dev/null +++ b/proto/examplecom/BUILD @@ -0,0 +1,37 @@ +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_library") +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "proto_files", + srcs = glob(["*.proto"]), +) + +proto_library( + name = "proto", + srcs = [ + ":proto_files", + ], + deps = [ + "//proto/othercom:proto", + "@com_google_protobuf//:compiler_plugin_proto", + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:source_context_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", + "@com_google_protobuf//:wrappers_proto", + ], +) + +typescript_proto_library( + name = "generate", + proto = ":proto", + services = [ + "simple_service", + ], +) diff --git a/proto/examplecom/enum_message.proto b/proto/examplecom/enum_message.proto index db11f682..d5486d04 100644 --- a/proto/examplecom/enum_message.proto +++ b/proto/examplecom/enum_message.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package examplecom; -import "othercom/external_enum.proto"; +import "proto/othercom/external_enum.proto"; message EnumMessage { enum InternalEnum { diff --git a/proto/examplecom/map_message.proto b/proto/examplecom/map_message.proto index fb33e8fb..99ffbbec 100644 --- a/proto/examplecom/map_message.proto +++ b/proto/examplecom/map_message.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package examplecom; -import "othercom/external_enum.proto"; -import "othercom/external_child_message.proto"; +import "proto/othercom/external_enum.proto"; +import "proto/othercom/external_child_message.proto"; message MapMessage { enum InternalEnum { diff --git a/proto/examplecom/oneof_message.proto b/proto/examplecom/oneof_message.proto index ec037406..ba23d676 100644 --- a/proto/examplecom/oneof_message.proto +++ b/proto/examplecom/oneof_message.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package examplecom; -import "othercom/external_child_message.proto"; +import "proto/othercom/external_child_message.proto"; message OneOfMessage { message InternalChildMessage { diff --git a/proto/examplecom/parent_message_v2.proto b/proto/examplecom/parent_message_v2.proto index 3c57d202..d9268424 100644 --- a/proto/examplecom/parent_message_v2.proto +++ b/proto/examplecom/parent_message_v2.proto @@ -2,7 +2,7 @@ syntax = "proto2"; package examplecom; -import "othercom/external_child_message.proto"; +import "proto/othercom/external_child_message.proto"; message ParentMessageV2 { message InternalChildMessage { diff --git a/proto/examplecom/parent_message_v3.proto b/proto/examplecom/parent_message_v3.proto index 4a733800..bafa6e05 100644 --- a/proto/examplecom/parent_message_v3.proto +++ b/proto/examplecom/parent_message_v3.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package examplecom; -import "othercom/external_child_message.proto"; +import "proto/othercom/external_child_message.proto"; message ParentMessageV3 { message InternalChildMessage { diff --git a/proto/examplecom/simple_service.proto b/proto/examplecom/simple_service.proto index c50cdddb..dcd5feb2 100644 --- a/proto/examplecom/simple_service.proto +++ b/proto/examplecom/simple_service.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package examplecom; -import "othercom/external_child_message.proto"; +import "proto/othercom/external_child_message.proto"; // this import should not be output in the generated typescript service import "google/protobuf/timestamp.proto"; diff --git a/proto/othercom/BUILD b/proto/othercom/BUILD new file mode 100644 index 00000000..d78d550f --- /dev/null +++ b/proto/othercom/BUILD @@ -0,0 +1,19 @@ +load("@ts_protoc_gen//:defs.bzl", "typescript_proto_library") +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "proto_files", + srcs = glob(["*.proto"]), +) + +proto_library( + name = "proto", + srcs = [ + ":proto_files", + ], +) + +typescript_proto_library( + name = "generate", + proto = ":proto", +) diff --git a/test/integration/enums.ts b/test/integration/enums.ts index 5aa21563..9b4231ac 100644 --- a/test/integration/enums.ts +++ b/test/integration/enums.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import {EnumMessage} from "../../examples/generated/examplecom/enum_message_pb"; -import {ExternalEnum} from "../../examples/generated/othercom/external_enum_pb"; +import {EnumMessage} from "../../examples/generated/proto/examplecom/enum_message_pb"; +import {ExternalEnum} from "../../examples/generated/proto/othercom/external_enum_pb"; import InternalEnum = EnumMessage.InternalEnum; describe("internal enums", () => { @@ -49,4 +49,4 @@ describe("enum casing", () => { parentMsg.setInternalEnum(InternalEnum.THIRD); // should compile. assert.ok(true, ".d.ts file should export the enum definition in ALL_CAPS"); }); -}); \ No newline at end of file +}); diff --git a/test/integration/maps.ts b/test/integration/maps.ts index 16bca99a..c635f3c8 100644 --- a/test/integration/maps.ts +++ b/test/integration/maps.ts @@ -1,10 +1,10 @@ import {assert} from "chai"; -import {MapMessage} from "../../examples/generated/examplecom/map_message_pb"; -import {ExternalEnum} from "../../examples/generated/othercom/external_enum_pb"; -import {ExternalChildMessage} from "../../examples/generated/othercom/external_child_message_pb"; +import {MapMessage} from "../../examples/generated/proto/examplecom/map_message_pb"; +import {ExternalEnum} from "../../examples/generated/proto/othercom/external_enum_pb"; +import {ExternalChildMessage} from "../../examples/generated/proto/othercom/external_child_message_pb"; import InternalEnum = MapMessage.InternalEnum; import InternalChildMessage = MapMessage.InternalChildMessage; -import {OrphanMapMessage} from "../../examples/generated/orphan_pb"; +import {OrphanMapMessage} from "../../examples/generated/proto/orphan_pb"; describe("maps", () => { describe("message maps", () => { diff --git a/test/integration/nestedMessagesV2.ts b/test/integration/nestedMessagesV2.ts index c667fe76..80bdd20e 100644 --- a/test/integration/nestedMessagesV2.ts +++ b/test/integration/nestedMessagesV2.ts @@ -1,7 +1,7 @@ import {assert} from "chai"; -import {ParentMessageV2} from "../../examples/generated/examplecom/parent_message_v2_pb"; +import {ParentMessageV2} from "../../examples/generated/proto/examplecom/parent_message_v2_pb"; import InternalChildMessage = ParentMessageV2.InternalChildMessage; -import {ExternalChildMessage} from "../../examples/generated/othercom/external_child_message_pb"; +import {ExternalChildMessage} from "../../examples/generated/proto/othercom/external_child_message_pb"; describe("proto2 - internal nested messages", () => { it("should allow getting internal message fields on an empty message", () => { diff --git a/test/integration/nestedMessagesV3.ts b/test/integration/nestedMessagesV3.ts index d5b8bfe6..1509f1a7 100644 --- a/test/integration/nestedMessagesV3.ts +++ b/test/integration/nestedMessagesV3.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import {ParentMessageV3} from "../../examples/generated/examplecom/parent_message_v3_pb"; -import {ExternalChildMessage} from "../../examples/generated/othercom/external_child_message_pb"; +import {ParentMessageV3} from "../../examples/generated/proto/examplecom/parent_message_v3_pb"; +import {ExternalChildMessage} from "../../examples/generated/proto/othercom/external_child_message_pb"; import InternalChildMessage = ParentMessageV3.InternalChildMessage; describe("proto3 - internal nested messages", () => { diff --git a/test/integration/oneof.ts b/test/integration/oneof.ts index 904b48b9..d720f503 100644 --- a/test/integration/oneof.ts +++ b/test/integration/oneof.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import {OneOfMessage, CamelCasedOneOfMessage} from "../../examples/generated/examplecom/oneof_message_pb"; -import {ExternalChildMessage} from "../../examples/generated/othercom/external_child_message_pb"; +import {OneOfMessage, CamelCasedOneOfMessage} from "../../examples/generated/proto/examplecom/oneof_message_pb"; +import {ExternalChildMessage} from "../../examples/generated/proto/othercom/external_child_message_pb"; import InternalChildMessage = OneOfMessage.InternalChildMessage; describe("oneofs", () => { diff --git a/test/integration/orphan.ts b/test/integration/orphan.ts index 584086f1..fe761855 100644 --- a/test/integration/orphan.ts +++ b/test/integration/orphan.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import * as orphan_pb_service from "../../examples/generated/orphan_pb_service"; -import * as orphan_pb from "../../examples/generated/orphan_pb"; +import * as orphan_pb_service from "../../examples/generated/proto/orphan_pb_service"; +import * as orphan_pb from "../../examples/generated/proto/orphan_pb"; describe("ts orphan service", () => { it("should generate a service definition that does not have a package", () => { diff --git a/test/integration/primitivesV2.ts b/test/integration/primitivesV2.ts index a082c0b3..9288ce53 100644 --- a/test/integration/primitivesV2.ts +++ b/test/integration/primitivesV2.ts @@ -1,5 +1,5 @@ import {assert} from "chai"; -import {PrimitiveMessageV2} from "../../examples/generated/examplecom/primitive_message_v2_pb"; +import {PrimitiveMessageV2} from "../../examples/generated/proto/examplecom/primitive_message_v2_pb"; describe("proto2 - primitive", () => { it("should allow getting required primitive fields", () => { diff --git a/test/integration/primitivesV3.ts b/test/integration/primitivesV3.ts index 6c6862e6..abc369df 100644 --- a/test/integration/primitivesV3.ts +++ b/test/integration/primitivesV3.ts @@ -1,5 +1,5 @@ import {assert} from "chai"; -import {PrimitiveMessageV3} from "../../examples/generated/examplecom/primitive_message_v3_pb"; +import {PrimitiveMessageV3} from "../../examples/generated/proto/examplecom/primitive_message_v3_pb"; describe("proto3 - primitive", () => { it("should allow getting primitive fields", () => { diff --git a/test/integration/repeatedPrimitives.ts b/test/integration/repeatedPrimitives.ts index e703aa21..9d4afff0 100644 --- a/test/integration/repeatedPrimitives.ts +++ b/test/integration/repeatedPrimitives.ts @@ -1,5 +1,5 @@ import {assert} from "chai"; -import {RepeatedPrimitiveMessage} from "../../examples/generated/examplecom/repeated_primitive_message_pb"; +import {RepeatedPrimitiveMessage} from "../../examples/generated/proto/examplecom/repeated_primitive_message_pb"; describe("repeated primitives", () => { it("should allow getting repeated primitive fields", () => { diff --git a/test/integration/reservedWords.ts b/test/integration/reservedWords.ts index 3f9cff69..11389c0d 100644 --- a/test/integration/reservedWords.ts +++ b/test/integration/reservedWords.ts @@ -1,5 +1,5 @@ import {assert} from "chai"; -import {ReservedWordsMessage} from "../../examples/generated/examplecom/reserved_words_pb"; +import {ReservedWordsMessage} from "../../examples/generated/proto/examplecom/reserved_words_pb"; describe("reserved words", () => { diff --git a/test/integration/service/grpcweb.ts b/test/integration/service/grpcweb.ts index 74d02547..a08690df 100644 --- a/test/integration/service/grpcweb.ts +++ b/test/integration/service/grpcweb.ts @@ -5,9 +5,9 @@ import { grpc } from "grpc-web-client"; import { createContext, runInContext } from "vm"; import { StubTransportBuilder } from "../../helpers/fakeGrpcTransport"; -import { ExternalChildMessage } from "../../../examples/generated/othercom/external_child_message_pb"; -import { SimpleService, SimpleServiceClient } from "../../../examples/generated/examplecom/simple_service_pb_service"; -import { StreamRequest, UnaryRequest } from "../../../examples/generated/examplecom/simple_service_pb"; +import { ExternalChildMessage } from "../../../examples/generated/proto/othercom/external_child_message_pb"; +import { SimpleService, SimpleServiceClient } from "../../../examples/generated/proto/examplecom/simple_service_pb_service"; +import { StreamRequest, UnaryRequest } from "../../../examples/generated/proto/examplecom/simple_service_pb"; describe("service/grpc-web", () => { @@ -30,15 +30,15 @@ describe("service/grpc-web", () => { }); it("should not output imports for namespaces that are not used in the service definition", () => { - const generatedService = readFileSync(resolve(__dirname, "../../../examples/generated/examplecom/simple_service_pb_service.d.ts"), "utf8"); + const generatedService = readFileSync(resolve(__dirname, "../../../examples/generated/proto/examplecom/simple_service_pb_service.d.ts"), "utf8"); assert.notInclude(generatedService, "google-protobuf/google/protobuf/timestamp_pb"); - const generatedProto = readFileSync(resolve(__dirname, "../../../examples/generated/examplecom/simple_service_pb.js"), "utf8"); + const generatedProto = readFileSync(resolve(__dirname, "../../../examples/generated/proto/examplecom/simple_service_pb.js"), "utf8"); assert.include(generatedProto, "google-protobuf/google/protobuf/timestamp_pb"); }); it("should generate valid javascript sources", () => { - const generatedService = readFileSync(resolve(__dirname, "../../../examples/generated/examplecom/simple_service_pb_service.js"), "utf8"); + const generatedService = readFileSync(resolve(__dirname, "../../../examples/generated/proto/examplecom/simple_service_pb_service.js"), "utf8"); // Create a sandbox into which the javascript module will be exported. const sandbox = { exports: { SimpleService: SimpleService } }; diff --git a/test/integration/wellKnownTypes.ts b/test/integration/wellKnownTypes.ts index 7aefeb3b..0b466462 100644 --- a/test/integration/wellKnownTypes.ts +++ b/test/integration/wellKnownTypes.ts @@ -1,5 +1,5 @@ import {assert} from "chai"; -import {WellKnownMessage} from "../../examples/generated/examplecom/well_known_message_pb"; +import {WellKnownMessage} from "../../examples/generated/proto/examplecom/well_known_message_pb"; import {Any} from "google-protobuf/google/protobuf/any_pb"; import {CodeGeneratorRequest} from "google-protobuf/google/protobuf/compiler/plugin_pb"; import {Method} from "google-protobuf/google/protobuf/api_pb"; diff --git a/test/unit/util.ts b/test/unit/util.ts index 0ab1b4e1..edc9ed50 100644 --- a/test/unit/util.ts +++ b/test/unit/util.ts @@ -30,4 +30,4 @@ describe("util", () => { }); }); -}); \ No newline at end of file +}); From e5a4b32ac599120587e25e22f940c8e6fefd8f8b Mon Sep 17 00:00:00 2001 From: colton Date: Tue, 29 May 2018 15:33:48 -0600 Subject: [PATCH 2/5] Cleaned up --- BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.bazel b/BUILD.bazel index fb22b2ef..ef5d1227 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,6 @@ package(default_visibility = ["//visibility:public"]) + exports_files(["tsconfig.json"]) filegroup( From a23ee7171a57376ab11923cede8405c0e02a787d Mon Sep 17 00:00:00 2001 From: colton Date: Tue, 29 May 2018 15:38:10 -0600 Subject: [PATCH 3/5] Added readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e4f1a8f..b8255b4d 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,13 @@ typescript_proto_library( name = "generate", proto = ":proto", ) -``` + +typescript_proto_library( + name = "generate", + proto = ":proto", +) +``` +For an example of how to generate `gRPC Service Stubs`, take a look at the root `BUILD.bazel` in this repo. ## Contributing Contributions are welcome! Please refer to [CONTRIBUTING.md](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CONTRIBUTING.md) for more information. From aabc5445003bd724e53d43662bde86f74ddd5ebd Mon Sep 17 00:00:00 2001 From: colton Date: Tue, 29 May 2018 21:43:09 -0600 Subject: [PATCH 4/5] rerun pipeline :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8255b4d..f45248b0 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ typescript_proto_library( proto = ":proto", ) ``` -For an example of how to generate `gRPC Service Stubs`, take a look at the root `BUILD.bazel` in this repo. +For an example of how to generate gRPC Service Stubs, take a look at the root `BUILD.bazel` in this repo. ## Contributing Contributions are welcome! Please refer to [CONTRIBUTING.md](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CONTRIBUTING.md) for more information. From c4e3a2b43ae0f400237442f0eaef9d21b90a1f53 Mon Sep 17 00:00:00 2001 From: colton Date: Wed, 30 May 2018 13:18:35 -0600 Subject: [PATCH 5/5] Removed services flag because of pull request #83 --- README.md | 1 - defs.bzl | 14 ++------------ proto/BUILD | 3 --- proto/examplecom/BUILD | 3 --- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8c2ed0c9..c8cf5457 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,6 @@ typescript_proto_library( proto = ":proto", ) ``` -For an example of how to generate gRPC Service Stubs, take a look at the root `BUILD.bazel` in this repo. ## Contributing Contributions are welcome! Please refer to [CONTRIBUTING.md](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CONTRIBUTING.md) for more information. diff --git a/defs.bzl b/defs.bzl index 8c671b89..c9be280d 100644 --- a/defs.bzl +++ b/defs.bzl @@ -26,10 +26,7 @@ def proto_path(proto): return path def append_to_outputs(ctx, file_name, outputs, file_modifications): - generated_filenames = ["_pb.d.ts", "_pb.js"] - - if file_name in ctx.attr.services: - generated_filenames += ["_pb_service.js", "_pb_service.d.ts"] + generated_filenames = ["_pb.d.ts", "_pb.js", "_pb_service.js", "_pb_service.d.ts"] for f in generated_filenames: outputs.append(declare_file(ctx, file_name + f, file_modifications)) @@ -57,9 +54,7 @@ def _typescript_proto_library_impl(ctx): descriptor_sets = [desc.path for desc in ctx.attr.proto.proto.transitive_descriptor_sets] - ts_out = "" - if ctx.attr.services: - ts_out = "service=true:" + ts_out = "service=true:" protoc_command = "%s --plugin=protoc-gen-ts=%s --ts_out=%s%s --js_out=import_style=commonjs,binary:%s --descriptor_set_in=%s %s" % (ctx.file._protoc.path, ctx.files._ts_protoc_gen[1].path, ts_out, ctx.var["BINDIR"], ctx.var["BINDIR"], ":".join(descriptor_sets), " ".join(proto_inputs)) @@ -88,11 +83,6 @@ typescript_proto_library = rule( single_file = True, providers = ["proto"], ), - "services": attr.string_list( - doc="An array of service names. Protoc-gen-ts can output additional files for grpc-web. Each element of this array should be the name of the service that will be generated. This is derived from the name of the service. If this proto service is named 'SimpleService', the correct value would be 'simple_service'.", - default = [], - allow_empty = True, - ), "remove_dependencies": attr.string_list( doc = "Each string given will be grepped and removed from the generated files. This can be useful if your proto files are importing a dependency that the generated Typescript does not use.", default = [], diff --git a/proto/BUILD b/proto/BUILD index f997fec0..d78d550f 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -16,7 +16,4 @@ proto_library( typescript_proto_library( name = "generate", proto = ":proto", - services = [ - "orphan", - ], ) diff --git a/proto/examplecom/BUILD b/proto/examplecom/BUILD index 29e1eea5..92980828 100644 --- a/proto/examplecom/BUILD +++ b/proto/examplecom/BUILD @@ -31,7 +31,4 @@ proto_library( typescript_proto_library( name = "generate", proto = ":proto", - services = [ - "simple_service", - ], )