wechaty / grpc

gRPC Service & Protocol Buffers for Wechaty Puppet
https://wechaty.github.io/grpc/
Apache License 2.0
26 stars 22 forks source link

Auto-generate TypeScript data structure from wechaty/grpc #171

Open suntong opened 2 years ago

suntong commented 2 years ago

🚀 Feature

From #65:

When Multi-lang Wechaty is working with the GRPC Service, we should convert all values from the GRPC service to the local value, so that we can make sure everything is right.

So what's the status of auto-generating ts-wechaty data definitions from wechaty/grpc?

It seems that we have Go, Java, PHP, but I don't see other languages like TS.

I don't know JS/TS much, but

gRPC on Node.js with Buf and TypeScript
https://slavovojacek.medium.com/?p=5aad61bab03b

I don't know JS/TS much, but hope ts-wechaty DS auto-generation can be done soon, so that we can avoid problems like #65, and fix issues like https://github.com/padlocal/wechaty-puppet-padlocal/issues/76 and https://github.com/padlocal/wechaty-puppet-padlocal/issues/68

thanks

huan commented 2 years ago

We will generate the JS/TS by running npm run generate. Please refer to the below code

https://github.com/wechaty/grpc/blob/7d881ddac3d93442669b47c02a7962c553c863c2/package.json#L29

And you can learn how to use the wechaty-grpc npm package (which is the generated gRPC code) by reading the wechaty-puppet-service module, for example, from here

suntong commented 2 years ago

We will generate the JS/TS by running npm run generate.

Thx. Will such generated code be published somewhere for public's general consumption?

huan commented 2 years ago

Thx. Will such generated code be published somewhere for public's general consumption?

Yes. They are published as wechaty-grpc NPM module

suntong commented 2 years ago

Oh, sorry, I meant the generated TS data structure from wechaty/go-grpc.

So I took a look at the scripts/generate-stub.sh, and it seems the output (if it is TS data structure) is generated under out folder.

Is such generated out folder available anywhere pls?

huan commented 2 years ago

Yes, we have published the go-grpc at https://github.com/wechaty/go-grpc

Please also refer to the action script:

https://github.com/wechaty/grpc/blob/7d881ddac3d93442669b47c02a7962c553c863c2/.github/workflows/go.yml#L35-L44

suntong commented 2 years ago

sorry, I meant the generated TypeScript data structure, not ~Go~, is such generated TypeScript data structure code available anywhere pls?

I took a look at the content of wechaty-grpc npm module, and see:

csharp
dist
docs
examples
go
java
openapi
php
proto
python

I.e., I see almost all languages, except TypeScript / JavaScript.

suntong commented 2 years ago

And, under wechaty-grpc, I run:

$ npm run generate

> wechaty-grpc@0.20.19 generate
> bash -x scripts/generate-stub.sh

+ set -e
+ PROTO_DIR=./proto/
+ THIRD_PARTY_DIR=./third-party/
+ OUT_DIR=./generated
+ '[' -d ./generated ']'
+ mkdir -p ./generated
++ find ./proto/ ./third-party/ -type f -name '*.proto'
find: â./third-party/â: No such file or directory
+ PROTO_FILE_LIST='./proto/wechaty/puppet.proto
./proto/wechaty/puppet/file_box.proto
./proto/wechaty/puppet/base.proto
./proto/wechaty/puppet/message.proto
./proto/wechaty/puppet/room_invitation.proto
./proto/wechaty/puppet/contact.proto
./proto/wechaty/puppet/friendship.proto
./proto/wechaty/puppet/tag.proto
./proto/wechaty/puppet/room.proto
./proto/wechaty/puppet/event.proto
./proto/wechaty/puppet/room_member.proto'

$ find !$
find ./generated
./generated

I.e., I see nothing get generated.

huan commented 2 years ago

Your local repo is outdated:

wechaty-grpc@0.20.19 generate

┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:45] tty:[11] jobs:[0]
└ (main) $ jq .version package.json 
"0.33.6"

Run git pull to update your local repo to the latest version (0.20.19 -> 0.33.6):

┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:29] tty:[11] jobs:[0]
└ (main) $ npm run generate

> wechaty-grpc@0.33.6 generate
> bash -x scripts/generate-stub.sh

