From b8fd61446565852c200d63ab26809c8e51b7eaa8 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Mon, 22 Nov 2021 13:25:58 +0100 Subject: [PATCH 01/22] Include dockerized protoc --- aliases.sh | 5 +++++ docker-compose.yml | 13 +++++++++++++ protoc.Dockerfile | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 aliases.sh create mode 100644 docker-compose.yml create mode 100644 protoc.Dockerfile diff --git a/aliases.sh b/aliases.sh new file mode 100644 index 000000000..009487596 --- /dev/null +++ b/aliases.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +function protoc() { docker-compose run --rm protoc "$@"; } +function protoc-sh() { docker-compose run --rm --entrypoint sh -- protoc "$@"; } +function protoc-build() { docker-compose build protoc; } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..f38b57934 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3" +services: + protoc: + build: + context: . + dockerfile: "protoc.Dockerfile" + args: + BASE: "node:17-alpine3.14" + BIN: "/ts-proto" + PROTOC_VERSION: "3.19.1" + working_dir: "/ts-proto" + volumes: + - ".:/ts-proto" diff --git a/protoc.Dockerfile b/protoc.Dockerfile new file mode 100644 index 000000000..70afa3ecd --- /dev/null +++ b/protoc.Dockerfile @@ -0,0 +1,16 @@ +# Docker image for protoc +ARG BASE="alpine:3.14.3" +FROM $BASE +ARG PROTOC_VERSION="3.19.1" +ARG BIN="" + +RUN apk add gcompat +ADD "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip" protoc.zip +RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc +RUN ln -s /usr/local/lib/protoc/bin/protoc /usr/local/bin/protoc + +RUN protoc --version + +ENV PATH "$BIN:$PATH" + +ENTRYPOINT ["/usr/local/bin/protoc"] From 3f5b0652a4500267c169ff2058162613ac4c2185 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Mon, 22 Nov 2021 14:14:57 +0100 Subject: [PATCH 02/22] Allow relative paths --- aliases.sh | 15 ++++++++++++--- docker-compose.yml | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/aliases.sh b/aliases.sh index 009487596..45248363c 100644 --- a/aliases.sh +++ b/aliases.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +PROJECT_ROOT=$(realpath $(dirname "$BASH_SOURCE")) +PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows -function protoc() { docker-compose run --rm protoc "$@"; } -function protoc-sh() { docker-compose run --rm --entrypoint sh -- protoc "$@"; } -function protoc-build() { docker-compose build protoc; } +# Alias docker-compose to make it usable from anywhere +function _docker-compose() { docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; } + +# Calculate the path relative to project root, and +function _relative_path() { echo "//host/$(realpath --relative-to="$PROJECT_ROOT" "$PWD")"; } + +function protoc() { _docker-compose run -w $(_relative_path) --rm protoc "$@"; } +function protoc-sh() { _docker-compose run -w $(_relative_path) --rm --entrypoint sh -- protoc "$@"; } +function protoc-build() { _docker-compose build protoc; } +function ts-protoc { protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@"; } diff --git a/docker-compose.yml b/docker-compose.yml index f38b57934..fa8727dec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: BASE: "node:17-alpine3.14" BIN: "/ts-proto" PROTOC_VERSION: "3.19.1" - working_dir: "/ts-proto" + working_dir: "/host" volumes: + - "${PWD}:/host" - ".:/ts-proto" From ac776a4110548f6d143412e142647115da4dd404 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Mon, 22 Nov 2021 14:24:25 +0100 Subject: [PATCH 03/22] Allow usage of dockerized protoc in any directory --- aliases.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/aliases.sh b/aliases.sh index 45248363c..27eeed544 100644 --- a/aliases.sh +++ b/aliases.sh @@ -5,10 +5,7 @@ PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows # Alias docker-compose to make it usable from anywhere function _docker-compose() { docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; } -# Calculate the path relative to project root, and -function _relative_path() { echo "//host/$(realpath --relative-to="$PROJECT_ROOT" "$PWD")"; } - -function protoc() { _docker-compose run -w $(_relative_path) --rm protoc "$@"; } -function protoc-sh() { _docker-compose run -w $(_relative_path) --rm --entrypoint sh -- protoc "$@"; } +function protoc() { _docker-compose run --rm protoc "$@"; } +function protoc-sh() { _docker-compose run --rm --entrypoint sh -- protoc "$@"; } function protoc-build() { _docker-compose build protoc; } function ts-protoc { protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@"; } From 274b823c2fc36c8f5b8906372abcb61e0e199cfe Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Mon, 22 Nov 2021 14:44:47 +0100 Subject: [PATCH 04/22] Remove protoc.zip after installing in docker --- protoc.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protoc.Dockerfile b/protoc.Dockerfile index 70afa3ecd..a046f4524 100644 --- a/protoc.Dockerfile +++ b/protoc.Dockerfile @@ -6,7 +6,7 @@ ARG BIN="" RUN apk add gcompat ADD "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip" protoc.zip -RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc +RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc && rm protoc.zip RUN ln -s /usr/local/lib/protoc/bin/protoc /usr/local/bin/protoc RUN protoc --version From e18a12b1334f27574eb0766cebce34f75c97a44b Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Mon, 22 Nov 2021 10:27:45 -0600 Subject: [PATCH 05/22] Small spike on some 'setup:...' commands. --- package.json | 4 ++++ protoc.Dockerfile | 1 + 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index 2af729c4e..5f5b20e60 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,10 @@ }, "scripts": { "build": "yarn tsc", + "setup:docker": "docker-compose build", + "setup:pbjs": "docker-compose run --rm --entrypoint bash -w /host/integration protoc pbjs.sh", + "setup:bins": "docker-compose run --rm --entrypoint bash -w /host/integration protoc update-bins.sh", + "setup:codegen": "docker-compose run --rm --entrypoint bash -w /host/integration protoc codegen.sh", "setup": "cd ./integration && ./pbjs.sh && ./update-bins.sh && ./codegen.sh", "test": "yarn jest -c jest.config.js --maxWorkers=2", "prettier": "prettier --write {src,tests}/**/*.ts", diff --git a/protoc.Dockerfile b/protoc.Dockerfile index a046f4524..f8a127b02 100644 --- a/protoc.Dockerfile +++ b/protoc.Dockerfile @@ -4,6 +4,7 @@ FROM $BASE ARG PROTOC_VERSION="3.19.1" ARG BIN="" +RUN apk add bash RUN apk add gcompat ADD "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip" protoc.zip RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc && rm protoc.zip From 38fa4003d1c8585f0de85327d9398b32a6ca86d1 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Mon, 22 Nov 2021 19:17:56 +0100 Subject: [PATCH 06/22] Set default value for PWD to project root directory --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index fa8727dec..7a7b6acc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,5 +10,5 @@ services: PROTOC_VERSION: "3.19.1" working_dir: "/host" volumes: - - "${PWD}:/host" + - "${PWD:-.}:/host" - ".:/ts-proto" From 186838db0fde53328e46af6ce09ad9fb3f6c0420 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 13:54:47 +0100 Subject: [PATCH 07/22] Make update-bins Windows compatible, and allow running from any directory --- integration/protoc-gen-dump.bat | 1 + integration/update-bins.sh | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 integration/protoc-gen-dump.bat diff --git a/integration/protoc-gen-dump.bat b/integration/protoc-gen-dump.bat new file mode 100644 index 000000000..272f9e037 --- /dev/null +++ b/integration/protoc-gen-dump.bat @@ -0,0 +1 @@ +@bash protoc-gen-dump diff --git a/integration/update-bins.sh b/integration/update-bins.sh index 66852c3e1..51fe74802 100755 --- a/integration/update-bins.sh +++ b/integration/update-bins.sh @@ -1,17 +1,23 @@ #!/usr/bin/env bash # To avoid running the protoc pipeline all the time, we capture the incoming Plugin -# proto requests into .bin files that then unit tests can pull in directly as needed. -list=$(find . -name "*.proto" -type f) +# proto requests into .bin PROTO_FILES that then unit tests can pull in directly as needed. -for file in $list; do - echo "${file}" -# # Strip the longest suffix starting at the 1st slash - dir="${file##./}" - dir="${dir%%/*}" +INTEGRATION_DIR=$(realpath $(dirname "$BASH_SOURCE")) +cd $INTEGRATION_DIR; - # Strip the proto suffix and add bin - dest="${file%proto}bin" - protoc --experimental_allow_proto3_optional "--plugin=$(pwd)/protoc-gen-dump" --dump_out=. "${file}" "-I${dir}" - mv file.bin "${dest}" +if [[ "$OSTYPE" == "msys" ]]; then + PLUGIN_PATH="protoc-gen-dump.bat" +else + PLUGIN_PATH="protoc-gen-dump" +fi + +PROTO_FILES=$(find . -name "*.proto" -type f) + +for FILE in $PROTO_FILES; do + echo "${FILE}" + INPUT_DIR="$(dirname "$FILE")" + OUTPUT_FILE="${FILE%proto}bin" + protoc --experimental_allow_proto3_optional "--plugin=$PLUGIN_PATH" --dump_out=. "${FILE}" "-I${INPUT_DIR}"\ + && mv FILE.bin "${OUTPUT_FILE}" done From a2d64493c835c6b33cd91f3c8254ec4d99f999cd Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 14:21:27 +0100 Subject: [PATCH 08/22] Fix issue where bin files were directly generated for dependencies of integration test --- integration/update-bins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/update-bins.sh b/integration/update-bins.sh index 51fe74802..12f18ac31 100755 --- a/integration/update-bins.sh +++ b/integration/update-bins.sh @@ -12,7 +12,7 @@ else PLUGIN_PATH="protoc-gen-dump" fi -PROTO_FILES=$(find . -name "*.proto" -type f) +PROTO_FILES=$(find . -name "*.proto" -type f -maxdepth 2) for FILE in $PROTO_FILES; do echo "${FILE}" From 6cbde87283bffd020184417f4a7e523f9af0f022 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 15:27:15 +0100 Subject: [PATCH 09/22] Avoid find warning about argument order --- integration/update-bins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/update-bins.sh b/integration/update-bins.sh index 12f18ac31..445ab12d4 100755 --- a/integration/update-bins.sh +++ b/integration/update-bins.sh @@ -12,7 +12,7 @@ else PLUGIN_PATH="protoc-gen-dump" fi -PROTO_FILES=$(find . -name "*.proto" -type f -maxdepth 2) +PROTO_FILES=$(find . -maxdepth 2 -name "*.proto" -type f) for FILE in $PROTO_FILES; do echo "${FILE}" From 8aa78c84525542c26cce1565284cd14897e7ba9c Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 15:29:31 +0100 Subject: [PATCH 10/22] Support specifying multiple integration tests in codegen.sh --- integration/codegen.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/codegen.sh b/integration/codegen.sh index 38da4e010..aea8804b2 100755 --- a/integration/codegen.sh +++ b/integration/codegen.sh @@ -9,9 +9,9 @@ # # Updates generated output for all integration tests. # -# ./codegen.sh simple +# ./codegen.sh simple value # -# Updates generated output only for the 'simple' integration test. +# Updates generated output only for the 'simple' and 'value' integration test. # # Each integration test can optionally have a `parameters.txt` file that will # be used as the ts-proto_opt... args for generating that test's code. @@ -22,10 +22,10 @@ N=6 dir=. if [ -n "${1}" ]; then - dir=$1 + dir="${@}" fi -list=$(find "$dir" -name "*.bin" -type f | grep -v dump-response.bin) +list=$(find $dir -name "*.bin" -type f | grep -v dump-response.bin) for file in $list; do echo "${file}" From b71504f1aba620d8776aa42dd74593f599c1a3e4 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 15:30:10 +0100 Subject: [PATCH 11/22] Support running codegen.sh from any directory --- integration/codegen.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/integration/codegen.sh b/integration/codegen.sh index aea8804b2..b204f1e9c 100755 --- a/integration/codegen.sh +++ b/integration/codegen.sh @@ -16,9 +16,12 @@ # Each integration test can optionally have a `parameters.txt` file that will # be used as the ts-proto_opt... args for generating that test's code. -dir=${1:-*} +INTEGRATION_DIR=$(realpath $(dirname "$BASH_SOURCE")) -N=6 +# Run the code generator in parallel, with one process per core. +N=$(nproc) + +echo "Generating typescript code for integration tests using ${N} cores..." dir=. if [ -n "${1}" ]; then @@ -39,7 +42,7 @@ for file in $list; do fi ((i=i%N)); ((i++==0)) && wait - ../node_modules/.bin/ts-node ./codegen.ts "${dir}" "${file}" "${params}" & + "${INTEGRATION_DIR}/../node_modules/.bin/ts-node" "${INTEGRATION_DIR}/codegen.ts" "${dir}" "${file}" "${params}" & done wait From 2e4282892deed4994375e52211109c0995231675 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 15:31:33 +0100 Subject: [PATCH 12/22] Define local alternatives for docker commands --- package.json | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5f5b20e60..c136b3750 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,19 @@ }, "scripts": { "build": "yarn tsc", - "setup:docker": "docker-compose build", - "setup:pbjs": "docker-compose run --rm --entrypoint bash -w /host/integration protoc pbjs.sh", - "setup:bins": "docker-compose run --rm --entrypoint bash -w /host/integration protoc update-bins.sh", - "setup:codegen": "docker-compose run --rm --entrypoint bash -w /host/integration protoc codegen.sh", - "setup": "cd ./integration && ./pbjs.sh && ./update-bins.sh && ./codegen.sh", + "build:test": "yarn proto2bin && yarn bin2pbjs && yarn bin2ts", + "build:test:local": "yarn proto2bin:local && yarn bin2pbjs:local && yarn bin2ts:local", + "proto2bin": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc update-bins.sh", + "proto2bin-node": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration node update-bins.sh", + "bin2pbjs": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc pbjs.sh", + "bin2ts": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc codegen.sh", + "proto2bin:local": "integration/update-bins.sh", + "bin2pbjs:local": "integration/pbjs.sh", + "bin2ts:local": "integration/codegen.sh", "test": "yarn jest -c jest.config.js --maxWorkers=2", "prettier": "prettier --write {src,tests}/**/*.ts", - "prettier:check": "prettier --list-different {src,tests}/**/*.ts" + "prettier:check": "prettier --list-different {src,tests}/**/*.ts", + "setup:docker": "docker-compose build" }, "files": [ "build" From 7c80deeb2a20719faf094278697398db45003f4c Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Thu, 25 Nov 2021 15:41:03 +0100 Subject: [PATCH 13/22] Update readme with development and contribution workflow --- README.markdown | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index b3adc1ec4..dd8531788 100644 --- a/README.markdown +++ b/README.markdown @@ -18,7 +18,7 @@ - [Supported options](#supported-options) - [Only Types](#only-types) - [NestJS Support](NESTJS.markdown) -- [Building](#building) +- [Development](#development) - [Assumptions](#assumptions) - [Todo](#todo) - [OneOf Handling](#oneof-handling) @@ -362,15 +362,45 @@ Kudos to our sponsors: If you need ts-proto customizations or priority support for your company, you can ping me at [via email](mailto:stephen.haberman@gmail.com). -# Building +# Development -After running `yarn install`, run `./integration/pbjs.sh` to create the integration test types. These pbjs-generated files are not currently checked in. +**Requirements** -After this, the tests should pass. +- [Docker](https://www.docker.com) or [protoc](https://github.com/protocolbuffers/protobuf/releases) v3.19.1 +- `yarn` — `npm install -g yarn` -After making changes to `ts-proto`, you can run `cd integration` and `./codegen.sh` to re-generate the test case `*.ts` output files that are in each `integration//` directory. +**Setup** -The test suite's proto files (i.e. `simple.proto`, `batching.proto`, etc.) currently have serialized/`.bin` copies checked into git (i.e. `simple.bin`, `batching.bin`, etc.), so that the test suite can run without having to invoke the `protoc` build chain. I.e. if you change the `simple.proto`/etc. files, you'll need to run `./integration/update-bins.sh`, which does require having the `protoc` executable available. +The commands below assume you have **Docker** installed. To use a **local** copy of `protoc` without docker, use commands suffixed with `:local` + +- Check out the [repository]() for the latest code. +- Run `yarn install` to install the dependencies. +- Run `yarn build:test` or `yarn build:test:local` to generate the test files. + > _This runs the following commands:_ + > - `proto2bin` — Converts integration test `.proto` files to `.bin`. + > - `bin2ts` — Runs `ts-proto` on the `.bin` files to generate `.ts` files. + > - `bin2pbjs` — Generates a reference implementation using `pbjs` for testing compatibility. +- Run `yarn test` + +**Workflow** + +- Modifying the plugin implementation: + - Run `yarn bin2ts` or `yarn bin2ts:local`. + _Since the proto files were not changed, you only need to regenerate the typescript files._ + - Run `yarn test` to verify the typescript files are compatible with the reference implementation, and pass other tests. +- Updating or adding `.proto` files in the integration directory: + - Run `yarn build:test` to regenerate the integration test files. + - Run `yarn test` to retest. + +**Contributing** + +- Run `yarn build:test` and `yarn test` to make sure everything works. +- Run `yarn prettier` to format the typescript files. +- Commit the changes: + - Also include the generated `.bin` files for the tests where you added or modified `.proto` files. + > These are checked into git so that the test suite can run without having to invoke the `protoc` build chain. + - Also include the generated `.ts` files. +- Create a pull request # Assumptions From 1fb35cbbfa3f162786317f59641c57409543a4b2 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Sat, 27 Nov 2021 11:07:15 +0100 Subject: [PATCH 14/22] Upgrade to protoc 3.19.1 --- integration/angular/simple-message.bin | Bin 235 -> 235 bytes .../simple.bin | Bin 1282 -> 1282 bytes .../simple2.bin | Bin 514 -> 514 bytes integration/avoid-import-conflicts/simple.bin | Bin 1254 -> 1254 bytes .../avoid-import-conflicts/simple2.bin | Bin 486 -> 486 bytes integration/barrel-imports/bar.bin | Bin 258 -> 258 bytes integration/barrel-imports/foo.bin | Bin 527 -> 527 bytes .../batching-with-context/batching.bin | Bin 2067 -> 2067 bytes integration/batching/batching.bin | Bin 2067 -> 2067 bytes integration/bytes-as-base64/message.bin | Bin 181 -> 181 bytes integration/bytes-node/point.bin | Bin 175 -> 175 bytes integration/const-enum/const-enum.bin | Bin 497 -> 497 bytes .../generic-service-definitions/simple.bin | Bin 1232 -> 1232 bytes integration/global-this/global-this.bin | Bin 315 -> 315 bytes .../grpc-js/google/protobuf/timestamp.ts | 11 ++++- integration/grpc-js/simple.bin | Bin 15636 -> 15887 bytes integration/grpc-web-go-server/example.bin | Bin 3082 -> 3082 bytes .../example.bin | Bin 1443 -> 1443 bytes integration/grpc-web-no-streaming/example.bin | Bin 1443 -> 1443 bytes integration/grpc-web/example.bin | Bin 3050 -> 3050 bytes integration/lower-case-svc-methods/math.bin | Bin 792 -> 792 bytes .../meta-typings/google/protobuf/timestamp.ts | 21 ++++++--- integration/meta-typings/meta-typings-test.ts | 42 +++++++++++++----- integration/meta-typings/simple.bin | Bin 21180 -> 21424 bytes integration/nestjs-metadata-grpc-js/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-metadata-observables/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-metadata-restparameters/hero.bin | Bin 1049 -> 1049 bytes integration/nestjs-metadata/hero.bin | Bin 1049 -> 1049 bytes integration/nestjs-restparameters/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-simple-observables/hero.bin | Bin 1049 -> 1049 bytes .../nestjs-simple-restparameters/hero.bin | Bin 2814 -> 2821 bytes .../google/protobuf/timestamp.ts | 11 ++++- integration/nestjs-simple/hero.bin | Bin 10088 -> 10339 bytes .../no-proto-package/no-proto-package.bin | Bin 364 -> 364 bytes integration/oneof-properties/oneof.bin | Bin 1927 -> 1927 bytes integration/oneof-unions/oneof.bin | Bin 2309 -> 2309 bytes .../only-types-grpc-metadata.bin | Bin 518 -> 518 bytes integration/only-types/google/protobuf/any.ts | 7 ++- .../only-types/google/protobuf/timestamp.ts | 11 ++++- integration/only-types/reservation.bin | Bin 12309 -> 12585 bytes integration/point/point.bin | Bin 437 -> 437 bytes integration/return-observable/observable.bin | Bin 463 -> 463 bytes .../simple-deprecated-fields/simple.bin | Bin 887 -> 887 bytes .../simple-esmodule-interop/simple.bin | Bin 1260 -> 1260 bytes integration/simple-json-name/simple.bin | Bin 6974 -> 6974 bytes .../google/protobuf/timestamp.ts | 11 ++++- integration/simple-long-string/simple.bin | Bin 11765 -> 12009 bytes integration/simple-long/simple.bin | Bin 6984 -> 6984 bytes .../google/protobuf/timestamp.ts | 11 ++++- integration/simple-optionals/simple.bin | Bin 17013 -> 17257 bytes integration/simple-optionals/thing.bin | Bin 6386 -> 6630 bytes integration/simple-proto2/simple.bin | Bin 368 -> 368 bytes .../simple-snake/google/protobuf/timestamp.ts | 11 ++++- integration/simple-snake/simple.bin | Bin 17013 -> 17257 bytes integration/simple-string-enums/simple.bin | Bin 595 -> 595 bytes .../google/protobuf/timestamp.ts | 11 ++++- .../simple-unrecognized-enum/simple.bin | Bin 17013 -> 17257 bytes .../simple/google/protobuf/timestamp.ts | 11 ++++- integration/simple/simple.bin | Bin 21734 -> 21978 bytes integration/struct/google/protobuf/struct.ts | 4 +- integration/struct/struct.bin | Bin 4734 -> 4735 bytes integration/type-registry/foo.bin | Bin 6514 -> 6758 bytes integration/types-with-underscores/file.bin | Bin 253 -> 253 bytes .../google/protobuf/timestamp.ts | 11 ++++- integration/use-date-false/metadata.bin | Bin 6371 -> 6615 bytes .../google/protobuf/timestamp.ts | 11 ++++- .../use-date-string/use-date-string.bin | Bin 6990 -> 7234 bytes .../google/protobuf/timestamp.ts | 11 ++++- integration/use-date-true/use-date-true.bin | Bin 6986 -> 7230 bytes integration/value/google/protobuf/struct.ts | 4 +- integration/value/value.bin | Bin 9573 -> 9574 bytes integration/vector-tile/vector_tile.bin | Bin 2942 -> 2942 bytes 72 files changed, 164 insertions(+), 35 deletions(-) diff --git a/integration/angular/simple-message.bin b/integration/angular/simple-message.bin index 8b9b8cfd02f1c5ab280c9d321aa676e2066e0e2b..7a24454348ff64ccbd9084fb5ac4bb0b98a78af0 100644 GIT binary patch delta 13 UcmaFO_?mHoG_$Y-<3zc$03Xr>F8}}l delta 13 UcmaFO_?mHoG&7F`%S5@e03WmjD*ylh diff --git a/integration/avoid-import-conflicts-types-only/simple.bin b/integration/avoid-import-conflicts-types-only/simple.bin index f0741c863ba400f7e4af8274c1055a0be76054d3..75915195a7f2a06bab35fda280e54969138b0d5c 100644 GIT binary patch delta 31 mcmZqTYT^>(;wjF|EyzjLD=5k@$(Q2bU=|RTVB9G7h6MnK&(;wjF|EyzjLD=5k@$(Q2bU>4w!VA&}4h6MnKt_V#4 diff --git a/integration/avoid-import-conflicts-types-only/simple2.bin b/integration/avoid-import-conflicts-types-only/simple2.bin index 745b205c10248303e9f3b04f186f053d62d43e9f..4a0fddc475f79838e282f338a18957669affd6af 100644 GIT binary patch delta 14 VcmZo-X=0fm!YnMoxKaEyBLEr*1C#&& delta 14 VcmZo-X=0fm!ptMVvQhjsBLErZ1CRg! diff --git a/integration/avoid-import-conflicts/simple.bin b/integration/avoid-import-conflicts/simple.bin index 8e46534d8f59263a97fef2437dc6a48bacad498f..57bd5482b36c981835fdf23568fcc99418fc93d8 100644 GIT binary patch delta 31 mcmaFH`HWMHi>EjEj)& delta 14 VcmaFH{ET^m2s4ia%SQ3@i~u9P1Udi! diff --git a/integration/barrel-imports/bar.bin b/integration/barrel-imports/bar.bin index 9a23de97604629d49c66d63baeff34acbb076dd7..8b84bf73907da9e45870748142e9b8e39a12d045 100644 GIT binary patch delta 27 icmZo-YGM-R;!H{`(km#+FUgnU;9wRImSCJH{2l;Y?gqjD delta 27 icmZo-YGM-R;!H{`(km#+FUgnU;9wTukzko9{2l;Y&<4H$ diff --git a/integration/barrel-imports/foo.bin b/integration/barrel-imports/foo.bin index 99e659e27ba11ebcb80338c5668a17741e13ee57..26df53209563317a81ef59344b7843191822ace8 100644 GIT binary patch delta 28 jcmeBY>1Pq<;!MlW*DEN>FUgnU;9wRImSEf{{D%<$Xru=n delta 28 jcmeBY>1Pq<;!MlW*DEN>FUgnU;9wTukzm;<{D%<$Xo3eB diff --git a/integration/batching-with-context/batching.bin b/integration/batching-with-context/batching.bin index 7355180b576cb1593b6ca035e9877f185f50b91c..5d6ad57e0e1c0de99ad8aa323e9806a6faa3cd12 100644 GIT binary patch delta 14 VcmbO%Fj-)ND6_Bx<3@?!>;N4U1Lgn# delta 14 VcmbO%Fj-)NC^L@)%SMUc>;N3{1L6Px diff --git a/integration/batching/batching.bin b/integration/batching/batching.bin index 7355180b576cb1593b6ca035e9877f185f50b91c..5d6ad57e0e1c0de99ad8aa323e9806a6faa3cd12 100644 GIT binary patch delta 14 VcmbO%Fj-)ND6_Bx<3@?!>;N4U1Lgn# delta 14 VcmbO%Fj-)NC^L@)%SMUc>;N3{1L6Px diff --git a/integration/bytes-as-base64/message.bin b/integration/bytes-as-base64/message.bin index 5044a3414ce2771f52826019b72e7af3f7dc9dc5..b035d9e0987c3b631972dc4504f0c0488a8a70b1 100644 GIT binary patch delta 13 UcmdnWxRr5&2(z#R<3#a!02)mLh5!Hn delta 13 UcmdnWxRr5&2s4ia%S7>c02(g?f&c&j diff --git a/integration/bytes-node/point.bin b/integration/bytes-node/point.bin index 9a03b3eacf4fa8e3364740923f491e195513b9fd..83d92ed00fea1c2289118099df883631e0aa4571 100644 GIT binary patch delta 29 kcmZ3_xSmmzi@P8{Gp|IipeVm2Uy6f+SwL8VaiZuf0DWHvzyJUM delta 29 kcmZ3_xSmmzi@P8{Gp|IipeVm2Uy6f+S%61^WuoXT0DVCRyZ`_I diff --git a/integration/const-enum/const-enum.bin b/integration/const-enum/const-enum.bin index 9842cd90a823f893a00548ddbfe1d14ac2d50266..12ff3f8df3c3b4675df5d67b8d360693467df20a 100644 GIT binary patch delta 14 Vcmey!{E>NrIJ2+><3_3Li~uDv1Y!UH delta 14 Vcmey!{E>NrI5Up~%SNf|i~uDN1YQ6D diff --git a/integration/generic-service-definitions/simple.bin b/integration/generic-service-definitions/simple.bin index adf555a23f6851fbd9dade154e7878a892ef9c82..f101042dfad06cea0dd9f01bac4101bc8aaececa 100644 GIT binary patch delta 31 mcmcb>d4W@mi>Ejd4W@mi>Ej13v%& delta 14 VcmdnZw3}&y1T&8W%SLGhMgSff13Lf! diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index dfd3577e7..e4600a73e 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -56,7 +56,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() diff --git a/integration/grpc-js/simple.bin b/integration/grpc-js/simple.bin index 6e198a4e743edddb460b55872b6621f88c5d443c..2520baddb9cb855168e7a78345c33bb1a0ea72f7 100644 GIT binary patch delta 512 zcmbPI)n6mU#Z#P_Tac5gS5TB+k}t)ds$dJ_fz?d*5tZRqu!SfCs+=4sp&STQrk9>t;#!cOoDrOwoS&DX zp{WU10ya^vIJLwtF)zPZ1F9Ir0jknVD$UFRD!1kWTJ2f^^i)o&g4yPC5@~D_++55o z42(i7?Tj3PTyq(@SXdaC7=&25Cwt4!*Xw3vV&~%JVg-o-)pRp*@WZ&wAg+)w*HefV hpzOrS5(>}dCnB^kf&>{kc%fPtfm$YRmQ(yD4FFiUh6w-w delta 299 zcmeCLnNlUg#Z#P_Tac5gS5TB+k}t)>coLo#C+(OLC40fC2+5a#yUDlr*%UQr!2huh9 zDW?#lHb@(1NoHn6KBw z$i&XY%f$*3V+0B^a`3~r%pk6iFxOLv7NBg$WMReU@*M~*j37Zq4qm7hMxd6C&5}yr Fqyhe}K-vHR diff --git a/integration/grpc-web-go-server/example.bin b/integration/grpc-web-go-server/example.bin index 5a0f331f33ddfea173650fecee4386b578b792b3..1c0736d4271b1dc3ee5e1730b07fa1117635745a 100644 GIT binary patch delta 14 VcmeB@=#rQq!YnMoxKaEwHvk;c1Kt1t delta 14 VcmeB@=#rQq!ptMVvQhjqHvk;41KI!p diff --git a/integration/grpc-web-no-streaming-observable/example.bin b/integration/grpc-web-no-streaming-observable/example.bin index 539202d2d32968bfc14b46975aee1d58bf67e3c7..0b96ce0c60a7879c3d721d3e3c69ad69ecc6c789 100644 GIT binary patch delta 14 VcmZ3?y_kD~2(z#R<3{lwRsbDP1Bn0t delta 14 VcmZ3?y_kD~2s4ia%SQ1YRsbC?1BCzp diff --git a/integration/grpc-web-no-streaming/example.bin b/integration/grpc-web-no-streaming/example.bin index 539202d2d32968bfc14b46975aee1d58bf67e3c7..0b96ce0c60a7879c3d721d3e3c69ad69ecc6c789 100644 GIT binary patch delta 14 VcmZ3?y_kD~2(z#R<3{lwRsbDP1Bn0t delta 14 VcmZ3?y_kD~2s4ia%SQ1YRsbC?1BCzp diff --git a/integration/grpc-web/example.bin b/integration/grpc-web/example.bin index a1281f473485215137de155efba9be3bf8098890..ace3893cc1b3f18219323162dea103d7fad2ebc6 100644 GIT binary patch delta 14 VcmaDQ{z`m;2(z#R<3{nz+yEvz1bhGh delta 14 VcmaDQ{z`m;2s4ia%SQ3b+yEvR1b6@d diff --git a/integration/lower-case-svc-methods/math.bin b/integration/lower-case-svc-methods/math.bin index 236dc3d612c67799be1a53bf1abb9d45f7b4558d..eddba34a47ed61e44755939da6271b2a424e561e 100644 GIT binary patch delta 29 kcmbQiHiJ!siz_#=Btx&DD8D3Mii3k$Kv;rtqX-K#0CR2zrT_o{ delta 29 kcmbQiHiJ!siz_#=Btx&DD8D3Mii3k$fJcI5qX-K#0CP+Rq5uE@ diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index 927b4c71a..f31402980 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -57,7 +57,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() @@ -177,7 +186,7 @@ export const protoMetadata: ProtoMetadata = { javaPackage: 'com.google.protobuf', javaOuterClassname: 'TimestampProto', javaMultipleFiles: true, - goPackage: 'github.com/golang/protobuf/ptypes/timestamp', + goPackage: 'google.golang.org/protobuf/types/known/timestamppb', ccEnableArenas: true, objcClassPrefix: 'GPB', csharpNamespace: 'Google.Protobuf.WellKnownTypes', @@ -186,21 +195,21 @@ export const protoMetadata: ProtoMetadata = { location: [ { path: [4, 0], - span: [126, 0, 137, 1], + span: [135, 0, 146, 1], leadingDetachedComments: [], leadingComments: - ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', + ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n Instant now = Instant.now();\n\n Timestamp timestamp =\n Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n .setNanos(now.getNano()).build();\n\n\n Example 6: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', }, { path: [4, 0, 2, 0], - span: [130, 2, 20], + span: [139, 2, 20], leadingDetachedComments: [], leadingComments: ' Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.\n', }, { path: [4, 0, 2, 1], - span: [136, 2, 18], + span: [145, 2, 18], leadingDetachedComments: [], leadingComments: ' Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.\n', diff --git a/integration/meta-typings/meta-typings-test.ts b/integration/meta-typings/meta-typings-test.ts index 53a40554e..ade8e5da0 100644 --- a/integration/meta-typings/meta-typings-test.ts +++ b/integration/meta-typings/meta-typings-test.ts @@ -869,7 +869,7 @@ describe('simple', () => { "ccGenericServices": false, "csharpNamespace": "Google.Protobuf.WellKnownTypes", "deprecated": false, - "goPackage": "github.com/golang/protobuf/ptypes/timestamp", + "goPackage": "google.golang.org/protobuf/types/known/timestamppb", "javaGenerateEqualsAndHash": false, "javaGenericServices": false, "javaMultipleFiles": true, @@ -944,7 +944,16 @@ describe('simple', () => { .setNanos((int) ((millis % 1000) * 1000000)).build(); - Example 5: Compute Timestamp from current time in Python. + Example 5: Compute Timestamp from Java \`Instant.now()\`. + + Instant now = Instant.now(); + + Timestamp timestamp = + Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + .setNanos(now.getNano()).build(); + + + Example 6: Compute Timestamp from current time in Python. timestamp = Timestamp() timestamp.GetCurrentTime() @@ -984,9 +993,9 @@ describe('simple', () => { 0, ], "span": Array [ - 126, + 135, 0, - 137, + 146, 1, ], "trailingComments": "", @@ -1004,7 +1013,7 @@ describe('simple', () => { 0, ], "span": Array [ - 130, + 139, 2, 20, ], @@ -1024,7 +1033,7 @@ describe('simple', () => { 1, ], "span": Array [ - 136, + 145, 2, 18, ], @@ -1097,7 +1106,7 @@ describe('simple', () => { "ccGenericServices": false, "csharpNamespace": "Google.Protobuf.WellKnownTypes", "deprecated": false, - "goPackage": "github.com/golang/protobuf/ptypes/timestamp", + "goPackage": "google.golang.org/protobuf/types/known/timestamppb", "javaGenerateEqualsAndHash": false, "javaGenericServices": false, "javaMultipleFiles": true, @@ -1172,7 +1181,16 @@ describe('simple', () => { .setNanos((int) ((millis % 1000) * 1000000)).build(); - Example 5: Compute Timestamp from current time in Python. + Example 5: Compute Timestamp from Java \`Instant.now()\`. + + Instant now = Instant.now(); + + Timestamp timestamp = + Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + .setNanos(now.getNano()).build(); + + + Example 6: Compute Timestamp from current time in Python. timestamp = Timestamp() timestamp.GetCurrentTime() @@ -1212,9 +1230,9 @@ describe('simple', () => { 0, ], "span": Array [ - 126, + 135, 0, - 137, + 146, 1, ], "trailingComments": "", @@ -1232,7 +1250,7 @@ describe('simple', () => { 0, ], "span": Array [ - 130, + 139, 2, 20, ], @@ -1252,7 +1270,7 @@ describe('simple', () => { 1, ], "span": Array [ - 136, + 145, 2, 18, ], diff --git a/integration/meta-typings/simple.bin b/integration/meta-typings/simple.bin index 6812857bc3acb07e66495166f58fad0b471c4410..0fffa492d2677e79a58dd41e84afb367e4ae31b7 100644 GIT binary patch delta 428 zcmdn9lySpyMj0-i;>_HFoK(GnqWqG4DGm;10bvP7C5Ea-0j|mC48=DZ&yip{ZaDd( zL;+JP<76jE4P&G9{QPvFj`aMT#JqI9{GxPyu;!%FH2spwg4AOD?7aN)JpGc)+|=Td z#N2{{q{**2wKliCZADPwgigmrKgs-7UU;q1g9qF=cQ<9YQmL(jngYmE%8gt%P-b|Dh6>hCL3yq zGn!34r!2WSNyC>-f}4w(g@I9srJa#OkZUd@7Yhpm6N3;-_vB-G^YywJnb^5_xmZDB yKsDWr9Q-gYGl(lB%=Hwa1t>dl@?`zz@)HqS7(s%J9K291j6f|DH_tRsRssN+sBHcK delta 241 zcmdn6oN>=mMlmj);>_HFoK(GnqWqG4DGm;10UimKjbb|`m@ey2z9><^SU1^OQiD-@ z@TJ#g&m-l&@D%lwXoB#lgWWz$3w;#896s-N zrAd0p`MLV(`8kPs>H1(TNu_D}1tpaQsm1!Kxj@ForEA!D?6^3&m^iqFn3WmqHpjBB GU3VD(lq&0Y*Ud~FHN;Wi;#H1F4D0>#k=U>WU4V0+niA26&xI-LqSN- zfm7s(HB5=Z}mi-`UR2T!!c)w3Ml=X>Ap^11l7oCK&?b)vg<;*q2z@v(%8N731% z0<@4G^7DiE++WQYx=n~(wb)lR9a|@L+xUr;4|fgk)U^(beTN)7hE;Q!EI-`di`_+# zfs?uvehd|Zjp!HVpC^HCrZqpW(1u*#E-`(Qv(r=m?CtH*&m!d1Pu^C5Lr#Je@6_&28xb zTKL*jV^k}2ROq1-YD)g~FdJP`$C8Zdw&fLFvRzrTwu!To&EN!+T}&lA&l$g z!@Vjq%mSNKJYhFfEiF%1`UZk`bwO0SfEN%}ga(%4aDzb*5Qh|@NlU3ay@|Of^gtwJ o%+thDZ%6W>R1)z18(~$S_G=$0|1W|=h^3x(1ha@A45jDAZliv28Ks^|Z;lb1$-eo%q%WH|7Z)=N1EUag9fu&-Tt+Sy76v8; zA(p1eE(-JYni!ebxp=u)L1K(RK}HUK7?&Bu6%yup3ef_T?U*d6_*}jNp@k77$jHG9 P)xrqW(y>`w$%hR9%k)wj diff --git a/integration/no-proto-package/no-proto-package.bin b/integration/no-proto-package/no-proto-package.bin index a07d20f4b7604ff1d3a67567381d2afaf58a609a..b23df4108ff9bd5aee9eae4ae174a6702ef7ab4c 100644 GIT binary patch delta 14 VcmaFE^oD7IEVHl#<3)SD9SI%m*U`H77&(T+$dVa4gh`M2Y3Jg delta 30 lcmZqYZ|4`~;?B=Y%}>)SD9SI%m*U`H7T}R!*(h4X4gh_<2Xp`c diff --git a/integration/oneof-unions/oneof.bin b/integration/oneof-unions/oneof.bin index 421cc6ec768771ccf9216cee39e2b6648db1e37d..1ffbd30ec830a3a4d7e6c8f2acea8160fcd203d3 100644 GIT binary patch delta 30 lcmZn_Y84XY;?B=Y%}>)SD9SI%m*U`H77&(T+$j2i0|0*z2l)U1 delta 30 lcmZn_Y84XY;?B=Y%}>)SD9SI%m*U`H7T}R!*(myf0|0*R2lW5| diff --git a/integration/only-types-grpc-metadata/only-types-grpc-metadata.bin b/integration/only-types-grpc-metadata/only-types-grpc-metadata.bin index 91849ed146953c5aa99eb5ce54f1be66aa77942c..e43e9b9970279217195549a756fd9ee5ff6043a1 100644 GIT binary patch delta 21 ccmZo;X=9n7${{SlsKiiplX-%|M&F%`06G2z-T(jq delta 21 ccmZo;X=9n7%E2SSqQp>jlX-%|M&F%`06D+~+5i9m diff --git a/integration/only-types/google/protobuf/any.ts b/integration/only-types/google/protobuf/any.ts index 04572d4fc..ade2721aa 100644 --- a/integration/only-types/google/protobuf/any.ts +++ b/integration/only-types/google/protobuf/any.ts @@ -40,10 +40,13 @@ export const protobufPackage = 'google.protobuf'; * Example 4: Pack and unpack a message in Go * * foo := &pb.Foo{...} - * any, err := ptypes.MarshalAny(foo) + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } * ... * foo := &pb.Foo{} - * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * if err := any.UnmarshalTo(foo); err != nil { * ... * } * diff --git a/integration/only-types/google/protobuf/timestamp.ts b/integration/only-types/google/protobuf/timestamp.ts index 3fd84b70a..c88251a53 100644 --- a/integration/only-types/google/protobuf/timestamp.ts +++ b/integration/only-types/google/protobuf/timestamp.ts @@ -53,7 +53,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() diff --git a/integration/only-types/reservation.bin b/integration/only-types/reservation.bin index 774442d3f7c708b9495d6bfd7d53a428a8509f0c..27024a9e94493da12640f0ee3d79d10277033396 100644 GIT binary patch delta 704 zcmbQ5urg_a1iP>VqY^{agNgEKjAawslyr5{^YhblQuWgFa}x8?_413-^$UvfOY)OS z)AUO!3sQ^qv-9%H^Yjz*DhrY(p3~s`sl~-E#45)ycjNy`HXdg#PA(=6ZXsr62It8w z?4kUB1-O`47=&1B80IoEO1IJkJZSV4k} zKv70cK^T`A#1#?c3I}TeO3s;lS2R*@4kHsgR0$(UkdcEI#s%t_!zdt_#0K`Van*4{ zuF3g&3X@yJ{Fz!ACtnfMFf$@Dd`dENQ;SOya|;TRelRkE0_vzfB%mgN0&4PASy3KO zSYW9zcuxK%8!C8D793b??TieQfT49>c5}4cO!mniRM_-A^MI!1mFNKjUqdrNj|&oL zP*DY-sDiBmlA6i(s`8xBfK^bK9H*)r2vnn&o?7Bske{3poSK}Um!hEw3wuZmDCiZZ zmiQ&+3K!gVc00a_}R?P&cEHFxOLv7NG3J$*Q`~D@Sf*_*7l>rloyN$-!NtqP3KC=liZXHv!nn*Ju81gC zI9Ll%a^~c}qLI2Y8JXCjN*FOozMghSjHn4|{t1jzLZWb$GtegB*OhZST zaJZCY=B5^xB<2=O4iMMoyr~Nbo=$M^O#Uk?%HsqJA{7Rw$#Qa`0-vQJK~%@k2@ImA z(wkf4X0mT)SNCNT=i*{!0eXqKjzf@ZE+fp_O_OtU=j$~g`~dQG6C(#dlCPT>g@n1D eLbL#7J0@G|J(ur5XaRY<1J&Cdo9*>qF#-U59eW7? diff --git a/integration/point/point.bin b/integration/point/point.bin index 788211d8118231405a75f2a5d11fc3bd7789c99e..a9f42b5d2a3ad5c0947d962a2d34308698ac4453 100644 GIT binary patch delta 30 lcmdnWyp>s$i@P8{Gp|IipeVm2Uy6f+SwL8Vaii!0MgWI+2loH~ delta 30 lcmdnWyp>s$i@P8{Gp|IipeVm2Uy6f+S%61^Wuxc<3_2ii~u2e1N;C0 delta 14 VcmX@le4crNI5Up~%SNfKi~u261NZ;{ diff --git a/integration/simple-deprecated-fields/simple.bin b/integration/simple-deprecated-fields/simple.bin index 6255f04249c3a2441afe5d57d9cec4dc503bee12..edc1b92bd4925c96e9de9d59b141d76e7448e6da 100644 GIT binary patch delta 31 mcmey)_MJ_Pi>EjEjEjEjEj)(=W-)O)V}-%q=KLn*5wmoAanX z7rPLv9K)o|#{~P>cs#i{xtKV(g_uDgGjj05xXd7~ nkTBO%h!&vi#L4~Y&*di~v@n7M898{NS{Q*^CT^apk-!Q724QK% delta 249 zcmaDE`!!mIi>Ej3kB!HPi<66qgIkDM zg~4fZhD4~qXK5}b76u{KI)+Y0MyaRLo6kwiWZxX9=*uR~#l_6Rz$nCA$05iymywHw zg@K7dh^1-rHud>>O^i(JT)bSYATdUuAR`AqjLQt-3JG&Pg=hiFc1&*8crM?8(8353 TWaQw5YGDLw>Db(EjEjTn*UK+T*9U7!DoxWbsVqn>*3Zt%FVE92$;?eHE=kNSC`g+8oKc(e zs6H3F5UU)+q|L_!``CCqxj4C)IJkwFRTw-cCrE?}-jn5GVqp+sYiDGb#Kds$dJ_fz(W1DKF0nQ3F&q`GmZ( zB~Vl^J+;KOAU`=HI5jyxFGWLB6RreooL+HiiCj3lMkuQ*Xw3vV&~%JVg-o-)pRp*@WZ&w pAg+)w*HefVpzOrS{p!!{kc%fPtfm$YRo~rRc5&)E0YOMeO delta 251 zcmaFa#`v{`QHG1BI5W2(CsnVYD8D3Mii3k$fJcHwiJ@w}BG=@7TJjsMCkQZI)}MS< zpn$P%vb~@NqxR&zj7pp(nYpROC5gEOlV=HPbKcbDVi#hSW9Zy`POy)S$BB!Ri;06< zh*^cfX>x`{sK94wE+!TRA=WyEPDVzlr_!6xNz7#59H{8aCeFph%)-DZ#9YTA$TgRd zi-m=Oi9v{^Y4SGp`Fc%^Ozd2|T&y55MxY=g2S1F<4B`q2b3KJ<0m^nvZq|4%-+|D= V2ohxE;Du^o1ZwHn+^P9M5&#S7H7WoA diff --git a/integration/simple-optionals/thing.bin b/integration/simple-optionals/thing.bin index 4780dd38c8797b83b3985368a7e8e7be6b20e666..1320735295cf71c32f1f3133a17ffdb8820e901f 100644 GIT binary patch delta 433 zcmYL^ze>YU6vppO(k8vJrcJTdU^S>iijYtXU8G}&3JN0bO>0bxX>Mpz|LxKtP)IX5 zhz}r6c?NOx1w=tmcb~wU{?W62-}!yt;rx`pDiY$oPS-Y7r;j}>aU7k=72pQAel7=+ zL*2l@S1LOu#-?ScCbo2f;=ZX(@Ydi|^R67j)y`~uVQXHuXSkl;bDUQ2zMXo~5Gy9u zz&OgmQF5VyQi$Ssk=_E0@R2>vz7-M005Lg)U<{%3QjA3ImaXpT=epc%*rdt!R8p*z znkqtaJTq4&u3Vd|2@_@(R(ZKL#RwTL37dxmQ%%FGJGk9BGTPWaQA(vhWYVa*hIgRb z*i~k5EC{8x23?EbyNH~wUy`RRL#~FS#g*tm*iROCL^A-2%n))}bO#Z`01AkV9}4+< w)rS;|(kKyogz+IK%q1O5F^4{<5wZ=!*ZlW-@E?J(3Aywv0!bu@K9)1^7lnvwfdBvi delta 262 zcmaE6{K-&?i@PKvGcR4QpeVm2Uy6f+S%61^MTw#6vi?M=0>-+DJsLXN>6s-NrAd0p z`MLV(`8kPs>H1*RNu_D}1tpaQsm1ywnYpROC5gEO6Q65y-qht{7h;uT=-e#L*vH1> z#Kp_*>AI4<{afO7roUH||9 diff --git a/integration/simple-proto2/simple.bin b/integration/simple-proto2/simple.bin index bc6fb523471b1c3ff2b5d7790b0892ab586db5b9..c879526ac6a7c2e75ecbbb8c90a5ac4aa159bd02 100644 GIT binary patch delta 31 mcmeys^npo?i>EjEjTn*UK+T*9U7!DoxWbsVqn>*3Zt%FVE92$;?eHE=kNSC`g+8oKc(e zs6H3F5UU)+q|L_!``CCqxj4C)IJkwFRTw-cCrE?}-jn5GVqp+sYiDGb#Kds$dJ_fz(W1DKF0nQ3F&q`GmZ( zB~Vl^J+;KOAU`=HI5jyxFGWLB6RreooL+HiiCj3lMkuQ*Xw3vV&~%JVg-o-)pRp*@WZ&w pAg+)w*HefVpzOrS{p!!{kc%fPtfm$YRo~rRc5&)E0YOMeO delta 251 zcmaFa#`v{`QHG1BI5W2(CsnVYD8D3Mii3k$fJcHwiJ@w}BG=@7TJjsMCkQZI)}MS< zpn$P%vb~@NqxR&zj7pp(nYpROC5gEOlV=HPbKcbDVi#hSW9Zy`POy)S$BB!Ri;06< zh*^cfX>x`{sK94wE+!TRA=WyEPDVzlr_!6xNz7#59H{8aCeFph%)-DZ#9YTA$TgRd zi-m=Oi9v{^Y4SGp`Fc%^Ozd2|T&y55MxY=g2S1F<4B`q2b3KJ<0m^nvZq|4%-+|D= V2ohxE;Du^o1ZwHn+^P9M5&#S7H7WoA diff --git a/integration/simple-string-enums/simple.bin b/integration/simple-string-enums/simple.bin index 602c5ff1ed0383085e71c150cf4154b299043411..8729b3131f73c89377872f0ae48469b40355ecaf 100644 GIT binary patch delta 31 mcmcc2a+yVpi>EjEjTn*UK+T*9U7!DoxWbsVqn>*3Zt%FVE92$;?eHE=kNSC`g+8oKc(e zs6H3F5UU)+q|L_!``CCqxj4C)IJkwFRTw-cCrE?}-jn5GVqp+sYiDGb#Kds$dJ_fz(W1DKF0nQ3F&q`GmZ( zB~Vl^J+;KOAU`=HI5jyxFGWLB6RreooL+HiiCj3lMkuQ*Xw3vV&~%JVg-o-)pRp*@WZ&w pAg+)w*HefVpzOrS{p!!{kc%fPtfm$YRo~rRc5&)E0YOMeO delta 251 zcmaFa#`v{`QHG1BI5W2(CsnVYD8D3Mii3k$fJcHwiJ@w}BG=@7TJjsMCkQZI)}MS< zpn$P%vb~@NqxR&zj7pp(nYpROC5gEOlV=HPbKcbDVi#hSW9Zy`POy)S$BB!Ri;06< zh*^cfX>x`{sK94wE+!TRA=WyEPDVzlr_!6xNz7#59H{8aCeFph%)-DZ#9YTA$TgRd zi-m=Oi9v{^Y4SGp`Fc%^Ozd2|T&y55MxY=g2S1F<4B`q2b3KJ<0m^nvZq|4%-+|D= V2ohxE;Du^o1ZwHn+^P9M5&#S7H7WoA diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index dfd3577e7..e4600a73e 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -56,7 +56,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() diff --git a/integration/simple/simple.bin b/integration/simple/simple.bin index eb98fb18e55275c972fcf16250eeb43bcf19851d..321bb33c3cc2a8864d634fb214a2b1c6de0b688b 100644 GIT binary patch delta 428 zcmaF1lJVARMj0-i;>_HFoK(GnqWqG4DGm;10bvP7C5Ea-0j|mC48=DZ&yip{ZaDd( zL;+JP<76jE4P&G9{QPvFj`aMT#JqI9{GxPyu;!%FH2spwg4AOD?7aN)JpGc)+|=Td z#N2{{q{**2wKliCZADPwgigmrKgs-7UU;q1g9qF=cQ<9YQmL(jngYmE%8gt%P-b|Dh6>hCL3yq zGn!34r!2WSNyC>-f}4w(g@I9srJa#OkZUd@7Yhpm6N3;-_vB-G^YywJnb^5_xmZDB yKsDWr9Q-gYGl(lB%=Hwa1t>dl@?`zz@)HqS7(s%J9K291j6f|DH_tTiRRI7pOKpY# delta 241 zcmcb$n(^66Mlmj);>_HFoK(GnqWqG4DGm;10bU7)jbb|`m@ey2z9><^SU1^OQiD-@ z@Ti}Nx? diff --git a/integration/struct/google/protobuf/struct.ts b/integration/struct/google/protobuf/struct.ts index 20465f053..a01146b34 100644 --- a/integration/struct/google/protobuf/struct.ts +++ b/integration/struct/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of that - * variants, absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of these + * variants. Absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/struct/struct.bin b/integration/struct/struct.bin index af5a5b0a396832343032246911f0234c0605e685..d9a1b260e4053e4b102673e7298fa2363c7d0065 100644 GIT binary patch delta 83 zcmeyT@?S-Yi>J7xs5H4mub?QuBwvbygIPdWf>DW~>iWiU#KpwI nD8ypR;L9kreXJ7xs5H4mub?QuBwvbygIR!2ffc7GJ4}o-H-Bf6<>Wie#KpwI mD8ypR;L9krZL$*2N&dtVE`_qhqRhm+l42c&#Ld5XT37)I78uk3 diff --git a/integration/type-registry/foo.bin b/integration/type-registry/foo.bin index c5f68fe8370664fd3a3f60c68122a55630db01ec..f6f140796958cb63ea5ace4bc73ceab82021b346 100644 GIT binary patch delta 432 zcmYL^Jx{_w0EX|{LdyXHB>^O&jXIQ=Tq7D1V;C85&=})R!BPpO*U;kEZipcw~|G%o7yAJ8iwdfWTn^Sqb)E`4s!qezPoZ1spk@`Au7(>b^dE}qtr_mh>} ztv%)vx>xc>Nhd@%G^`UtHFZpSx-xbe{g&dKTbiwOOmb=}PP?nwj@q@XhWok}c~lTD zh8DrdPr>VOtcD_p5uzfy3Toa1f0%kJAcg~CcmTl&!u)f=PYSnuc}G1_rFzYzOQwVA zuw1NTgrwk1TZy((WtPT_Hy2xoN|gylNiUsP*{2xRHK%Hk=JA2nB<7J^EdC+mMQm%% zu4)onp29((6mIm}2F14#eY$!^KV@iA*}qA&!nr77IRHg&0EHB~gNWk*14M4<#WVMK v2pJy5Q7GsrGlW877TF+*Y4kBs=&kF$WWJW%e+3356yj3_QpNS(vm^Km3PWn2 delta 260 zcmaE6^2tboi!&`hU$3Ajza(FZgM(RsM}kF(q3W{!M2P~%x`|yHI@;-(B^jkjddc~@ z`sw*OiFxVzVAV;bY5D~vl?AEA`X!mUsl_FUxdjuSYIEMykCk&A_efr&wgrD-yw_m)$JNF_YcYE3qt5A;B{bXi{E@9?)P7 z%>+FzE(H*PiYfp_6>MQVkebOq`Q$kvYJkcnOYkdO0!8)GQ%hV6@{==yQ|DHDtROL UAVEeBUZ@sEpq7b~pNjtj07FA!SO5S3 delta 245 zcmca^{Mc}UCEDS=dbqt-1j8adfH_LI%WZ%3{z?V&&i;J0sfl-LLjzf@ZE+ZEU3j-5_ z5KGf!Hu3p-O^i(JT)bSYATdUuAR`AqjLQt-3JG&Pg=hiFc1*r3{#?ETp@k77$jHG9 O)xrqW(lPm_#6JL5W;O5t diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index dfd3577e7..e4600a73e 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -56,7 +56,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() diff --git a/integration/use-date-string/use-date-string.bin b/integration/use-date-string/use-date-string.bin index 6629454ec9e20d142c1418f968c50ded87ca8467..79e656e01000f5d7270deddc4d832437ec5448d9 100644 GIT binary patch delta 399 zcmX?ScF1Ca42Q4;qY^{aal?r!1x&4s6Q^nz8>Q#xr{|>VrRV1)=B4Z97p3bL6y=xX zCzYn@msA#{7VBr{<(KE_mt^Lq7MCRE78E2+e5uWORG*7oh*geZ(q>u4J~kdtE>12c z4sIc46$a1A+u1_}@5yp8u`md+wKFnIVq}y$FS}WWVLPtVUu%uClV zD9SI%Pby8*FDR)jNG;Yc$;?eHE=kNSnD|kf^QJBryAZ1!L+55y#y&P4CoWDdCJt^P zW)%jf$@|$u1wKo2F|jZRvDPtkGBQd%mENq%F_V4s3ISg>aV{=q76wKk<~j~RuDOg{ zEG!I63_>hTlX=DG>oqYlv2*cqv4X@Hfr5-2{4g#vh$|$_^%SB7DBCglmiTk|4ulp) UkRT%mFH{R7P)o<=2NFrl0C>DMfdBvi diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index dfd3577e7..e4600a73e 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -56,7 +56,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() diff --git a/integration/use-date-true/use-date-true.bin b/integration/use-date-true/use-date-true.bin index c71a37d8a2cb67b4c55de2e8f0923ec18381c199..1a6bb1cb0024b8d28d032b12bc38d5d5cd307ce9 100644 GIT binary patch delta 417 zcmX?Qw$EaM6sNERqY^{aaYL@jd=d&1o&A|w87EHGFg8lh&ri=u)l1LMNz6;v%P&gT zFDS|{$xkXx(=VwkNG;aS&dV>)(=W-)O)V}-%q=KLn)qCs^Qb--yAZ1!!=%m9jD2i8 zo?M(VZEWdIfP*g8HwZyd`KRF{fH90>o zMMF~)t^{nHUU6!PUt(T?-0_dNdR0Xri^4yY}H}m_l zNpN#9voJ6Uv9vRC2y)G37FbuHeausk%^s)mx~o722|6{$iWZeGK086 m!dy=wT7a?>CqEH;Eliv28Ks^|Z&v1*$-a4+fG?Xk7Z)=N1EUag9fu&-Tt+Sy76v8; zA(p1e+~V`~ni!ebxp=u)L1K(RK}HUK7?&Bu6%yup3ef_T?U;N+{JDGwLJK2EkdcEI Ps)Z4#rDO9wi3DZi@Pi_r!-ZspeVm2Uy6f+SwL8VQHi1I|3=9>OpLQOe`Av6SZyE>)0}u`v03rZ-{vryKd?OvPIK2V^nX~o+ t9SIJ@0tx~I0TKi~08IfJwv! Date: Sat, 27 Nov 2021 11:21:55 +0100 Subject: [PATCH 15/22] Add dockerized protoc documentation --- README.markdown | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.markdown b/README.markdown index c92674219..1e7a6f095 100644 --- a/README.markdown +++ b/README.markdown @@ -402,6 +402,30 @@ The commands below assume you have **Docker** installed. To use a **local** copy - Also include the generated `.ts` files. - Create a pull request +**Dockerized Protoc** + +The repository includes a dockerized version of `protoc`, which is configured in [docker-compose.yml](docker-compose.yml). + +It can be useful in case you want to manually invoke the plugin with a known version of `protoc`. + +Usage: + +```bash +# Include the protoc alias in your shell. +. aliases.sh + +# Run protoc as usual. The ts-proto directory is available in /ts-proto. +protoc --plugin=/ts-proto/protoc-gen-ts_proto --ts_proto_out=./output -I=./protos ./protoc/*.proto + +# Or use the ts-protoc alias which specifies the plugin path for you. +ts-protoc --ts_proto_out=./output -I=./protos ./protoc/*.proto +``` + +- All paths must be relative paths _within_ the current working directory of the host. `../` is not allowed +- Within the docker container, the absolute path to the project root is `/ts-proto` +- The container mounts the current working directory in `/host`, and sets it as its working directory. +- Once `aliases.sh` is sourced, you can use the `protoc` command in any folder. + # Assumptions - TS/ES6 module name is the proto package From b3e44149cf904e220be0f6e178210f442bddd3d8 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Sat, 27 Nov 2021 12:37:18 +0100 Subject: [PATCH 16/22] Recompile ts without docker --- integration/type-registry/google/protobuf/timestamp.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 3369aef3b..1fd946d9c 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -201,3 +201,12 @@ if (util.Long !== Long) { util.Long = Long as any; configure(); } +rn long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} From 4edc99a56b7e3d70d4dd25346388fbbd039fd990 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Sat, 27 Nov 2021 12:51:16 +0100 Subject: [PATCH 17/22] Recompile proto files --- integration/grpc-js/simple.bin | Bin 20908 -> 20909 bytes integration/value/value.bin | Bin 9574 -> 4969 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/integration/grpc-js/simple.bin b/integration/grpc-js/simple.bin index 97028a38bf8ada15090b6b4bc9c54493bf556198..a4adec6064309d08147fbbb804084e27b84dc709 100644 GIT binary patch delta 117 zcmV-*0E+*tqXDg>0UQbpb7^gGY-KKRa&L5R8VCpj5EB>yA^>{75(<-XL>#d=pE3jg zA_|kwL>;sDGQ9!`njH!T5(FLqUb9~cjRvzyJct4g!~zNe1OXBRJpfGs8n=_+KFJVe Xb7cx3c42a9VQzGDE+9d(xIgp}9atm` delta 106 zcmV-w0G0o(qXDd=0Tv1jb7^gGY-KKRa&L5R8VCpj5Dpjsu@=EH1O6fklh8yRv-dK+ z0tuNN3I-Ac9spjmUkZ%|vr0UO0uI9h3IYTH5(GT}O#vFVli)td4`Fl)Aa-GLX<=@3 Mb1WcXv$;R?5x2S^*Z=?k diff --git a/integration/value/value.bin b/integration/value/value.bin index b89c95276a979abbab72293401cfc1d40822f099..f10ce787a935b5954f153800f8f7c9026c818d45 100644 GIT binary patch delta 261 zcmXxcK?=e!5Czc5Bu(pYHwHmLh1NoKQBd&~9>cv<)V+u3&Qo;jA-sm@Eu28IeDnXG z&+*p`&#`*<=eq4*_3-#ASZ9bbg$$~2n#f@U*5ou(1Aq-VV|)S7hLqDLn;?hWSV{@6 zP$2QJUehQkCbMOf7L`?)No0BBqnqrM>@3eiQ~7XFN6F4M>#$>|Q{IP&jTfTiNt%~Y U@+7U=D0z}@cPD$fcK7b^2jxx_RsaA1 delta 2962 zcma);&u<$=6vt-&6VZG~k z*RkA-k+^cp4aEO|gv6Z-;>I7q9f>m+j(lf!*3MQo;x=#gy*HovzBe=b*R?+%{`g&G z^7{t8+Kr-aAh-I1D2ZCb&emuk`h7Ww8+wLaOuwfVzSlPB(udKo70Ay-FqG^PEu5;s z6^mPS>q%m(qC)0l66KsG z8TWTMrIX=tAXYU)UPFIhjUgH&o_bxm$ zC3viA^4NNQ`|NxBx|bE^>^J-7>aT0G$lN-4Y0*DcsI|iOgr;k47;Sk+AfD5ILOTc!=Tcw=3F0l!7?%J!>Rn;Oq z%{6VCWm-@k1?A#VV8dGP=QNjU~yLL%)!9wt^cOkPtxw}%)ls0o8kcZa#B1&J~x>L&8^*W=B z^$lmlw6V|wLuo6@{VAo+l%s?LDEAE|EClZxN?4%W2c@dH!`w&YiB(%v^kE+J+%vF% z)4@`YOwk?1c`z+{nkxqi4}cz+qQgS;fhjsHfF78lyUcw?Hl8mmIyiT>&&z2ZnHgrT zH_=4SGb5*~Fb~hmxwD<4gaarKjhwI$d}!o^1e2i&)WQQiRdf0p&%|sdgQ0Bd zcc9r3K`fQCI`l;>+4U;)Do#^T0sD5PTG6LT<;>}d@4)r#qCP&b5bKwgGYh!>#TDA! z1aFDC5g9DJo6@5)1wQw0FhkBArxKQmjIJexc{0^C^~-_61E42HS6GNXF}lJ6=!t1l zkGUhV@p56Cw$u;FlymlbvH;V=LL<|rp28eY+f--DQNjU~W7DRv5Ii<*3Ja9ul}f9q ze<^of{^QWIA1XJh)rCKwXTMZ_F8^(*e;h)}XJ50+6TBGefIFm)V(S;9K+4wiwl8>> z=u&pu7wwv^Brf(MbBgxm%tC_Vl{YgBSVg{W!tkkN*UcvjVI}+Z%)+-XN^fjrCgMuh luA4Z#te$<_e6n3-(ab^?Z;59XvUuy8nS~_Y)~!sFe*s2?o!S5Z From b9d8d45055bf58d4110f3ac41f20863f61d2ce2b Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Sat, 27 Nov 2021 13:09:08 +0100 Subject: [PATCH 18/22] Recompile proto files --- integration/grpc-js/google/protobuf/struct.ts | 4 ++-- .../meta-typings/google/protobuf/timestamp.ts | 21 ++++++------------- .../google/protobuf/timestamp.ts | 20 +++++++++--------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/integration/grpc-js/google/protobuf/struct.ts b/integration/grpc-js/google/protobuf/struct.ts index abe3dfe8d..a2b7d6f54 100644 --- a/integration/grpc-js/google/protobuf/struct.ts +++ b/integration/grpc-js/google/protobuf/struct.ts @@ -60,8 +60,8 @@ export interface Struct_FieldsEntry { /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a - * list of values. A producer of value is expected to set one of that - * variants, absence of any variant indicates an error. + * list of values. A producer of value is expected to set one of these + * variants. Absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index f31402980..927b4c71a 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -57,16 +57,7 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from Java `Instant.now()`. - * - * Instant now = Instant.now(); - * - * Timestamp timestamp = - * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) - * .setNanos(now.getNano()).build(); - * - * - * Example 6: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() @@ -186,7 +177,7 @@ export const protoMetadata: ProtoMetadata = { javaPackage: 'com.google.protobuf', javaOuterClassname: 'TimestampProto', javaMultipleFiles: true, - goPackage: 'google.golang.org/protobuf/types/known/timestamppb', + goPackage: 'github.com/golang/protobuf/ptypes/timestamp', ccEnableArenas: true, objcClassPrefix: 'GPB', csharpNamespace: 'Google.Protobuf.WellKnownTypes', @@ -195,21 +186,21 @@ export const protoMetadata: ProtoMetadata = { location: [ { path: [4, 0], - span: [135, 0, 146, 1], + span: [126, 0, 137, 1], leadingDetachedComments: [], leadingComments: - ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n Instant now = Instant.now();\n\n Timestamp timestamp =\n Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n .setNanos(now.getNano()).build();\n\n\n Example 6: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', + ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', }, { path: [4, 0, 2, 0], - span: [139, 2, 20], + span: [130, 2, 20], leadingDetachedComments: [], leadingComments: ' Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.\n', }, { path: [4, 0, 2, 1], - span: [145, 2, 18], + span: [136, 2, 18], leadingDetachedComments: [], leadingComments: ' Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.\n', diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 1fd946d9c..2f723335c 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -57,7 +57,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() @@ -201,12 +210,3 @@ if (util.Long !== Long) { util.Long = Long as any; configure(); } -rn long.toNumber(); -} - -// If you get a compile-error about 'Constructor and ... have no overlap', -// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. -if (util.Long !== Long) { - util.Long = Long as any; - configure(); -} From 5ecd4a57570d7d75170b419f6ef7b2e956c2ea55 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 27 Nov 2021 10:11:22 -0600 Subject: [PATCH 19/22] Rename bin2pbjs to proto2pbjs. --- README.markdown | 2 +- package.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 1e7a6f095..72f613cc0 100644 --- a/README.markdown +++ b/README.markdown @@ -379,7 +379,7 @@ The commands below assume you have **Docker** installed. To use a **local** copy > _This runs the following commands:_ > - `proto2bin` — Converts integration test `.proto` files to `.bin`. > - `bin2ts` — Runs `ts-proto` on the `.bin` files to generate `.ts` files. - > - `bin2pbjs` — Generates a reference implementation using `pbjs` for testing compatibility. + > - `proto2pbjs` — Generates a reference implementation using `pbjs` for testing compatibility. - Run `yarn test` **Workflow** diff --git a/package.json b/package.json index b66a9959b..19f9795e1 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,14 @@ }, "scripts": { "build": "yarn tsc", - "build:test": "yarn proto2bin && yarn bin2pbjs && yarn bin2ts", - "build:test:local": "yarn proto2bin:local && yarn bin2pbjs:local && yarn bin2ts:local", + "build:test": "yarn proto2bin && yarn proto2pbjs && yarn bin2ts", + "build:test:local": "yarn proto2bin:local && yarn proto2pbjs:local && yarn bin2ts:local", "proto2bin": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc update-bins.sh", "proto2bin-node": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration node update-bins.sh", - "bin2pbjs": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc pbjs.sh", + "proto2pbjs": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc pbjs.sh", "bin2ts": "docker-compose run --rm --entrypoint bash -w /ts-proto/integration protoc codegen.sh", "proto2bin:local": "integration/update-bins.sh", - "bin2pbjs:local": "integration/pbjs.sh", + "proto2pbjs:local": "integration/pbjs.sh", "bin2ts:local": "integration/codegen.sh", "test": "yarn jest -c jest.config.js --maxWorkers=2", "prettier": "prettier --write {src,tests}/**/*.ts", From 1659e94d33d788b377f7bed6ab5384b765f51235 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 27 Nov 2021 10:14:44 -0600 Subject: [PATCH 20/22] Fix file.bin case. --- integration/update-bins.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/update-bins.sh b/integration/update-bins.sh index 445ab12d4..ae2be93a5 100755 --- a/integration/update-bins.sh +++ b/integration/update-bins.sh @@ -18,6 +18,6 @@ for FILE in $PROTO_FILES; do echo "${FILE}" INPUT_DIR="$(dirname "$FILE")" OUTPUT_FILE="${FILE%proto}bin" - protoc --experimental_allow_proto3_optional "--plugin=$PLUGIN_PATH" --dump_out=. "${FILE}" "-I${INPUT_DIR}"\ - && mv FILE.bin "${OUTPUT_FILE}" + protoc --experimental_allow_proto3_optional "--plugin=$PLUGIN_PATH" --dump_out=. "${FILE}" "-I${INPUT_DIR}" + mv file.bin "${OUTPUT_FILE}" done From c0eb1c6501c6286cb3f9fd3431d8c6790666dbe9 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 27 Nov 2021 10:17:03 -0600 Subject: [PATCH 21/22] Update workflow to use bin2ts. --- .github/workflows/build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d8509eff..33a3fe48c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,10 +28,9 @@ jobs: run: ./integration/pbjs.sh # This will fail if any git-tracked file has changed - name: Codegen - run: | - cd integration - ./codegen.sh - git status && git diff --exit-code + run: yarn bin2ts + - name: Diff Output + run: git status && git diff --exit-code - name: test run: yarn test env: From e86d8c12a8331e0af06f08f4db392361126d2f9d Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 27 Nov 2021 10:17:14 -0600 Subject: [PATCH 22/22] Run bin2ts output. --- .../meta-typings/google/protobuf/timestamp.ts | 21 +++++++++++++------ .../google/protobuf/timestamp.ts | 11 +--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index 927b4c71a..f31402980 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -57,7 +57,16 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime() @@ -177,7 +186,7 @@ export const protoMetadata: ProtoMetadata = { javaPackage: 'com.google.protobuf', javaOuterClassname: 'TimestampProto', javaMultipleFiles: true, - goPackage: 'github.com/golang/protobuf/ptypes/timestamp', + goPackage: 'google.golang.org/protobuf/types/known/timestamppb', ccEnableArenas: true, objcClassPrefix: 'GPB', csharpNamespace: 'Google.Protobuf.WellKnownTypes', @@ -186,21 +195,21 @@ export const protoMetadata: ProtoMetadata = { location: [ { path: [4, 0], - span: [126, 0, 137, 1], + span: [135, 0, 146, 1], leadingDetachedComments: [], leadingComments: - ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', + ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n Instant now = Instant.now();\n\n Timestamp timestamp =\n Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n .setNanos(now.getNano()).build();\n\n\n Example 6: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', }, { path: [4, 0, 2, 0], - span: [130, 2, 20], + span: [139, 2, 20], leadingDetachedComments: [], leadingComments: ' Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.\n', }, { path: [4, 0, 2, 1], - span: [136, 2, 18], + span: [145, 2, 18], leadingDetachedComments: [], leadingComments: ' Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.\n', diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 2f723335c..3369aef3b 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -57,16 +57,7 @@ export const protobufPackage = 'google.protobuf'; * .setNanos((int) ((millis % 1000) * 1000000)).build(); * * - * Example 5: Compute Timestamp from Java `Instant.now()`. - * - * Instant now = Instant.now(); - * - * Timestamp timestamp = - * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) - * .setNanos(now.getNano()).build(); - * - * - * Example 6: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from current time in Python. * * timestamp = Timestamp() * timestamp.GetCurrentTime()