diff --git a/.gitignore b/.gitignore index 2c39f51..f9db292 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,6 @@ dist .yarn/install-state.gz .pnp.* +# tmp directories to build proto dependencies validate +google diff --git a/Makefile b/Makefile index 8c1580b..12aa00c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ export -CLIENTS=go js +CLIENTS=go nodejs # CONFIG CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1` @@ -14,12 +14,13 @@ LAST_TAG:=$(shell git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0) export GO111MODULE=on PLATFORM_PREFIX=hoguera/platform +NODE_MODULES_BIN=$(PWD)/node_modules/.bin # PROTO GOOGLEAPIS_PROTO=${SUBMODULES_DIR}/googleapis GOOGLEPROTOBUF_PROTO=${SUBMODULES_DIR}/protobuf/src PROTOC_GEN_VALIDATE_PROTO=${SUBMODULES_DIR}/protoc-gen-validate GOOGLE_OPENAPI_PROTO=${SUBMODULES_DIR}/gnostic/openapiv3 -PROTO_OPTION=-Iproto -I${SUBMODULES_DIR} -I${GOOGLEAPIS_PROTO} -I${GOOGLEPROTOBUF_PROTO} -I${PROTOC_GEN_VALIDATE_PROTO} -I${GOOGLE_OPENAPI_PROTO} +PROTO_OPTION=-I. -I${SUBMODULES_DIR} -I${GOOGLEAPIS_PROTO} -I${GOOGLEPROTOBUF_PROTO} -I${PROTOC_GEN_VALIDATE_PROTO} -I${GOOGLE_OPENAPI_PROTO} PROTO_DOCS_OPTS=${PROTO_OPTION} \ --plugin=protoc-gen-doc=${BIN_DIR}/protoc-gen-doc @@ -28,22 +29,24 @@ help: @echo "Usage: make " @echo "" @echo "Targets:" - @echo " vendor - Update vendor" - @echo " plugin - Build protoc plugins" - @echo " proto - Generate all of the proto clients" - @echo " clean - Clean all of the proto clients" - @echo " release - Publish all of the proto clients" - @echo " proto/go - Generate go client from proto" - @echo " clean/go - Clean go client" - @echo " release/go - Publish go client" - @echo " proto/ts - Generate typescript client from proto" - @echo " release/ts - Publish typescript client" - @echo " dep/ts - Install typescript dependencies" - @echo " docs - Generate docs" - @echo " lint - Lint proto" - @echo " fmt - Format proto (wip)" - @echo " changelog - Generate changelog" - @echo " help - Show this help message" + @echo " vendor - Update vendor" + @echo " plugin - Build protoc plugins" + @echo " proto - Generate all of the proto clients" + @echo " clean - Clean all of the proto clients" + @echo " release - Publish all of the proto clients" + @echo " proto/go - Generate go client from proto" + @echo " clean/go - Clean go client" + @echo " release/go - Publish go client" + @echo " proto/ts - WIP Generate typescript client from proto" + @echo " proto/nodejs - Generate nodejs client from proto" + @echo " clean/nodejs - Clean nodejs client" + @echo " release/nodejs - Publish nodejs client" + @echo " dep/npm - Install npm dependencies" + @echo " docs - Generate docs" + @echo " lint - Lint proto" + @echo " fmt - Format proto (wip)" + @echo " changelog - Generate changelog" + @echo " help - Show this help message" .PHONY: vendor vendor: go.sum .gitmodules @@ -83,7 +86,6 @@ proto/% release/% clean/%: # GO PROTOC_GO_OPTS=${PROTO_OPTION} \ - -I. \ --plugin=protoc-gen-go=${BIN_DIR}/protoc-gen-go \ --go_out=${GEN_GO_DIR} \ --plugin=protoc-gen-go-grpc=${BIN_DIR}/protoc-gen-go-grpc \ @@ -91,11 +93,9 @@ PROTOC_GO_OPTS=${PROTO_OPTION} \ --plugin=protoc-gen-validate=${BIN_DIR}/protoc-gen-validate-go \ --validate_out=${GEN_GO_DIR} PROTOC_GATEWAY_SPEC_OPT=${PROTO_OPTION} \ - -I. \ --plugin=protoc-gen-openapi=${BIN_DIR}/protoc-gen-openapi \ --openapi_out=:${GEN_GO_DIR} PROTOC_GRPC_GATEWAY_OPTS=${PROTO_OPTION} \ - -I. \ --plugin=protoc-gen-grpc-gateway=${BIN_DIR}/protoc-gen-grpc-gateway \ --grpc-gateway_out=logtostderr=true:${GEN_GO_DIR} @@ -135,7 +135,6 @@ release/go: proto @cd ${TMP_REPO_DIR}/client-go && git add . && git commit -m "bump(version): $(NEXT_VERSION)" && git tag -a $(NEXT_VERSION) -m '$(NEXT_VERSION)' && git push --tags origin main # TS -NODE_MODULES_BIN=$(PWD)/node_modules/.bin TYPESCRIPT_OUTPUT=gen/typescript PROTOC_TS_OPT=${PROTO_OPTION} \ --plugin=protoc-gen-ts=${NODE_MODULES_BIN}/protoc-gen-ts \ @@ -150,6 +149,7 @@ REGEX_REPLACE='s|(\.\./)+google/|@areugoh/vendor-proto-ts/gen/google/|' .PHONY: proto/ts proto/ts: @echo "Generating typescript client from proto..." + @echo "WIP" @rm -rf $(TYPESCRIPT_OUTPUT) && mkdir -p $(TYPESCRIPT_OUTPUT) @find proto -name '*.proto' -print0 | xargs -0 -I{} -P${CPUS} ${TS_COMMAND} {} @rm -rf validate && mkdir validate && cp $(PROTOC_GEN_VALIDATE_PROTO)/validate/validate.proto validate @@ -158,22 +158,66 @@ proto/ts: # @find $(TYPESCRIPT_OUTPUT) -name '*.js' -print0 -name '*.d.ts' -print0 | xargs -0 -I{} -P${CPUS} sed -i -E ${REGEX_REPLACE} {} .PHONY: release/ts -release/ts: proto/ts docs +release/ts: proto/ts @echo "Publishing typescript client..." + @echo "WIP" @git fetch --tags + # @rm -rf ${TMP_REPO_DIR} && mkdir -p ${TMP_REPO_DIR} + # @git clone ${REPO}-typescript.git ${TMP_REPO_DIR}/client-typescript + # @cd ${TMP_REPO_DIR}/client-typescript&& git clean -fdx #&& git checkout main + # @cp $(PWD)/scripts/typescript/*.* ${TMP_REPO_DIR}/client-typescript/ + # @cp -R $(PWD)/scripts/typescript/.github ${TMP_REPO_DIR}/client-typescript/ + # @cp $(PWD)/docs/README.md ${TMP_REPO_DIR}/client-typescript/README.md + # @cp $(PWD)/CHANGELOG.md ${TMP_REPO_DIR}/client-typescript/CHANGELOG.md + # @cp -R $(PWD)/gen/typescript/src ${TMP_REPO_DIR}/client-typescript + # @$(eval NEXT_VERSION=$(shell test $(NEXT_VERSION) && echo $(NEXT_VERSION) || echo $(LAST_TAG))) + # @cd ${TMP_REPO_DIR}/client-typescript&& git add . && git commit -m "bump(version): $(NEXT_VERSION)" && git tag -a $(NEXT_VERSION) -m '$(NEXT_VERSION)' && git push --tags origin main + +# NodeJS +NODEJS_OUTPUT=gen/nodejs +PROTOC_NODEJS_OPT=${PROTO_OPTION} \ + --js_out=import_style=commonjs,binary:${NODEJS_OUTPUT} \ + --grpc_out=grpc_js:${NODEJS_OUTPUT} +NODEJS_COMMAND=${NODE_MODULES_BIN}/grpc_tools_node_protoc \ + ${PROTOC_NODEJS_OPT} +.PHONY: proto/nodejs +proto/nodejs: clean/nodejs + @echo "Generating nodejs client from proto..." + @rm -rf $(NODEJS_OUTPUT) && mkdir -p $(NODEJS_OUTPUT) + @find proto -name '*.proto' -print0 | xargs -0 -I{} -P${CPUS} ${NODEJS_COMMAND} {} + @echo "Generating nodejs vendor..." + @mkdir -p google/protobuf && cp $(GOOGLEPROTOBUF_PROTO)/google/protobuf/*.proto google/protobuf + @mkdir -p google/api && cp $(GOOGLEAPIS_PROTO)/google/api/*.proto google/api + @mkdir -p google/rpc && cp $(GOOGLEAPIS_PROTO)/google/rpc/*.proto google/rpc + @mkdir -p google/type && cp $(GOOGLEAPIS_PROTO)/google/type/*.proto google/type + @mkdir -p google/longrunning && cp $(GOOGLEAPIS_PROTO)/google/longrunning/*.proto google/longrunning + @mkdir validate && cp $(PROTOC_GEN_VALIDATE_PROTO)/validate/validate.proto validate + @find google -name '*.proto' -print0 | xargs -0 -I{} -P${CPUS} ${NODEJS_COMMAND} {} 2>/dev/null || true + @find validate -name '*.proto' -print0 | xargs -0 -I{} -P${CPUS} ${NODEJS_COMMAND} {} 2>/dev/null || true + +.PHONY: release/nodejs +release/nodejs: proto/nodejs + @echo "Publishing nodejs client..." + @git switch main && git pull origin main && git fetch --tags @rm -rf ${TMP_REPO_DIR} && mkdir -p ${TMP_REPO_DIR} - @git clone ${REPO}-typescript.git ${TMP_REPO_DIR}/client-typescript - @cd ${TMP_REPO_DIR}/client-typescript&& git clean -fdx #&& git checkout main - @cp $(PWD)/scripts/typescript/*.* ${TMP_REPO_DIR}/client-typescript/ - @cp -R $(PWD)/scripts/typescript/.github ${TMP_REPO_DIR}/client-typescript/ - @cp $(PWD)/docs/README.md ${TMP_REPO_DIR}/client-typescript/README.md - @cp $(PWD)/CHANGELOG.md ${TMP_REPO_DIR}/client-typescript/CHANGELOG.md - @cp -R $(PWD)/gen/typescript/src ${TMP_REPO_DIR}/client-typescript + @git clone ${REPO}-nodejs.git ${TMP_REPO_DIR}/client-nodejs + @cd ${TMP_REPO_DIR}/client-nodejs && git clean -fdx #&& git checkout main + @cp -R $(PWD)/scripts/nodejs/ ${TMP_REPO_DIR}/client-nodejs/ + @cp -R $(PWD)/scripts/nodejs/.git* ${TMP_REPO_DIR}/client-nodejs/ + @cp -R $(PWD)/scripts/nodejs/.npmrc ${TMP_REPO_DIR}/client-nodejs/.npmrc + @cp $(PWD)/CHANGELOG.md ${TMP_REPO_DIR}/client-nodejs/CHANGELOG.md + @cp -R $(PWD)/gen/nodejs/* ${TMP_REPO_DIR}/client-nodejs @$(eval NEXT_VERSION=$(shell test $(NEXT_VERSION) && echo $(NEXT_VERSION) || echo $(LAST_TAG))) - @cd ${TMP_REPO_DIR}/client-typescript&& git add . && git commit -m "bump(version): $(NEXT_VERSION)" && git tag -a $(NEXT_VERSION) -m '$(NEXT_VERSION)' && git push --tags origin main + @cd ${TMP_REPO_DIR}/client-nodejs && git add . && git commit -m "bump(version): $(NEXT_VERSION)" && npm version $(NEXT_VERSION) && git tag -a $(NEXT_VERSION) -m '$(NEXT_VERSION)' && git push --tags origin main + +.PHONY: clean/nodejs +clean/nodejs: + @echo "Cleaning nodejs client..." + @rm -rf $(NODEJS_OUTPUT) + @rm -rf google validate -.PHONY: dep/ts -dep/js: +.PHONY: dep/npm +dep/npm: @echo "Installing typescript dependencies..." @npm install diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 4525200..0000000 --- a/docs/README.md +++ /dev/null @@ -1,212 +0,0 @@ -# Protocol Documentation - - -## Table of Contents - -- [proto/api/v1/mobile.proto](#proto_api_v1_mobile-proto) - - [Animal](#platform-api-v1-Animal) - - [AnimalsRequest](#platform-api-v1-AnimalsRequest) - - [CoastRequest](#platform-api-v1-CoastRequest) - - [CoastResponse](#platform-api-v1-CoastResponse) - - [LocationRequest](#platform-api-v1-LocationRequest) - - [LocationResponse](#platform-api-v1-LocationResponse) - - [V1Response](#platform-api-v1-V1Response) - - - [Condition](#platform-api-v1-Condition) - - - [Bff](#platform-api-v1-Bff) - - [Internal](#platform-api-v1-Internal) - -- [Scalar Value Types](#scalar-value-types) - - - - -