+ set -e
+ shopt -s globstar
+++ dirname scripts/generate-stub.sh
++ cd scripts
++ pwd -P
+ WORK_DIR=/home/huan/git/wechaty/grpc/scripts
++ cd /home/huan/git/wechaty/grpc/scripts/../
++ pwd -P
+ REPO_DIR=/home/huan/git/wechaty/grpc
+ OUT_DIR=/home/huan/git/wechaty/grpc/out/
+ '[' -d /home/huan/git/wechaty/grpc/out/ ']'
+ PROTOC_CMD='protoc   -I /home/huan/git/wechaty/grpc/third-party/   -I /home/huan/git/wechaty/grpc/proto/   /home/huan/git/wechaty/grpc/third-party/**/*.proto   /home/huan/git/wechaty/grpc/proto/**/*.proto '
+ main
+ gen_js_pb
+ protoc -I /home/huan/git/wechaty/grpc/third-party/ -I /home/huan/git/wechaty/grpc/proto/ /home/huan/git/wechaty/grpc/third-party/google/api/annotations.proto /home/huan/git/wechaty/grpc/third-party/google/api/health_check/v1/health_check.proto /home/huan/git/wechaty/grpc/third-party/google/api/http.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/annotations.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/openapiv2.proto /home/huan/git/wechaty/grpc/proto/wechaty/deprecated/file-box.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/base.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/contact.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/download-upload.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/event.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/friendship.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/image.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/location.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/message.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/mini-program.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/referrer.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-invitation.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-member.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/tag.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/url-link.proto --js_out=import_style=commonjs,binary:/home/huan/git/wechaty/grpc/out/
+ gen_js_stub
+ protoc -I /home/huan/git/wechaty/grpc/third-party/ -I /home/huan/git/wechaty/grpc/proto/ /home/huan/git/wechaty/grpc/third-party/google/api/annotations.proto /home/huan/git/wechaty/grpc/third-party/google/api/health_check/v1/health_check.proto /home/huan/git/wechaty/grpc/third-party/google/api/http.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/annotations.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/openapiv2.proto /home/huan/git/wechaty/grpc/proto/wechaty/deprecated/file-box.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/base.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/contact.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/download-upload.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/event.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/friendship.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/image.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/location.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/message.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/mini-program.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/referrer.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-invitation.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-member.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/tag.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/url-link.proto --plugin=protoc-gen-grpc=node_modules/.bin/grpc_tools_node_protoc_plugin --grpc_out=grpc_js:/home/huan/git/wechaty/grpc/out/
+ gen_ts_typing
+ protoc -I /home/huan/git/wechaty/grpc/third-party/ -I /home/huan/git/wechaty/grpc/proto/ /home/huan/git/wechaty/grpc/third-party/google/api/annotations.proto /home/huan/git/wechaty/grpc/third-party/google/api/health_check/v1/health_check.proto /home/huan/git/wechaty/grpc/third-party/google/api/http.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/annotations.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/openapiv2.proto /home/huan/git/wechaty/grpc/proto/wechaty/deprecated/file-box.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/base.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/contact.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/download-upload.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/event.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/friendship.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/image.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/location.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/message.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/mini-program.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/referrer.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-invitation.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-member.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/tag.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/url-link.proto --plugin=protoc-gen-grpc=node_modules/grpc_tools_node_protoc_ts/bin/protoc-gen-ts --grpc_out=grpc_js:/home/huan/git/wechaty/grpc/out/
+ gen_cjs_package_json
+ echo '{"type": "commonjs"}'
+ gen_web_grpc
+ protoc -I /home/huan/git/wechaty/grpc/third-party/ -I /home/huan/git/wechaty/grpc/proto/ /home/huan/git/wechaty/grpc/third-party/google/api/annotations.proto /home/huan/git/wechaty/grpc/third-party/google/api/health_check/v1/health_check.proto /home/huan/git/wechaty/grpc/third-party/google/api/http.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/annotations.proto /home/huan/git/wechaty/grpc/third-party/protoc-gen-openapiv2/options/openapiv2.proto /home/huan/git/wechaty/grpc/proto/wechaty/deprecated/file-box.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/base.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/contact.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/download-upload.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/event.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/friendship.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/image.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/location.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/message.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/mini-program.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/referrer.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-invitation.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room-member.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/room.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/tag.proto /home/huan/git/wechaty/grpc/proto/wechaty/puppet/url-link.proto --plugin=protoc-gen-ts=node_modules/ts-protoc-gen/bin/protoc-gen-ts --ts_out=service=grpc-web:/home/huan/git/wechaty/grpc/out/
+ gen_openapi
+ pushd openapi
~/git/wechaty/grpc/openapi ~/git/wechaty/grpc
+ make generate
./generate.sh
Swagger version synced with gRPC version 0.33.6 for /home/huan/git/wechaty/grpc/out//wechaty/puppet.swagger.json
+ popd
~/git/wechaty/grpc
┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:36] tty:[11] jobs:[0]
└ (main) $ ls gen
ls: cannot access 'gen': No such file or directory
┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:41] tty:[11] jobs:[0]
└ (main) $ ls out/
google  package.json  protoc-gen-openapiv2  wechaty
┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:42] tty:[11] jobs:[0]
└ (main) $ ls out/wechaty/
deprecated  puppet_grpc_pb.d.ts  puppet.openapi.yaml  puppet_pb.js            puppet_pb_service.js
puppet      puppet_grpc_pb.js    puppet_pb.d.ts       puppet_pb_service.d.ts  puppet.swagger.json
┌ huan@dev.zixia.net:~/git/wechaty/grpc [13:35:45] tty:[11] jobs:[0]
└ (main) $ jq .version package.json 
"0.33.6"

They reside in the out/wechaty/ folder.

suntong commented 2 years ago

I got that wechaty-grpc with

npm i wechaty-grpc

The above code was run under my node_modules/wechaty-grpc/ folder.

Sorry I'm not very clear how to properly get the result of yours above.

Can you try to run npm i wechaty-grpc under the node_modules/wechaty-grpc/ folder and see if you get my above result pls?

suntong commented 2 years ago

Oh, Run git pull ok. I'll try tomorrow... good night.

suntong commented 2 years ago
$ npm run generate

> wechaty-grpc@0.33.6 generate
> bash -x scripts/generate-stub.sh
. . .
+ protoc -I /home/suntong/git/grpc/third-party/ -I /home/suntong/git/grpc/proto/ '/home/suntong/git/grpc/third-party/**/*.proto' /home/suntong/git/grpc/proto/wechaty/deprecated/file-box.proto /home/suntong/git/grpc/proto/wechaty/puppet.proto /home/suntong/git/grpc/proto/wechaty/puppet/base.proto /home/suntong/git/grpc/proto/wechaty/puppet/contact.proto /home/suntong/git/grpc/proto/wechaty/puppet/download-upload.proto /home/suntong/git/grpc/proto/wechaty/puppet/event.proto /home/suntong/git/grpc/proto/wechaty/puppet/friendship.proto /home/suntong/git/grpc/proto/wechaty/puppet/image.proto /home/suntong/git/grpc/proto/wechaty/puppet/location.proto /home/suntong/git/grpc/proto/wechaty/puppet/message.proto /home/suntong/git/grpc/proto/wechaty/puppet/mini-program.proto /home/suntong/git/grpc/proto/wechaty/puppet/referrer.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-invitation.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-member.proto /home/suntong/git/grpc/proto/wechaty/puppet/room.proto /home/suntong/git/grpc/proto/wechaty/puppet/tag.proto /home/suntong/git/grpc/proto/wechaty/puppet/url-link.proto --js_out=import_style=commonjs,binary:/home/suntong/git/grpc/out/
scripts/generate-stub.sh: line 30: protoc: command not found

$ ./scripts/install-protoc.sh
[sudo] password for suntong: 

$ id
uid=1006(suntong) gid=1006(suntong) groups=1006(suntong),116(docker),1001(wechaty)

I.e., I need sudo access in dev.chatie.io in order to try it.

Is it possible that I have sudo access? thx

Or, somebody install protoc globally so that everyone can use pls.

huan commented 2 years ago

Protoc has been installed on our community server:

root@wechaty-contributors:/home/suntong/git/grpc/scripts# sudo apt install -y protobuf-compiler
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-azure-cloud-tools-5.4.0-1036 linux-azure-headers-5.4.0-1036 linux-azure-tools-5.4.0-1036 linux-cloud-tools-5.4.0-1036-azure linux-headers-5.4.0-1036-azure linux-image-5.4.0-1036-azure
  linux-modules-5.4.0-1036-azure linux-modules-extra-5.4.0-1036-azure linux-tools-5.4.0-1036-azure
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libprotobuf-dev libprotobuf-lite17 libprotoc17
The following NEW packages will be installed:
  libprotobuf-dev libprotobuf-lite17 libprotoc17 protobuf-compiler
