Skip to content

Commit

Permalink
Merge 08f7e4e into 108601e
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Oct 11, 2020
2 parents 108601e + 08f7e4e commit ec48ac4
Show file tree
Hide file tree
Showing 62 changed files with 3,631 additions and 86 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[submodule "packages/grpc-tools/deps/protobuf"]
path = packages/grpc-tools/deps/protobuf
url = https://github.com/protocolbuffers/protobuf
[submodule "packages/proto-loader/deps/gapic-showcase"]
path = packages/proto-loader/deps/gapic-showcase
url = https://github.com/googleapis/gapic-showcase.git
[submodule "packages/proto-loader/deps/googleapis"]
path = packages/proto-loader/deps/googleapis
url = https://github.com/googleapis/googleapis.git
[submodule "packages/grpc-js/deps/envoy-api"]
path = packages/grpc-js/deps/envoy-api
url = https://github.com/envoyproxy/data-plane-api.git
Expand Down
35 changes: 35 additions & 0 deletions packages/proto-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The options parameter is an object that can have the following optional properti
| `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`.
| `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`.
| `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`.
| `json` | `true` or `false` | Represent `Infinity` and `NaN` as strings in `float` fields, and automatically decode `google.protobuf.Any` values. Defaults to `false`
| `includeDirs` | An array of strings | A list of search paths for imported `.proto` files.

The following options object closely approximates the existing behavior of `grpc.load`:
Expand All @@ -51,3 +52,37 @@ const options = {
oneofs: true
}
```

## Generating TypeScript types

The `proto-loader-gen-types` script distributed with this package can be used to generate TypeScript type information for the objects loaded at runtime. More information about how to use it can be found in [the *@grpc/proto-loader TypeScript Type Generator CLI Tool* proposal document](https://github.com/grpc/proposal/blob/master/L70-node-proto-loader-type-generator.md). The arguments mostly match the `load` function's options; the full usage information is as follows:

```
proto-loader-gen-types.js [options] filenames...
Options:
--help Show help [boolean]
--version Show version number [boolean]
--keepCase Preserve the case of field names [boolean]
--longs The type that should be used to output 64 bit integer
values. Can be String, Number [string]
--enums The type that should be used to output enum fields. Can be
String [string]
--bytes The type that should be used to output bytes fields. Can be
String, Array [string]
--defaults Output default values for omitted fields [boolean]
--arrays Output default values for omitted repeated fields even if
--defaults is not set [boolean]
--objects Output default values for omitted message fields even if
--defaults is not set [boolean]
--oneofs Output virtual oneof fields set to the present field's name
[boolean]
--json Represent Infinity and NaN as strings in float fields. Also
decode google.protobuf.Any automatically [boolean]
--includeComments Generate doc comments from comments in the original files
[boolean]
--includeDirs, -I Directories to search for included files [array]
--outDir, -O Directory in which to output files [string] [required]
--grpcLib The gRPC implementation library that these types will be
used with [string] [required]
```

0 comments on commit ec48ac4

Please sign in to comment.