Top

- -## proto/api/v1/mobile.proto - - - - - -### Animal -Animals - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| name | [string](#string) | | | -| in_danger | [bool](#bool) | | | -| description | [string](#string) | | | - - - - - - - - -### AnimalsRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [LocationResponse](#platform-api-v1-LocationResponse) | | | - - - - - - - - -### CoastRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [LocationResponse](#platform-api-v1-LocationResponse) | | | - - - - - - - - -### CoastResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| name | [string](#string) | | | -| condition | [Condition](#platform-api-v1-Condition) | | | -| temperature | [float](#float) | | | -| distance | [double](#double) | | | - - - - - - - - -### LocationRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| ip | [string](#string) | | | - - - - - - - - -### LocationResponse -Location - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| longitude | [int32](#int32) | | | -| latitude | [int32](#int32) | | | -| name | [string](#string) | | | - - - - - - - - -### V1Response -BFF - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [LocationResponse](#platform-api-v1-LocationResponse) | | | -| nearest_aquatic_location | [CoastResponse](#platform-api-v1-CoastResponse) | | | -| animals | [Animal](#platform-api-v1-Animal) | repeated | | - - - - - - - - - - -### Condition -Coast - -| Name | Number | Description | -| ---- | ------ | ----------- | -| GOOD | 0 | | -| MODERATE | 1 | | -| CONTAMINATED | 2 | | -| UNKNOWN | 3 | | -| RADIATION | 4 | | -| DANGER | 5 | | -| PROTECTED | 6 | | - - - - - - - - - -### Bff -BFF service - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| GetV1 | [.google.protobuf.Empty](#google-protobuf-Empty) | [V1Response](#platform-api-v1-V1Response) | | - - - - -### Internal -Internal service - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| GetAnimals | [AnimalsRequest](#platform-api-v1-AnimalsRequest) | [Animal](#platform-api-v1-Animal) stream | | -| GetCoast | [CoastRequest](#platform-api-v1-CoastRequest) | [CoastResponse](#platform-api-v1-CoastResponse) | | -| GetLocation | [LocationRequest](#platform-api-v1-LocationRequest) | [LocationResponse](#platform-api-v1-LocationResponse) | | - - - - - -## Scalar Value Types - -| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | -| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | -| double | | double | double | float | float64 | double | float | Float | -| float | | float | float | float | float32 | float | float | Float | -| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | -| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | -| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | -| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | -| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | -| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | -| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | - diff --git a/package-lock.json b/package-lock.json index 6799e3d..cccb241 100644 --- a/package-lock.json +++ b/package-lock.json @@ -131,9 +131,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.9.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.2.tgz", - "integrity": "sha512-WHZXKFCEyIUJzAwh3NyyTHYSR35SevJ6mZ1nWwJafKtiQbqRTIKSRcw3Ma3acqgsent3RRDqeVwpHntMk+9irg==", + "version": "20.9.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.3.tgz", + "integrity": "sha512-nk5wXLAXGBKfrhLB0cyHGbSqopS+nz0BUgZkUQqSHSSgdee0kssp1IAqlQOu333bW+gMNs2QREx7iynm19Abxw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" diff --git a/scripts/nodejs/.github/workflows/publish.yaml b/scripts/nodejs/.github/workflows/publish.yaml new file mode 100644 index 0000000..c5544ec --- /dev/null +++ b/scripts/nodejs/.github/workflows/publish.yaml @@ -0,0 +1,24 @@ +name: Publish package to GitHub Packages +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@areugoh' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/nodejs/.gitignore b/scripts/nodejs/.gitignore new file mode 100644 index 0000000..c6bba59 --- /dev/null +++ b/scripts/nodejs/.gitignore @@ -0,0 +1,130 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/scripts/nodejs/.npmignore b/scripts/nodejs/.npmignore new file mode 100644 index 0000000..fad39f7 --- /dev/null +++ b/scripts/nodejs/.npmignore @@ -0,0 +1,2 @@ +.github +.git* diff --git a/scripts/nodejs/.npmrc b/scripts/nodejs/.npmrc new file mode 100644 index 0000000..459755b --- /dev/null +++ b/scripts/nodejs/.npmrc @@ -0,0 +1,3 @@ +registry=https://registry.npmjs.org/ +@areugoh:registry=https://npm.pkg.github.com/ +npm.pkg.github.com/:_authToken= diff --git a/scripts/nodejs/README.md b/scripts/nodejs/README.md new file mode 100644 index 0000000..ffa6040 --- /dev/null +++ b/scripts/nodejs/README.md @@ -0,0 +1,36 @@ +# Client-nodejs + +> **Warning:** This repository is automatically generated. Please don't make any changes here. + +This repository contains the client libraries for the [areugoh](https://github.com/areugoh) services. +It's **automatically generated** from the [proto](https://github.com/areugoh/proto) repository. + +## Installation + +Update your `~/.npmrc` file to include the following line. + +```bash +# ~/.npmrc +registry=https://registry.npmjs.org/ +@areugoh:registry=https://npm.pkg.github.com/ +//npm.pkg.github.com/:_authToken= +``` +Then install the package. + +```bash +$ npm install @areugoh/client-nodejs@latest +``` + +## Usage + +> **Note:** You can see the proto docs in each package. For example, [here](https://github.com/areugoh/proto/blob/main/proto/greenspace/api/v1/README.md). + +```javascript +import { credentials } from "@grpc/grpc-js"; +import { GreenSpaceClient } from '@areugoh/client-nodejs/proto/greenspace/api/v1/mobile_grpc_pb'; + +const client = new GreenSpaceClient('localhost:50051', credentials.createInsecure()); +// ... +``` + +For more detailed example check [grpc_tools_node_protoc_ts client.js](https://github.com/agreatfool/grpc_tools_node_protoc_ts/blob/v5.0.0/examples/src/grpcjs/client.ts). diff --git a/scripts/nodejs/package-lock.json b/scripts/nodejs/package-lock.json new file mode 100644 index 0000000..25938d6 --- /dev/null +++ b/scripts/nodejs/package-lock.json @@ -0,0 +1,318 @@ +{ + "name": "@areugoh/client-nodejs", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@areugoh/client-nodejs", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@grpc/grpc-js": "^1.9.11", + "@types/google-protobuf": "^3.15.10", + "google-protobuf": "^3.21.2" + } + }, + "node_modules/@grpc/grpc-js": { + "version": "1.9.11", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.11.tgz", + "integrity": "sha512-QDhMfbTROOXUhLHMroow8f3EHiCKUOh6UwxMP5S3EuXMnWMNSVIhatGZRwkpg9OUTYdZPsDUVH3cOAkWhGFUJw==", + "dependencies": { + "@grpc/proto-loader": "^0.7.8", + "@types/node": ">=12.12.47" + }, + "engines": { + "node": "^8.13.0 || >=10.10.0" + } + }, + "node_modules/@grpc/proto-loader": { + "version": "0.7.10", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.10.tgz", + "integrity": "sha512-CAqDfoaQ8ykFd9zqBDn4k6iWT9loLAlc2ETmDFS9JCD70gDcnA4L3AFEo2iV7KyAtAAHFW9ftq1Fz+Vsgq80RQ==", + "dependencies": { + "lodash.camelcase": "^4.3.0", + "long": "^5.0.0", + "protobufjs": "^7.2.4", + "yargs": "^17.7.2" + }, + "bin": { + "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" + }, + "node_modules/@types/google-protobuf": { + "version": "3.15.12", + "resolved": "https://registry.npmjs.org/@types/google-protobuf/-/google-protobuf-3.15.12.tgz", + "integrity": "sha512-40um9QqwHjRS92qnOaDpL7RmDK15NuZYo9HihiJRbYkMQZlWnuH8AdvbMy8/o6lgLmKbDUKa+OALCltHdbOTpQ==" + }, + "node_modules/@types/node": { + "version": "20.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.4.tgz", + "integrity": "sha512-wmyg8HUhcn6ACjsn8oKYjkN/zUzQeNtMy44weTJSM6p4MMzEOuKbA3OjJ267uPCOW7Xex9dyrNTful8XTQYoDA==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/google-protobuf": { + "version": "3.21.2", + "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz", + "integrity": "sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==" + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" + }, + "node_modules/long": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", + "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" + }, + "node_modules/protobufjs": { + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.5.tgz", + "integrity": "sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==", + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/scripts/nodejs/package.json b/scripts/nodejs/package.json new file mode 100644 index 0000000..15b8b6a --- /dev/null +++ b/scripts/nodejs/package.json @@ -0,0 +1,35 @@ +{ + "name": "@areugoh/client-nodejs", + "version": "0.0.0", + "description": "nodejs client all protobuf files defined in github.com/areugoh/proto", + "main": " ", + "publishConfig": { + "registry": "https://npm.pkg.github.com/areugoh" + }, + "files": [ + "proto", + "google", + "validate", + "package.json", + "README.md", + "CHANGELOG.md" + ], + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/areugoh/client-nodejs.git" + }, + "author": "areugoh", + "license": "ISC", + "bugs": { + "url": "https://github.com/areugoh/client-nodejs/issues" + }, + "homepage": "https://github.com/areugoh/client-nodejs#readme", + "dependencies": { + "@grpc/grpc-js": "^1.9.11", + "@types/google-protobuf": "^3.15.10", + "google-protobuf": "^3.21.2" + } +} diff --git a/scripts/typescript/examples/client.ts b/scripts/typescript/examples/client.ts index ae3f6e6..babe6f4 100644 --- a/scripts/typescript/examples/client.ts +++ b/scripts/typescript/examples/client.ts @@ -1,5 +1,5 @@ import { credentials } from '@grpc/grpc-js'; -import { GreenSpaceClient } from './proto/typescript/greenspace/api/v1/mobile_grpc_pb'; +import GreenSpaceClient from './proto/typescript/greenspace/api/v1/mobile_grpc_pb.js'; const client = new GreenSpaceClient('localhost:50051', credentials.createInsecure()); diff --git a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.d.ts b/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.d.ts deleted file mode 100644 index 313e9c9..0000000 --- a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -// package: hoguera.platform.greenspace.api.v1 -// file: greenspace/api/v1/mobile.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as grpc from "@grpc/grpc-js"; -import * as greenspace_api_v1_mobile_pb from "../../../greenspace/api/v1/mobile_pb"; -import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; - -interface IGreenSpaceService extends grpc.ServiceDefinition { - getAnimals: IGreenSpaceService_IGetAnimals; - getCoast: IGreenSpaceService_IGetCoast; - getLocation: IGreenSpaceService_IGetLocation; - getV1: IGreenSpaceService_IGetV1; -} - -interface IGreenSpaceService_IGetAnimals extends grpc.MethodDefinition { - path: "/hoguera.platform.greenspace.api.v1.GreenSpace/GetAnimals"; - requestStream: false; - responseStream: true; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IGreenSpaceService_IGetCoast extends grpc.MethodDefinition { - path: "/hoguera.platform.greenspace.api.v1.GreenSpace/GetCoast"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IGreenSpaceService_IGetLocation extends grpc.MethodDefinition { - path: "/hoguera.platform.greenspace.api.v1.GreenSpace/GetLocation"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IGreenSpaceService_IGetV1 extends grpc.MethodDefinition { - path: "/hoguera.platform.greenspace.api.v1.GreenSpace/GetV1"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -export const GreenSpaceService: IGreenSpaceService; - -export interface IGreenSpaceServer extends grpc.UntypedServiceImplementation { - getAnimals: grpc.handleServerStreamingCall; - getCoast: grpc.handleUnaryCall; - getLocation: grpc.handleUnaryCall; - getV1: grpc.handleUnaryCall; -} - -export interface IGreenSpaceClient { - getAnimals(request: greenspace_api_v1_mobile_pb.AnimalsRequest, options?: Partial): grpc.ClientReadableStream; - getAnimals(request: greenspace_api_v1_mobile_pb.AnimalsRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - getV1(request: google_protobuf_empty_pb.Empty, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; - getV1(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; - getV1(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; -} - -export class GreenSpaceClient extends grpc.Client implements IGreenSpaceClient { - constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); - public getAnimals(request: greenspace_api_v1_mobile_pb.AnimalsRequest, options?: Partial): grpc.ClientReadableStream; - public getAnimals(request: greenspace_api_v1_mobile_pb.AnimalsRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - public getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - public getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - public getCoast(request: greenspace_api_v1_mobile_pb.CoastRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.CoastResponse) => void): grpc.ClientUnaryCall; - public getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - public getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - public getLocation(request: greenspace_api_v1_mobile_pb.LocationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.LocationResponse) => void): grpc.ClientUnaryCall; - public getV1(request: google_protobuf_empty_pb.Empty, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; - public getV1(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; - public getV1(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: greenspace_api_v1_mobile_pb.V1Response) => void): grpc.ClientUnaryCall; -} diff --git a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.js b/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.js deleted file mode 100644 index bc9f1de..0000000 --- a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_grpc_pb.js +++ /dev/null @@ -1,150 +0,0 @@ -// GENERATED CODE -- DO NOT EDIT! - -'use strict'; -var grpc = require('@grpc/grpc-js'); -var greenspace_api_v1_mobile_pb = require('../../../greenspace/api/v1/mobile_pb.js'); -var google_api_annotations_pb = require('../../../google/api/annotations_pb.js'); -var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); - -function serialize_google_protobuf_Empty(arg) { - if (!(arg instanceof google_protobuf_empty_pb.Empty)) { - throw new Error('Expected argument of type google.protobuf.Empty'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_google_protobuf_Empty(buffer_arg) { - return google_protobuf_empty_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_Animal(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.Animal)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.Animal'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_Animal(buffer_arg) { - return greenspace_api_v1_mobile_pb.Animal.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_AnimalsRequest(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.AnimalsRequest)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.AnimalsRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_AnimalsRequest(buffer_arg) { - return greenspace_api_v1_mobile_pb.AnimalsRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_CoastRequest(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.CoastRequest)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.CoastRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_CoastRequest(buffer_arg) { - return greenspace_api_v1_mobile_pb.CoastRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_CoastResponse(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.CoastResponse)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.CoastResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_CoastResponse(buffer_arg) { - return greenspace_api_v1_mobile_pb.CoastResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_LocationRequest(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.LocationRequest)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.LocationRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_LocationRequest(buffer_arg) { - return greenspace_api_v1_mobile_pb.LocationRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_LocationResponse(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.LocationResponse)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.LocationResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_LocationResponse(buffer_arg) { - return greenspace_api_v1_mobile_pb.LocationResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hoguera_platform_greenspace_api_v1_V1Response(arg) { - if (!(arg instanceof greenspace_api_v1_mobile_pb.V1Response)) { - throw new Error('Expected argument of type hoguera.platform.greenspace.api.v1.V1Response'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hoguera_platform_greenspace_api_v1_V1Response(buffer_arg) { - return greenspace_api_v1_mobile_pb.V1Response.deserializeBinary(new Uint8Array(buffer_arg)); -} - - -// GreenSpace is the service that provides all the information for NASA's GreenSpace app. -var GreenSpaceService = exports.GreenSpaceService = { - // GetAnimals returns the animals that are in danger in the coast as a stream. -getAnimals: { - path: '/hoguera.platform.greenspace.api.v1.GreenSpace/GetAnimals', - requestStream: false, - responseStream: true, - requestType: greenspace_api_v1_mobile_pb.AnimalsRequest, - responseType: greenspace_api_v1_mobile_pb.Animal, - requestSerialize: serialize_hoguera_platform_greenspace_api_v1_AnimalsRequest, - requestDeserialize: deserialize_hoguera_platform_greenspace_api_v1_AnimalsRequest, - responseSerialize: serialize_hoguera_platform_greenspace_api_v1_Animal, - responseDeserialize: deserialize_hoguera_platform_greenspace_api_v1_Animal, - }, - // GetCoast returns the nearest coast to the user location. -getCoast: { - path: '/hoguera.platform.greenspace.api.v1.GreenSpace/GetCoast', - requestStream: false, - responseStream: false, - requestType: greenspace_api_v1_mobile_pb.CoastRequest, - responseType: greenspace_api_v1_mobile_pb.CoastResponse, - requestSerialize: serialize_hoguera_platform_greenspace_api_v1_CoastRequest, - requestDeserialize: deserialize_hoguera_platform_greenspace_api_v1_CoastRequest, - responseSerialize: serialize_hoguera_platform_greenspace_api_v1_CoastResponse, - responseDeserialize: deserialize_hoguera_platform_greenspace_api_v1_CoastResponse, - }, - // GetLocation returns the location of the user. -getLocation: { - path: '/hoguera.platform.greenspace.api.v1.GreenSpace/GetLocation', - requestStream: false, - responseStream: false, - requestType: greenspace_api_v1_mobile_pb.LocationRequest, - responseType: greenspace_api_v1_mobile_pb.LocationResponse, - requestSerialize: serialize_hoguera_platform_greenspace_api_v1_LocationRequest, - requestDeserialize: deserialize_hoguera_platform_greenspace_api_v1_LocationRequest, - responseSerialize: serialize_hoguera_platform_greenspace_api_v1_LocationResponse, - responseDeserialize: deserialize_hoguera_platform_greenspace_api_v1_LocationResponse, - }, - // GetV1 is the BFF endpoint. It returns the location of the user, the nearest coast and the animals in danger. -getV1: { - path: '/hoguera.platform.greenspace.api.v1.GreenSpace/GetV1', - requestStream: false, - responseStream: false, - requestType: google_protobuf_empty_pb.Empty, - responseType: greenspace_api_v1_mobile_pb.V1Response, - requestSerialize: serialize_google_protobuf_Empty, - requestDeserialize: deserialize_google_protobuf_Empty, - responseSerialize: serialize_hoguera_platform_greenspace_api_v1_V1Response, - responseDeserialize: deserialize_hoguera_platform_greenspace_api_v1_V1Response, - }, -}; - -exports.GreenSpaceClient = grpc.makeGenericClientConstructor(GreenSpaceService); diff --git a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.d.ts b/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.d.ts deleted file mode 100644 index a4ffc8f..0000000 --- a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -// package: hoguera.platform.greenspace.api.v1 -// file: greenspace/api/v1/mobile.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as jspb from "google-protobuf"; -import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; - -export class LocationResponse extends jspb.Message { - getLongitude(): number; - setLongitude(value: number): LocationResponse; - getLatitude(): number; - setLatitude(value: number): LocationResponse; - getName(): string; - setName(value: string): LocationResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): LocationResponse.AsObject; - static toObject(includeInstance: boolean, msg: LocationResponse): LocationResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: LocationResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): LocationResponse; - static deserializeBinaryFromReader(message: LocationResponse, reader: jspb.BinaryReader): LocationResponse; -} - -export namespace LocationResponse { - export type AsObject = { - longitude: number, - latitude: number, - name: string, - } -} - -export class LocationRequest extends jspb.Message { - getIp(): string; - setIp(value: string): LocationRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): LocationRequest.AsObject; - static toObject(includeInstance: boolean, msg: LocationRequest): LocationRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: LocationRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): LocationRequest; - static deserializeBinaryFromReader(message: LocationRequest, reader: jspb.BinaryReader): LocationRequest; -} - -export namespace LocationRequest { - export type AsObject = { - ip: string, - } -} - -export class CoastRequest extends jspb.Message { - - hasLocation(): boolean; - clearLocation(): void; - getLocation(): LocationResponse | undefined; - setLocation(value?: LocationResponse): CoastRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): CoastRequest.AsObject; - static toObject(includeInstance: boolean, msg: CoastRequest): CoastRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: CoastRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): CoastRequest; - static deserializeBinaryFromReader(message: CoastRequest, reader: jspb.BinaryReader): CoastRequest; -} - -export namespace CoastRequest { - export type AsObject = { - location?: LocationResponse.AsObject, - } -} - -export class CoastResponse extends jspb.Message { - getName(): string; - setName(value: string): CoastResponse; - getCondition(): Condition; - setCondition(value: Condition): CoastResponse; - getTemperature(): number; - setTemperature(value: number): CoastResponse; - getDistance(): number; - setDistance(value: number): CoastResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): CoastResponse.AsObject; - static toObject(includeInstance: boolean, msg: CoastResponse): CoastResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: CoastResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): CoastResponse; - static deserializeBinaryFromReader(message: CoastResponse, reader: jspb.BinaryReader): CoastResponse; -} - -export namespace CoastResponse { - export type AsObject = { - name: string, - condition: Condition, - temperature: number, - distance: number, - } -} - -export class Animal extends jspb.Message { - getName(): string; - setName(value: string): Animal; - getInDanger(): boolean; - setInDanger(value: boolean): Animal; - getDescription(): string; - setDescription(value: string): Animal; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Animal.AsObject; - static toObject(includeInstance: boolean, msg: Animal): Animal.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Animal, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Animal; - static deserializeBinaryFromReader(message: Animal, reader: jspb.BinaryReader): Animal; -} - -export namespace Animal { - export type AsObject = { - name: string, - inDanger: boolean, - description: string, - } -} - -export class AnimalsRequest extends jspb.Message { - - hasLocation(): boolean; - clearLocation(): void; - getLocation(): LocationResponse | undefined; - setLocation(value?: LocationResponse): AnimalsRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): AnimalsRequest.AsObject; - static toObject(includeInstance: boolean, msg: AnimalsRequest): AnimalsRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: AnimalsRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): AnimalsRequest; - static deserializeBinaryFromReader(message: AnimalsRequest, reader: jspb.BinaryReader): AnimalsRequest; -} - -export namespace AnimalsRequest { - export type AsObject = { - location?: LocationResponse.AsObject, - } -} - -export class V1Response extends jspb.Message { - - hasLocation(): boolean; - clearLocation(): void; - getLocation(): LocationResponse | undefined; - setLocation(value?: LocationResponse): V1Response; - - hasNearestAquaticLocation(): boolean; - clearNearestAquaticLocation(): void; - getNearestAquaticLocation(): CoastResponse | undefined; - setNearestAquaticLocation(value?: CoastResponse): V1Response; - clearAnimalsList(): void; - getAnimalsList(): Array; - setAnimalsList(value: Array): V1Response; - addAnimals(value?: Animal, index?: number): Animal; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): V1Response.AsObject; - static toObject(includeInstance: boolean, msg: V1Response): V1Response.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: V1Response, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): V1Response; - static deserializeBinaryFromReader(message: V1Response, reader: jspb.BinaryReader): V1Response; -} - -export namespace V1Response { - export type AsObject = { - location?: LocationResponse.AsObject, - nearestAquaticLocation?: CoastResponse.AsObject, - animalsList: Array, - } -} - -export enum Condition { - GOOD = 0, - MODERATE = 1, - CONTAMINATED = 2, - UNKNOWN = 3, - RADIATION = 4, - DANGER = 5, - PROTECTED = 6, -} diff --git a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.js b/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.js deleted file mode 100644 index 574e30f..0000000 --- a/scripts/typescript/examples/proto/typescript/greenspace/api/v1/mobile_pb.js +++ /dev/null @@ -1,1490 +0,0 @@ -// source: greenspace/api/v1/mobile.proto -/** - * @fileoverview - * @enhanceable - * @suppress {missingRequire} reports error on implicit type usages. - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -// GENERATED CODE -- DO NOT EDIT! -/* eslint-disable */ -// @ts-nocheck - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = (function() { - if (this) { return this; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } - if (typeof self !== 'undefined') { return self; } - return Function('return this')(); -}.call(null)); - -var google_api_annotations_pb = require('../../../google/api/annotations_pb.js'); -goog.object.extend(proto, google_api_annotations_pb); -var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); -goog.object.extend(proto, google_protobuf_empty_pb); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.Animal', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.AnimalsRequest', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.CoastRequest', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.CoastResponse', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.Condition', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.LocationRequest', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.LocationResponse', null, global); -goog.exportSymbol('proto.hoguera.platform.greenspace.api.v1.V1Response', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.LocationResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.LocationResponse.displayName = 'proto.hoguera.platform.greenspace.api.v1.LocationResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.LocationRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.LocationRequest.displayName = 'proto.hoguera.platform.greenspace.api.v1.LocationRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.CoastRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.CoastRequest.displayName = 'proto.hoguera.platform.greenspace.api.v1.CoastRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.CoastResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.CoastResponse.displayName = 'proto.hoguera.platform.greenspace.api.v1.CoastResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.Animal = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.Animal, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.Animal.displayName = 'proto.hoguera.platform.greenspace.api.v1.Animal'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.AnimalsRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.displayName = 'proto.hoguera.platform.greenspace.api.v1.AnimalsRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hoguera.platform.greenspace.api.v1.V1Response = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hoguera.platform.greenspace.api.v1.V1Response.repeatedFields_, null); -}; -goog.inherits(proto.hoguera.platform.greenspace.api.v1.V1Response, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hoguera.platform.greenspace.api.v1.V1Response.displayName = 'proto.hoguera.platform.greenspace.api.v1.V1Response'; -} - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.LocationResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.toObject = function(includeInstance, msg) { - var f, obj = { - longitude: jspb.Message.getFloatingPointFieldWithDefault(msg, 1, 0.0), - latitude: jspb.Message.getFloatingPointFieldWithDefault(msg, 2, 0.0), - name: jspb.Message.getFieldWithDefault(msg, 3, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.LocationResponse; - return proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readFloat()); - msg.setLongitude(value); - break; - case 2: - var value = /** @type {number} */ (reader.readFloat()); - msg.setLatitude(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setName(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.LocationResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLongitude(); - if (f !== 0.0) { - writer.writeFloat( - 1, - f - ); - } - f = message.getLatitude(); - if (f !== 0.0) { - writer.writeFloat( - 2, - f - ); - } - f = message.getName(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } -}; - - -/** - * optional float longitude = 1; - * @return {number} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.getLongitude = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 1, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.setLongitude = function(value) { - return jspb.Message.setProto3FloatField(this, 1, value); -}; - - -/** - * optional float latitude = 2; - * @return {number} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.getLatitude = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.setLatitude = function(value) { - return jspb.Message.setProto3FloatField(this, 2, value); -}; - - -/** - * optional string name = 3; - * @return {string} - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.LocationResponse.prototype.setName = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.LocationRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.toObject = function(includeInstance, msg) { - var f, obj = { - ip: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.LocationRequest; - return proto.hoguera.platform.greenspace.api.v1.LocationRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setIp(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.LocationRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getIp(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string ip = 1; - * @return {string} - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.prototype.getIp = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hoguera.platform.greenspace.api.v1.LocationRequest} returns this - */ -proto.hoguera.platform.greenspace.api.v1.LocationRequest.prototype.setIp = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.CoastRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.toObject = function(includeInstance, msg) { - var f, obj = { - location: (f = msg.getLocation()) && proto.hoguera.platform.greenspace.api.v1.LocationResponse.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.CoastRequest; - return proto.hoguera.platform.greenspace.api.v1.CoastRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.hoguera.platform.greenspace.api.v1.LocationResponse; - reader.readMessage(value,proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinaryFromReader); - msg.setLocation(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.CoastRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLocation(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.hoguera.platform.greenspace.api.v1.LocationResponse.serializeBinaryToWriter - ); - } -}; - - -/** - * optional LocationResponse location = 1; - * @return {?proto.hoguera.platform.greenspace.api.v1.LocationResponse} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.getLocation = function() { - return /** @type{?proto.hoguera.platform.greenspace.api.v1.LocationResponse} */ ( - jspb.Message.getWrapperField(this, proto.hoguera.platform.greenspace.api.v1.LocationResponse, 1)); -}; - - -/** - * @param {?proto.hoguera.platform.greenspace.api.v1.LocationResponse|undefined} value - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} returns this -*/ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.setLocation = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastRequest} returns this - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.clearLocation = function() { - return this.setLocation(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hoguera.platform.greenspace.api.v1.CoastRequest.prototype.hasLocation = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.CoastResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.toObject = function(includeInstance, msg) { - var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), - condition: jspb.Message.getFieldWithDefault(msg, 2, 0), - temperature: jspb.Message.getFloatingPointFieldWithDefault(msg, 3, 0.0), - distance: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 0.0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.CoastResponse; - return proto.hoguera.platform.greenspace.api.v1.CoastResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setName(value); - break; - case 2: - var value = /** @type {!proto.hoguera.platform.greenspace.api.v1.Condition} */ (reader.readEnum()); - msg.setCondition(value); - break; - case 3: - var value = /** @type {number} */ (reader.readFloat()); - msg.setTemperature(value); - break; - case 4: - var value = /** @type {number} */ (reader.readDouble()); - msg.setDistance(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.CoastResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getName(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getCondition(); - if (f !== 0.0) { - writer.writeEnum( - 2, - f - ); - } - f = message.getTemperature(); - if (f !== 0.0) { - writer.writeFloat( - 3, - f - ); - } - f = message.getDistance(); - if (f !== 0.0) { - writer.writeDouble( - 4, - f - ); - } -}; - - -/** - * optional string name = 1; - * @return {string} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.setName = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional Condition condition = 2; - * @return {!proto.hoguera.platform.greenspace.api.v1.Condition} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.getCondition = function() { - return /** @type {!proto.hoguera.platform.greenspace.api.v1.Condition} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {!proto.hoguera.platform.greenspace.api.v1.Condition} value - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.setCondition = function(value) { - return jspb.Message.setProto3EnumField(this, 2, value); -}; - - -/** - * optional float temperature = 3; - * @return {number} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.getTemperature = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 3, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.setTemperature = function(value) { - return jspb.Message.setProto3FloatField(this, 3, value); -}; - - -/** - * optional double distance = 4; - * @return {number} - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.getDistance = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.hoguera.platform.greenspace.api.v1.CoastResponse} returns this - */ -proto.hoguera.platform.greenspace.api.v1.CoastResponse.prototype.setDistance = function(value) { - return jspb.Message.setProto3FloatField(this, 4, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.Animal.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.Animal} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.Animal.toObject = function(includeInstance, msg) { - var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), - inDanger: jspb.Message.getBooleanFieldWithDefault(msg, 2, false), - description: jspb.Message.getFieldWithDefault(msg, 3, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.Animal; - return proto.hoguera.platform.greenspace.api.v1.Animal.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.Animal} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setName(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setInDanger(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setDescription(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.Animal.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.Animal} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.Animal.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getName(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getInDanger(); - if (f) { - writer.writeBool( - 2, - f - ); - } - f = message.getDescription(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } -}; - - -/** - * optional string name = 1; - * @return {string} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} returns this - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.setName = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional bool in_danger = 2; - * @return {boolean} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.getInDanger = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} returns this - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.setInDanger = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional string description = 3; - * @return {string} - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.getDescription = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} returns this - */ -proto.hoguera.platform.greenspace.api.v1.Animal.prototype.setDescription = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.toObject = function(includeInstance, msg) { - var f, obj = { - location: (f = msg.getLocation()) && proto.hoguera.platform.greenspace.api.v1.LocationResponse.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.AnimalsRequest; - return proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.hoguera.platform.greenspace.api.v1.LocationResponse; - reader.readMessage(value,proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinaryFromReader); - msg.setLocation(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLocation(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.hoguera.platform.greenspace.api.v1.LocationResponse.serializeBinaryToWriter - ); - } -}; - - -/** - * optional LocationResponse location = 1; - * @return {?proto.hoguera.platform.greenspace.api.v1.LocationResponse} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.getLocation = function() { - return /** @type{?proto.hoguera.platform.greenspace.api.v1.LocationResponse} */ ( - jspb.Message.getWrapperField(this, proto.hoguera.platform.greenspace.api.v1.LocationResponse, 1)); -}; - - -/** - * @param {?proto.hoguera.platform.greenspace.api.v1.LocationResponse|undefined} value - * @return {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} returns this -*/ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.setLocation = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hoguera.platform.greenspace.api.v1.AnimalsRequest} returns this - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.clearLocation = function() { - return this.setLocation(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hoguera.platform.greenspace.api.v1.AnimalsRequest.prototype.hasLocation = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.repeatedFields_ = [3]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.toObject = function(opt_includeInstance) { - return proto.hoguera.platform.greenspace.api.v1.V1Response.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hoguera.platform.greenspace.api.v1.V1Response} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.toObject = function(includeInstance, msg) { - var f, obj = { - location: (f = msg.getLocation()) && proto.hoguera.platform.greenspace.api.v1.LocationResponse.toObject(includeInstance, f), - nearestAquaticLocation: (f = msg.getNearestAquaticLocation()) && proto.hoguera.platform.greenspace.api.v1.CoastResponse.toObject(includeInstance, f), - animalsList: jspb.Message.toObjectList(msg.getAnimalsList(), - proto.hoguera.platform.greenspace.api.v1.Animal.toObject, includeInstance) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hoguera.platform.greenspace.api.v1.V1Response; - return proto.hoguera.platform.greenspace.api.v1.V1Response.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hoguera.platform.greenspace.api.v1.V1Response} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.hoguera.platform.greenspace.api.v1.LocationResponse; - reader.readMessage(value,proto.hoguera.platform.greenspace.api.v1.LocationResponse.deserializeBinaryFromReader); - msg.setLocation(value); - break; - case 2: - var value = new proto.hoguera.platform.greenspace.api.v1.CoastResponse; - reader.readMessage(value,proto.hoguera.platform.greenspace.api.v1.CoastResponse.deserializeBinaryFromReader); - msg.setNearestAquaticLocation(value); - break; - case 3: - var value = new proto.hoguera.platform.greenspace.api.v1.Animal; - reader.readMessage(value,proto.hoguera.platform.greenspace.api.v1.Animal.deserializeBinaryFromReader); - msg.addAnimals(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hoguera.platform.greenspace.api.v1.V1Response.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hoguera.platform.greenspace.api.v1.V1Response} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLocation(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.hoguera.platform.greenspace.api.v1.LocationResponse.serializeBinaryToWriter - ); - } - f = message.getNearestAquaticLocation(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.hoguera.platform.greenspace.api.v1.CoastResponse.serializeBinaryToWriter - ); - } - f = message.getAnimalsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 3, - f, - proto.hoguera.platform.greenspace.api.v1.Animal.serializeBinaryToWriter - ); - } -}; - - -/** - * optional LocationResponse location = 1; - * @return {?proto.hoguera.platform.greenspace.api.v1.LocationResponse} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.getLocation = function() { - return /** @type{?proto.hoguera.platform.greenspace.api.v1.LocationResponse} */ ( - jspb.Message.getWrapperField(this, proto.hoguera.platform.greenspace.api.v1.LocationResponse, 1)); -}; - - -/** - * @param {?proto.hoguera.platform.greenspace.api.v1.LocationResponse|undefined} value - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this -*/ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.setLocation = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.clearLocation = function() { - return this.setLocation(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.hasLocation = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional CoastResponse nearest_aquatic_location = 2; - * @return {?proto.hoguera.platform.greenspace.api.v1.CoastResponse} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.getNearestAquaticLocation = function() { - return /** @type{?proto.hoguera.platform.greenspace.api.v1.CoastResponse} */ ( - jspb.Message.getWrapperField(this, proto.hoguera.platform.greenspace.api.v1.CoastResponse, 2)); -}; - - -/** - * @param {?proto.hoguera.platform.greenspace.api.v1.CoastResponse|undefined} value - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this -*/ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.setNearestAquaticLocation = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.clearNearestAquaticLocation = function() { - return this.setNearestAquaticLocation(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.hasNearestAquaticLocation = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * repeated Animal animals = 3; - * @return {!Array} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.getAnimalsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hoguera.platform.greenspace.api.v1.Animal, 3)); -}; - - -/** - * @param {!Array} value - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this -*/ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.setAnimalsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 3, value); -}; - - -/** - * @param {!proto.hoguera.platform.greenspace.api.v1.Animal=} opt_value - * @param {number=} opt_index - * @return {!proto.hoguera.platform.greenspace.api.v1.Animal} - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.addAnimals = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.hoguera.platform.greenspace.api.v1.Animal, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.hoguera.platform.greenspace.api.v1.V1Response} returns this - */ -proto.hoguera.platform.greenspace.api.v1.V1Response.prototype.clearAnimalsList = function() { - return this.setAnimalsList([]); -}; - - -/** - * @enum {number} - */ -proto.hoguera.platform.greenspace.api.v1.Condition = { - GOOD: 0, - MODERATE: 1, - CONTAMINATED: 2, - UNKNOWN: 3, - RADIATION: 4, - DANGER: 5, - PROTECTED: 6 -}; - -goog.object.extend(exports, proto.hoguera.platform.greenspace.api.v1); diff --git a/scripts/typescript/examples/tsconfig.json b/scripts/typescript/examples/tsconfig.json new file mode 100644 index 0000000..564eaa1 --- /dev/null +++ b/scripts/typescript/examples/tsconfig.json @@ -0,0 +1,19 @@ +{ + "ts-node": { "esm": true }, + "compilerOptions": { + "lib": [ + "es6" + ], + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "outDir": "dist", + "resolveJsonModule": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "sourceMap": true + }, + "include": ["**/*.ts"], + "exclude": ["node_modules", "**/*.spec.ts"] +}