0 upgraded, 4 newly installed, 0 to remove and 120 not upgraded.
Need to get 1,960 kB of archives.
After this operation, 13.8 MB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 libprotobuf-lite17 amd64 3.6.1.3-2ubuntu5 [132 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 libprotoc17 amd64 3.6.1.3-2ubuntu5 [646 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 libprotobuf-dev amd64 3.6.1.3-2ubuntu5 [1,155 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal/universe amd64 protobuf-compiler amd64 3.6.1.3-2ubuntu5 [27.6 kB]
Fetched 1,960 kB in 0s (26.9 MB/s)           
Selecting previously unselected package libprotobuf-lite17:amd64.
(Reading database ... 164255 files and directories currently installed.)
Preparing to unpack .../libprotobuf-lite17_3.6.1.3-2ubuntu5_amd64.deb ...
Unpacking libprotobuf-lite17:amd64 (3.6.1.3-2ubuntu5) ...
Selecting previously unselected package libprotoc17:amd64.
Preparing to unpack .../libprotoc17_3.6.1.3-2ubuntu5_amd64.deb ...
Unpacking libprotoc17:amd64 (3.6.1.3-2ubuntu5) ...
Selecting previously unselected package libprotobuf-dev:amd64.
Preparing to unpack .../libprotobuf-dev_3.6.1.3-2ubuntu5_amd64.deb ...
Unpacking libprotobuf-dev:amd64 (3.6.1.3-2ubuntu5) ...
Selecting previously unselected package protobuf-compiler.
Preparing to unpack .../protobuf-compiler_3.6.1.3-2ubuntu5_amd64.deb ...
Unpacking protobuf-compiler (3.6.1.3-2ubuntu5) ...
Setting up libprotoc17:amd64 (3.6.1.3-2ubuntu5) ...
Setting up protobuf-compiler (3.6.1.3-2ubuntu5) ...
Setting up libprotobuf-lite17:amd64 (3.6.1.3-2ubuntu5) ...
Setting up libprotobuf-dev:amd64 (3.6.1.3-2ubuntu5) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@wechaty-contributors:/home/suntong/git/grpc/scripts# protoc --version
libprotoc 3.6.1
suntong commented 2 years ago

thx @huan !

Now npm run generate is failing with:

~/git/grpc$ npm run generate

> wechaty-grpc@0.33.6 generate
> bash -x scripts/generate-stub.sh

+ set -e
+ shopt -s globstar
+++ dirname scripts/generate-stub.sh
++ cd scripts
++ pwd -P
+ WORK_DIR=/home/suntong/git/grpc/scripts
++ cd /home/suntong/git/grpc/scripts/../
++ pwd -P
+ REPO_DIR=/home/suntong/git/grpc
+ OUT_DIR=/home/suntong/git/grpc/out/
+ '[' -d /home/suntong/git/grpc/out/ ']'
+ PROTOC_CMD='protoc   -I /home/suntong/git/grpc/third-party/   -I /home/suntong/git/grpc/proto/   /home/suntong/git/grpc/third-party/**/*.proto   /home/suntong/git/grpc/proto/**/*.proto '
+ main
+ gen_js_pb
+ protoc -I /home/suntong/git/grpc/third-party/ -I /home/suntong/git/grpc/proto/ '/home/suntong/git/grpc/third-party/**/*.proto' /home/suntong/git/grpc/proto/wechaty/deprecated/file-box.proto /home/suntong/git/grpc/proto/wechaty/puppet.proto /home/suntong/git/grpc/proto/wechaty/puppet/base.proto /home/suntong/git/grpc/proto/wechaty/puppet/contact.proto /home/suntong/git/grpc/proto/wechaty/puppet/download-upload.proto /home/suntong/git/grpc/proto/wechaty/puppet/event.proto /home/suntong/git/grpc/proto/wechaty/puppet/friendship.proto /home/suntong/git/grpc/proto/wechaty/puppet/image.proto /home/suntong/git/grpc/proto/wechaty/puppet/location.proto /home/suntong/git/grpc/proto/wechaty/puppet/message.proto /home/suntong/git/grpc/proto/wechaty/puppet/mini-program.proto /home/suntong/git/grpc/proto/wechaty/puppet/referrer.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-invitation.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-member.proto /home/suntong/git/grpc/proto/wechaty/puppet/room.proto /home/suntong/git/grpc/proto/wechaty/puppet/tag.proto /home/suntong/git/grpc/proto/wechaty/puppet/url-link.proto --js_out=import_style=commonjs,binary:/home/suntong/git/grpc/out/
/home/suntong/git/grpc/third-party/: warning: directory does not exist.
/home/suntong/git/grpc/third-party/**/*.proto: No such file or directory
huan commented 2 years ago

You are welcome.

Please refer to our GitHub Action YAML file to learn how to reproduce the generating process

suntong commented 2 years ago

Hmm...

The above apt install -y protobuf-compiler installed 3.6.1 version:

Unpacking protobuf-compiler (3.6.1.3-2ubuntu5) ...
Setting up libprotoc17:amd64 (3.6.1.3-2ubuntu5) ...
Setting up protobuf-compiler (3.6.1.3-2ubuntu5) ...

Yet, why npm run install:protoc, which is a step in https://github.com/wechaty/grpc/blob/main/.github/workflows/node.yml, is requiring 3.17?

$ npm run install:protoc

> wechaty-grpc@0.33.6 install:protoc
> bash -x scripts/install-protoc.sh

+ set -e
+ set -o pipefail
+++ dirname scripts/install-protoc.sh
++ cd scripts
++ pwd -P
+ WORK_DIR=/home/suntong/git/grpc/scripts
++ cd /home/suntong/git/grpc/scripts/../
++ pwd -P
+ REPO_DIR=/home/suntong/git/grpc
+ THIRD_PARTY_DIR=/home/suntong/git/grpc/third-party/
+ main
+ install_protoc
+ command -v protoc
+ echo 'install skipped: protoc exists'
install skipped: protoc exists
+ return
+ check_protoc_version
++ protoc --version
++ cut '-d ' -f 2
+ protocVersion=3.6.1
++ cut -d. -f 1
++ echo 3.6.1
+ majorVer=3
++ echo 3.6.1
++ cut -d. -f 2
+ minorVer=6
+ (( 3 == 3 ))
+ (( 6 >= 17 ))
+ echo 'protoc minor version must >= 17 (the installed version is 3.6.1)'
protoc minor version must >= 17 (the installed version is 3.6.1)
+ exit 1
suntong commented 2 years ago

I then skipped that step and run the next few steps:

$ npm install
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated @hapi/pinpoint@1.0.2: Moved to 'npm install @sideway/pinpoint'
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/formula@1.2.0: Moved to 'npm install @sideway/formula'
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated tslint-config-standard@9.0.0: TSLint is deprecated, please move to ESLint: https://github.com/blakeembrey/tslint-config-standard/issues/61
npm WARN deprecated eslint-plugin-standard@5.0.0: standard 16.0.0 and eslint-config-standard 16.0.0 no longer require the eslint-plugin-standard package. You can remove it from your dependencies with 'npm rm eslint-plugin-standard'. More info here: https://github.com/standard/standard/issues/1316
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/joi@16.1.8: Switch to 'npm install joi'
npm WARN deprecated @types/protobufjs@6.0.0: This is a stub types definition for protobufjs (https://github.com/dcodeIO/ProtoBuf.js). protobufjs provides its own type definitions, so you don't need @types/protobufjs installed!
npm WARN deprecated tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
npm WARN deprecated grpc@1.24.11: This library will not receive further updates other than security fixes. We recommend using @grpc/grpc-js instead.

added 906 packages, and audited 1068 packages in 1m

100 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

./scripts/generate-package-json.sh

./scripts/package-publish-config-tag.sh
NO: 0.33.6 is NOT a production release.
development release: publicConfig.tag set to next.

$ npm run dist

> wechaty-grpc@0.33.6 dist
> npm-run-all clean generate build dist:copy dist:commonjs

> wechaty-grpc@0.33.6 clean
> shx rm -fr dist/* out/*

> wechaty-grpc@0.33.6 generate
> bash -x scripts/generate-stub.sh

+ set -e
+ shopt -s globstar
+++ dirname scripts/generate-stub.sh
++ cd scripts
++ pwd -P
+ WORK_DIR=/home/suntong/git/grpc/scripts
++ cd /home/suntong/git/grpc/scripts/../
++ pwd -P
+ REPO_DIR=/home/suntong/git/grpc
+ OUT_DIR=/home/suntong/git/grpc/out/
+ '[' -d /home/suntong/git/grpc/out/ ']'
+ PROTOC_CMD='protoc   -I /home/suntong/git/grpc/third-party/   -I /home/suntong/git/grpc/proto/   /home/suntong/git/grpc/third-party/**/*.proto   /home/suntong/git/grpc/proto/**/*.proto '
+ main
+ gen_js_pb
+ protoc -I /home/suntong/git/grpc/third-party/ -I /home/suntong/git/grpc/proto/ '/home/suntong/git/grpc/third-party/**/*.proto' /home/suntong/git/grpc/proto/wechaty/deprecated/file-box.proto /home/suntong/git/grpc/proto/wechaty/puppet.proto /home/suntong/git/grpc/proto/wechaty/puppet/base.proto /home/suntong/git/grpc/proto/wechaty/puppet/contact.proto /home/suntong/git/grpc/proto/wechaty/puppet/download-upload.proto /home/suntong/git/grpc/proto/wechaty/puppet/event.proto /home/suntong/git/grpc/proto/wechaty/puppet/friendship.proto /home/suntong/git/grpc/proto/wechaty/puppet/image.proto /home/suntong/git/grpc/proto/wechaty/puppet/location.proto /home/suntong/git/grpc/proto/wechaty/puppet/message.proto /home/suntong/git/grpc/proto/wechaty/puppet/mini-program.proto /home/suntong/git/grpc/proto/wechaty/puppet/referrer.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-invitation.proto /home/suntong/git/grpc/proto/wechaty/puppet/room-member.proto /home/suntong/git/grpc/proto/wechaty/puppet/room.proto /home/suntong/git/grpc/proto/wechaty/puppet/tag.proto /home/suntong/git/grpc/proto/wechaty/puppet/url-link.proto --js_out=import_style=commonjs,binary:/home/suntong/git/grpc/out/
/home/suntong/git/grpc/third-party/**/*.proto: No such file or directory
ERROR: "generate" exited with 1.

$ ls -l /home/suntong/git/grpc/third-party/
total 0

What else I'm missing?

huan commented 2 years ago

Have updated it to v3.19.3

See: https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os

$ protoc --version
libprotoc 3.19.1
suntong commented 2 years ago

OK, now a different error after updating it to v3.19.3:

scripts/generate-stub.sh: line 30: /usr/bin/protoc: Permission denied

$ ls -l /usr/bin/protoc
-rwxr-x--- 1 root root 5407624 Oct 29 06:58 /usr/bin/protoc

please chmod 755 /usr/bin/protoc

huan commented 2 years ago

Done.

And all you need is to run npm run install:protoc:

$ ./scripts/install-protoc.sh 
install skipped: protoc exists
protoc version check: v3.19.1 OK
go: downloading github.com/ckaznocha/protoc-gen-lint v0.2.4
go: downloading google.golang.org/protobuf v1.26.0
~/git/grpc/openapi ~/git/grpc
./install.sh
go: downloading google.golang.org/protobuf v1.27.1
go: downloading google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
go: downloading google.golang.org/grpc v1.42.0
go: downloading google.golang.org/protobuf v1.23.0
go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.1
go: downloading github.com/golang/glog v1.0.0
go: downloading google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12
go: downloading sigs.k8s.io/yaml v1.3.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/golang/protobuf v1.5.2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1760  100  1760    0     0   5789      0 --:--:-- --:--:-- --:--:--  5789
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24777  100 24777    0     0  76236      0 --:--:-- --:--:-- --:--:-- 76236
~/git/grpc
go: downloading github.com/pseudomuto/protoc-gen-doc v1.5.0
go: downloading github.com/pseudomuto/protokit v0.2.0
go: downloading google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007
go: downloading github.com/Masterminds/sprig v2.15.0+incompatible
go: downloading github.com/envoyproxy/protoc-gen-validate v0.3.0-java
go: downloading github.com/gogo/protobuf v1.1.1
go: downloading github.com/Masterminds/semver v1.4.2
go: downloading github.com/aokoli/goutils v1.0.1
go: downloading github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c
go: downloading github.com/huandu/xstrings v1.0.0
go: downloading github.com/imdario/mergo v0.3.4
go: downloading golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1045  100  1045    0     0   3415      0 --:--:-- --:--:-- --:--:--  3415
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15140  100 15140    0     0  47760      0 --:--:-- --:--:-- --:--:-- 47760
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15140  100 15140    0     0   924k      0 --:--:-- --:--:-- --:--:--  924k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2416  100  2416    0     0   7023      0 --:--:-- --:--:-- --:--:--  7023
suntong commented 2 years ago

Thx! Now I get it going.

But calling gen_openapi failed:

. . .
+ gen_js_stub
+ protoc -I ...
+ gen_ts_typing
+ protoc -I ...
+ gen_cjs_package_json
+ echo '{"type": "commonjs"}'
+ gen_web_grpc
+ protoc -I ...
+ gen_openapi
+ pushd openapi
~/git/grpc/openapi ~/git/grpc
+ make generate
./generate.sh
protoc-gen-openapiv2: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--openapiv2_out: protoc-gen-openapiv2: Plugin failed with status code 1.
make: *** [Makefile:6: generate] Error 1
ERROR: "generate" exited with 2.

But at least my gen_ts_typing and gen_js_stub is working! looking into their results now...

suntong commented 2 years ago
proto.wechaty.puppet.MessagePayloadRequest = function(opt_data) {...}
proto.wechaty.puppet.MessagePayloadResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageImageRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageImageResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageContactRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageContactResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageFileRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageFileResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageMiniProgramRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageMiniProgramResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageUrlRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageUrlResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendContactRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendContactResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendFileRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendFileResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendTextRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendTextResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendUrlRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendUrlResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageRecallRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageRecallResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageForwardRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageForwardResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageLocationRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageLocationResponse = function(opt_data) {...}
proto.wechaty.puppet.MessageSendLocationRequest = function(opt_data) {...}
proto.wechaty.puppet.MessageSendLocationResponse = function(opt_data) {...}
proto.wechaty.puppet.MessagePayloadRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessagePayloadRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessagePayloadRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessagePayloadRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessagePayloadRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessagePayloadRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessagePayloadRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessagePayloadRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessagePayloadResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessagePayloadResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessagePayloadResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getFilename = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setFilename = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getText = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setText = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getTimestampDeprecated = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setTimestampDeprecated = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getType = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setType = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getFromId = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setFromId = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getRoomId = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setRoomId = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getToId = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setToId = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getMentionIdsList = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setMentionIdsList = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.addMentionIds = function(value, opt_index) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.clearMentionIdsList = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.getReceiveTime = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.setReceiveTime = function(value) {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.clearReceiveTime = function() {...}
proto.wechaty.puppet.MessagePayloadResponse.prototype.hasReceiveTime = function() {...}
proto.wechaty.puppet.MessageImageRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageImageRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageImageRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageImageRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageImageRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageImageRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageImageRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageImageRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageImageRequest.prototype.getType = function() {...}
proto.wechaty.puppet.MessageImageRequest.prototype.setType = function(value) {...}
proto.wechaty.puppet.MessageImageResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageImageResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageImageResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageImageResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageImageResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageImageResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageImageResponse.prototype.getFileBox = function() {...}
proto.wechaty.puppet.MessageImageResponse.prototype.setFileBox = function(value) {...}
proto.wechaty.puppet.MessageContactRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageContactRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageContactRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageContactRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageContactRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageContactRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageContactRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageContactRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageContactResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageContactResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageContactResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageContactResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageContactResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageContactResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageContactResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageContactResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageFileRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageFileRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageFileRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageFileRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageFileRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageFileRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageFileRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageFileRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageFileResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageFileResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageFileResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageFileResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageFileResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageFileResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageFileResponse.prototype.getFileBox = function() {...}
proto.wechaty.puppet.MessageFileResponse.prototype.setFileBox = function(value) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageMiniProgramRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageMiniProgramRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageMiniProgramRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageMiniProgramResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.getMiniProgramDeprecated = function() {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.setMiniProgramDeprecated = function(value) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.getMiniProgram = function() {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.setMiniProgram = function(value) {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.clearMiniProgram = function() {...}
proto.wechaty.puppet.MessageMiniProgramResponse.prototype.hasMiniProgram = function() {...}
proto.wechaty.puppet.MessageUrlRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageUrlRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageUrlRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageUrlRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageUrlRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageUrlRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageUrlRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageUrlRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageUrlResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageUrlResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageUrlResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageUrlResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.getUrlLinkDeprecated = function() {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.setUrlLinkDeprecated = function(value) {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.getUrlLink = function() {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.setUrlLink = function(value) {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.clearUrlLink = function() {...}
proto.wechaty.puppet.MessageUrlResponse.prototype.hasUrlLink = function() {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendContactRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendContactRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendContactRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendContactRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.getContactId = function() {...}
proto.wechaty.puppet.MessageSendContactRequest.prototype.setContactId = function(value) {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendContactResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendContactResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendContactResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendContactResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendContactResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendFileRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendFileRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendFileRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendFileRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.getFileBox = function() {...}
proto.wechaty.puppet.MessageSendFileRequest.prototype.setFileBox = function(value) {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendFileResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendFileResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendFileResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendFileResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendFileResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendTextRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendTextRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendTextRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendTextRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.getText = function() {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.setText = function(value) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.getMentionalIdsList = function() {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.setMentionalIdsList = function(value) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.addMentionalIds = function(value, opt_index) {...}
proto.wechaty.puppet.MessageSendTextRequest.prototype.clearMentionalIdsList = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendTextResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendTextResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendTextResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendTextResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.getMiniProgramDeprecated = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.setMiniProgramDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.getMiniProgram = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.setMiniProgram = function(value) {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.clearMiniProgram = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramRequest.prototype.hasMiniProgram = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendMiniProgramResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendUrlRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendUrlRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendUrlRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendUrlRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.getUrlLinkDeprecated = function() {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.setUrlLinkDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.getUrlLink = function() {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.setUrlLink = function(value) {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.clearUrlLink = function() {...}
proto.wechaty.puppet.MessageSendUrlRequest.prototype.hasUrlLink = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendUrlResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendUrlResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendUrlResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendUrlResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageRecallRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageRecallRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageRecallRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageRecallRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageRecallRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageRecallRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageRecallRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageRecallRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageRecallResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageRecallResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageRecallResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageRecallResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageRecallResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageRecallResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageRecallResponse.prototype.getSuccess = function() {...}
proto.wechaty.puppet.MessageRecallResponse.prototype.setSuccess = function(value) {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageForwardRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageForwardRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageForwardRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageForwardRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.getMessageId = function() {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.setMessageId = function(value) {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageForwardRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageForwardResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageForwardResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageForwardResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageForwardResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.getIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.setIdStringValueDeprecated = function(value) {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.clearIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.hasIdStringValueDeprecated = function() {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageForwardResponse.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageLocationRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageLocationRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageLocationRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageLocationRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageLocationRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageLocationRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageLocationRequest.prototype.getId = function() {...}
proto.wechaty.puppet.MessageLocationRequest.prototype.setId = function(value) {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageLocationResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageLocationResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageLocationResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageLocationResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.getLocation = function() {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.setLocation = function(value) {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.clearLocation = function() {...}
proto.wechaty.puppet.MessageLocationResponse.prototype.hasLocation = function() {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendLocationRequest.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendLocationRequest.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendLocationRequest.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendLocationRequest.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.getConversationId = function() {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.setConversationId = function(value) {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.getLocation = function() {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.setLocation = function(value) {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.clearLocation = function() {...}
proto.wechaty.puppet.MessageSendLocationRequest.prototype.hasLocation = function() {...}
proto.wechaty.puppet.MessageSendLocationResponse.prototype.toObject = function(opt_includeInstance) {...}
proto.wechaty.puppet.MessageSendLocationResponse.toObject = function(includeInstance, msg) {...}
proto.wechaty.puppet.MessageSendLocationResponse.deserializeBinary = function(bytes) {...}
proto.wechaty.puppet.MessageSendLocationResponse.deserializeBinaryFromReader = function(msg, reader) {...}
proto.wechaty.puppet.MessageSendLocationResponse.prototype.serializeBinary = function() {...}
proto.wechaty.puppet.MessageSendLocationResponse.serializeBinaryToWriter = function(message, writer) {...}
proto.wechaty.puppet.MessageSendLocationResponse.prototype.getId = function() {...}
proto.wechaty.puppet.MessageSendLocationResponse.prototype.setId = function(value) {...}

I think I misunderstand what wechaty/grpc generates when I asked this question. So let me ask this way, @huan,

Apparently what generated is how the puppet client can talk to wechaty/grpc server with the protobuf protocol, right?

Is there anywhere I can find the definition in TypeScript of the data structure of different wechat message are? E.g., for a type 54 wechat message (<type>54</type>), is there any predefined message data type that can map such type 54 wechat message as a TypeScript object? Hope that I've made myself clear enough. thx.

Hmmm, maybe these?

  toObject(includeInstance?: boolean): MessagePayloadRequest.AsObject;
  toObject(includeInstance?: boolean): MessagePayloadResponse.AsObject;
  toObject(includeInstance?: boolean): MessageImageRequest.AsObject;
  toObject(includeInstance?: boolean): MessageImageResponse.AsObject;
  toObject(includeInstance?: boolean): MessageContactRequest.AsObject;
  toObject(includeInstance?: boolean): MessageContactResponse.AsObject;
  toObject(includeInstance?: boolean): MessageFileRequest.AsObject;
  toObject(includeInstance?: boolean): MessageFileResponse.AsObject;
  toObject(includeInstance?: boolean): MessageMiniProgramRequest.AsObject;
  toObject(includeInstance?: boolean): MessageMiniProgramResponse.AsObject;
  toObject(includeInstance?: boolean): MessageUrlRequest.AsObject;
  toObject(includeInstance?: boolean): MessageUrlResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendContactRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendContactResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendFileRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendFileResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendTextRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendTextResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendMiniProgramRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendMiniProgramResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendUrlRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendUrlResponse.AsObject;
  toObject(includeInstance?: boolean): MessageRecallRequest.AsObject;
  toObject(includeInstance?: boolean): MessageRecallResponse.AsObject;
  toObject(includeInstance?: boolean): MessageForwardRequest.AsObject;
  toObject(includeInstance?: boolean): MessageForwardResponse.AsObject;
  toObject(includeInstance?: boolean): MessageLocationRequest.AsObject;
  toObject(includeInstance?: boolean): MessageLocationResponse.AsObject;
  toObject(includeInstance?: boolean): MessageSendLocationRequest.AsObject;
  toObject(includeInstance?: boolean): MessageSendLocationResponse.AsObject;

but these only cast different message requests into objects. Not message itself.

$ grep 'MessageMiniProgram' wechaty/puppet/message_pb.d.ts 
export class MessageMiniProgramRequest extends jspb.Message {
  toObject(includeInstance?: boolean): MessageMiniProgramRequest.AsObject;
  static toObject(includeInstance: boolean, msg: MessageMiniProgramRequest): MessageMiniProgramRequest.AsObject;
  static serializeBinaryToWriter(message: MessageMiniProgramRequest, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): MessageMiniProgramRequest;
  static deserializeBinaryFromReader(message: MessageMiniProgramRequest, reader: jspb.BinaryReader): MessageMiniProgramRequest;
export namespace MessageMiniProgramRequest {
export class MessageMiniProgramResponse extends jspb.Message {
  toObject(includeInstance?: boolean): MessageMiniProgramResponse.AsObject;
  static toObject(includeInstance: boolean, msg: MessageMiniProgramResponse): MessageMiniProgramResponse.AsObject;
  static serializeBinaryToWriter(message: MessageMiniProgramResponse, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): MessageMiniProgramResponse;
  static deserializeBinaryFromReader(message: MessageMiniProgramResponse, reader: jspb.BinaryReader): MessageMiniProgramResponse;
export namespace MessageMiniProgramResponse {

$ grep 'export class .* extends' wechaty/puppet/message_pb.d.ts 
export class MessagePayloadRequest extends jspb.Message {
export class MessagePayloadResponse extends jspb.Message {
export class MessageImageRequest extends jspb.Message {
export class MessageImageResponse extends jspb.Message {
export class MessageContactRequest extends jspb.Message {
export class MessageContactResponse extends jspb.Message {
export class MessageFileRequest extends jspb.Message {
export class MessageFileResponse extends jspb.Message {
export class MessageMiniProgramRequest extends jspb.Message {
export class MessageMiniProgramResponse extends jspb.Message {
export class MessageUrlRequest extends jspb.Message {
export class MessageUrlResponse extends jspb.Message {
export class MessageSendContactRequest extends jspb.Message {
export class MessageSendContactResponse extends jspb.Message {
export class MessageSendFileRequest extends jspb.Message {
export class MessageSendFileResponse extends jspb.Message {
export class MessageSendTextRequest extends jspb.Message {
export class MessageSendTextResponse extends jspb.Message {
export class MessageSendMiniProgramRequest extends jspb.Message {
export class MessageSendMiniProgramResponse extends jspb.Message {
export class MessageSendUrlRequest extends jspb.Message {
export class MessageSendUrlResponse extends jspb.Message {
export class MessageRecallRequest extends jspb.Message {
export class MessageRecallResponse extends jspb.Message {
export class MessageForwardRequest extends jspb.Message {
export class MessageForwardResponse extends jspb.Message {
export class MessageLocationRequest extends jspb.Message {
export class MessageLocationResponse extends jspb.Message {
export class MessageSendLocationRequest extends jspb.Message {
export class MessageSendLocationResponse extends jspb.Message {

Maybe the message data type is defined in jspb.Message?

huan commented 2 years ago

Are you trying to find this?

Most of the universal schema definitions are in the above folder.

suntong commented 2 years ago

Hmm... more or less this for the message data type definition, for e.g., type 51 & 54 appmsg etc.

huan commented 2 years ago

You can also refer to the source code of webwx app:

            //msg type
            MSGTYPE_TEXT: 1
            , MSGTYPE_IMAGE: 3
            , MSGTYPE_VOICE: 34
            , MSGTYPE_VIDEO: 43
            , MSGTYPE_MICROVIDEO: 62
            , MSGTYPE_EMOTICON: 47
            , MSGTYPE_APP: 49
            , MSGTYPE_VOIPMSG: 50, // voip msg
            MSGTYPE_VOIPNOTIFY: 52, // voip 结束消息
            MSGTYPE_VOIPINVITE: 53, // voip 邀请
            MSGTYPE_LOCATION: 48
            , MSGTYPE_STATUSNOTIFY: 51
            , MSGTYPE_SYSNOTICE: 9999
            , MSGTYPE_POSSIBLEFRIEND_MSG: 40
            , MSGTYPE_VERIFYMSG: 37
            , MSGTYPE_SHARECARD: 42
            , MSGTYPE_SYS: 10000
            , MSGTYPE_RECALLED: 10002,

See:

https://github.com/wechaty/webwx-app-tracker/blob/a12c78fb8bd7186c0f3bb0e18dd611151e6b8aac/formatted/webwxApp.js#L7512

suntong commented 2 years ago

I'm looking for the definition in TypeScript of the data structure of different wechat message. E.g., for this type 51 message:

<?xml version="1.0"?>
<msg>
 <appmsg appid="" sdkver="0">
  <title>Your current WeChat version does not support this content. Update to the latest version.</title>
  <des />
  <username />
  <action>view</action>
  <type>51</type>
  <showtype>0</showtype>
  <content />
  <url>https://support.weixin.qq.com/security/readtemplate?t=w_security_center_website/upgrade</url>
  <lowurl />
  <dataurl />
  <lowdataurl />
  <contentattr>0</contentattr>
  <streamvideo>
   <streamvideourl />
   <streamvideototaltime>0</streamvideototaltime>
   <streamvideotitle />
   <streamvideowording />
   <streamvideoweburl />
   <streamvideothumburl />
   <streamvideoaduxinfo />
   <streamvideopublishid />
  </streamvideo>
  <canvasPageItem>
   <canvasPageXml><![CDATA[]]></canvasPageXml>
  </canvasPageItem>
  <appattach>
   <totallen>0</totallen>
   <attachid />
   <cdnattachurl />
   <emoticonmd5></emoticonmd5>
   <aeskey></aeskey>
   <fileext />
   <islargefilemsg>0</islargefilemsg>
   <overwrite_newmsgid>0</overwrite_newmsgid>
   <fileuploadtoken><![CDATA[]]></fileuploadtoken>
  </appattach>
  <extinfo />
  <androidsource>0</androidsource>
  <thumburl />
  <mediatagname />
  <messageaction><![CDATA[]]></messageaction>
  <messageext><![CDATA[]]></messageext>
  <emoticongift>
   <packageflag>0</packageflag>
   <packageid />
  </emoticongift>
  <emoticonshared>
   <packageflag>0</packageflag>
   <packageid />
  </emoticonshared>
  <designershared>
   <designeruin>0</designeruin>
   <designername>null</designername>
   <designerrediretcturl>null</designerrediretcturl>
  </designershared>
  <emotionpageshared>
   <tid>0</tid>
   <title>null</title>
   <desc>null</desc>
   <iconUrl>null</iconUrl>
   <secondUrl />
   <pageType>0</pageType>
  </emotionpageshared>
  <webviewshared>
   <shareUrlOriginal />
   <shareUrlOpen />
   <jsAppId />
   <publisherId />
  </webviewshared>
  <template_id />
  <md5 />
  <weappinfo>
   <username />
   <appid />
   <appservicetype>0</appservicetype>
   <videopageinfo>
    <thumbwidth>0</thumbwidth>
    <thumbheight>0</thumbheight>
    <fromopensdk>0</fromopensdk>
   </videopageinfo>
  </weappinfo>
  <statextstr />
  <musicShareItem>
   <musicDuration>0</musicDuration>
  </musicShareItem>
  <finderFeed>
   <objectId>13586191238638082080</objectId>
   <objectNonceId>2479223310619088676_4_20_13</objectNonceId>
   <feedType>4</feedType>
   <nickname>滇东南行者</nickname>
   <username>v2_060000231003b20faec8c5e5881bc4d1cb03ea36b077a34e350ea4895034bb2b4d3df377eabd@finder</username>
   <avatar><![CDATA[http://wx.qlogo.cn/finderhead/eHEMOF2hOelPSyzBicEqdLPKKsTbS7Ff9h7d54WtPUqBPjjLicNwu2hw/0]]></avatar>
   <desc>像是回到了冰河时代,冰雹,暴雨,雪,一起砸下来,头一回见这么厉害!</desc>
   <mediaCount>1</mediaCount>
   <localId>0</localId>
   <mediaList>
    <media>
     <mediaType>4</mediaType>
     <url><![CDATA[http://wxapp.tc.qq.com/251/20302/stodownload?encfilekey=Cvvj5Ix3eezXKmVNfShJRUicJJMYPEroic4L0paJjibKRISeJCCpqp7iaS9rxgh97Vyx0RpQR4HSnO5cpRJibMyXaKyWDH4Ye4SjRfQc2DqvWhfdjIT4OE9lrgnqElVykU31ShvsTgAoUmcHA4p9J6HWPP8uTbbdZkaicgbH2fOfGgMYOf3KicK7JicHjHoKgIXUGsuJ&adaptivelytrans=0&bizid=1023&dotrans=938&hy=SZ&idx=1&m=7d3803d8f2c1afb7aed787ec5937609a]]></url>
     <thumbUrl><![CDATA[http://wxapp.tc.qq.com/251/20350/stodownload?encfilekey=XGocBFxVWK5dcyOOqpEU4yZ0ia4qlCRBBTHTgGfEODUzWBl1WYcKtOuUjeibYYPcHlURnMw0RwbE68WWTopR43X9CWEvV50Z33iax7yKY6NgCjus14sicoFdF3SUDrfnquCXicffUnEb5udxYC8fiaXTZs6iaThfTs7ia8HU8nkicwoOI8XibrSiaIZQmmBog&adaptivelytrans=0&bizid=1023&dotrans=0&hy=SZ&idx=1&m=78634793a91e2c6011e51255c325e5ed&token=x5Y29zUxcibBiaGHtmXXicGxqSiaiaOb6G2y8lpQ4vWoI03lxEt7I0zhgjyibLibUJSRNc5]]></thumbUrl>
     <fullCoverUrl><![CDATA[http://wxapp.tc.qq.com/251/20304/stodownload?encfilekey=XGocBFxVWK5dcyOOqpEU4yZ0ia4qlCRBBFUImJxslyp8liaHI4I5h2IsSyAPZVT5tabmyIbDEHLUYpRbao6Y4LQ45hh0HN4ibkib6Fng9wpl2KjRaIRaQgwaI1ibiaGG9BB8Jg1iaicI0h66Hcg04SaYl8YITgKNW383xy5ljfrIgSgNIXxb3iaof8y9J6A&adaptivelytrans=0&bizid=1023&dotrans=0&hy=SZ&idx=1&m=9525757867aa7e93bd14ee3a8721dcc4&token=x5Y29zUxcibCvkDbNQE5SdNN7OrXdJWIRQjGibFFddEhQqHNdhWuJicdp7CW630yUjia]]></fullCoverUrl>
     <fullClipInset><![CDATA[]]></fullClipInset>
     <width>720.0</width>
     <height>1280.0</height>
     <videoPlayDuration>43</videoPlayDuration>
    </media>
   </mediaList>
   <megaVideo>
    <objectId />
    <objectNonceId />
   </megaVideo>
  </finderFeed>
  <findernamecard>
   <username />
   <avatar><![CDATA[]]></avatar>
   <nickname />
   <auth_job />
   <auth_icon>0</auth_icon>
   <auth_icon_url />
  </findernamecard>
  <finderEndorsement>
   <scene><![CDATA[0]]></scene>
  </finderEndorsement>
  <directshare>0</directshare>
  <gamecenter>
   <namecard>
    <iconUrl />
    <name />
    <desc />
    <tail />
    <jumpUrl />
   </namecard>
  </gamecenter>
  <patMsg>
   <chatUser />
   <records>
    <recordNum>0</recordNum>
   </records>
  </patMsg>
  <websearch />
 </appmsg>
 <fromusername>wxid_h6tt4q3egsoh22</fromusername>
 <scene>0</scene>
 <appinfo>
  <version>1</version>
  <appname />
 </appinfo>
 <commenturl />
</msg>

The corresponding TypeScript data structure would more or less look like this:

declare module namespace {

    export interface Streamvideo {
        streamvideourl: any[];
        streamvideototaltime: string;
        streamvideotitle: any[];
        streamvideowording: any[];
        streamvideoweburl: any[];
        streamvideothumburl: any[];
        streamvideoaduxinfo: any[];
        streamvideopublishid: any[];
    }

    export interface CanvasPageItem {
        canvasPageXml: any[];
    }

    export interface Appattach {
        totallen: string;
        attachid: any[];
        cdnattachurl: any[];
        emoticonmd5: any[];
        aeskey: any[];
        fileext: any[];
        islargefilemsg: string;
        overwrite_newmsgid: string;
        fileuploadtoken: any[];
    }

    export interface Emoticongift {
        packageflag: string;
        packageid: any[];
    }

    export interface Emoticonshared {
        packageflag: string;
        packageid: any[];
    }

    export interface Designershared {
        designeruin: string;
        designername?: any;
        designerrediretcturl?: any;
    }

    export interface Emotionpageshared {
        tid: string;
        title?: any;
        desc?: any;
        iconUrl?: any;
        secondUrl: any[];
        pageType: string;
    }

    export interface Webviewshared {
        shareUrlOriginal: any[];
        shareUrlOpen: any[];
        jsAppId: any[];
        publisherId: any[];
    }

    export interface Videopageinfo {
        thumbwidth: string;
        thumbheight: string;
        fromopensdk: string;
    }

    export interface Weappinfo {
        username: any[];
        appid: any[];
        appservicetype: string;
        videopageinfo: Videopageinfo;
    }

    export interface MusicShareItem {
        musicDuration: string;
    }

    export interface Media {
        mediaType: string;
        url: string;
        thumbUrl: string;
        fullCoverUrl: string;
        fullClipInset: any[];
        width: string;
        height: string;
        videoPlayDuration: string;
    }

    export interface MediaList {
        media: Media;
    }

    export interface MegaVideo {
        objectId: any[];
        objectNonceId: any[];
    }

    export interface FinderFeed {
        objectId: string;
        objectNonceId: string;
        feedType: string;
        nickname: string;
        username: string;
        avatar: string;
        desc: string;
        mediaCount: string;
        localId: string;
        mediaList: MediaList;
        megaVideo: MegaVideo;
    }

    export interface Findernamecard {
        username: any[];
        avatar: any[];
        nickname: any[];
        auth_job: any[];
        auth_icon: string;
        auth_icon_url: any[];
    }

    export interface FinderEndorsement {
        scene: string;
    }

    export interface Namecard {
        iconUrl: any[];
        name: any[];
        desc: any[];
        tail: any[];
        jumpUrl: any[];
    }

    export interface Gamecenter {
        namecard: Namecard;
    }

    export interface Records {
        recordNum: string;
    }

    export interface PatMsg {
        chatUser: any[];
        records: Records;
    }

    export interface Appmsg {
        @appid: string;
        @sdkver: string;
        title: string;
        des: any[];
        username: any[];
        action: string;
        type: string;
        showtype: string;
        content: any[];
        url: string;
        lowurl: any[];
        dataurl: any[];
        lowdataurl: any[];
        contentattr: string;
        streamvideo: Streamvideo;
        canvasPageItem: CanvasPageItem;
        appattach: Appattach;
        extinfo: any[];
        androidsource: string;
        thumburl: any[];
        mediatagname: any[];
        messageaction: any[];
        messageext: any[];
        emoticongift: Emoticongift;
        emoticonshared: Emoticonshared;
        designershared: Designershared;
        emotionpageshared: Emotionpageshared;
        webviewshared: Webviewshared;
        template_id: any[];
        md5: any[];
        weappinfo: Weappinfo;
        statextstr: any[];
        musicShareItem: MusicShareItem;
        finderFeed: FinderFeed;
        findernamecard: Findernamecard;
        finderEndorsement: FinderEndorsement;
        directshare: string;
        gamecenter: Gamecenter;
        patMsg: PatMsg;
        websearch: any[];
    }

    export interface Appinfo {
        version: string;
        appname: any[];
    }

    export interface RootObject {
        appmsg: Appmsg;
        fromusername: string;
        scene: string;
        appinfo: Appinfo;
        commenturl: any[];
    }

}
suntong commented 2 years ago

Because TypeScript object is strongly typed. Thus it need data structure so as to visit data.

In Javascript, to convert a JSON string to Javascript object, one can simply do this:

const text = '{"name":"John", "birth":"1986-12-14", "city":"New York"}'
const obj = JSON.parse(text)
huan commented 2 years ago

I hope you can solve your problem soon, good luck!