Skip to content

Commit

Permalink
clean google/protobuf/wrappers.proto (#125)
Browse files Browse the repository at this point in the history
* require protoc v3.15 (#109)

* Upgrade grpc-gateway v2.1 -> v2.3 (#109)

* show version when install grpc-gateway (#109)

* use `optional` in friendship source (#109)

* clean

* optional hello

* v0.25 for optional

* add comment to #130

* add docs for gRPC proto

* clean script

* add link

* add back optional to replace wrappers

* improvement

* remove unnecessary optional

* 0.29.36

* 0.29.37

* 0.29.38

* 0.29.39

* 0.29.40

* clean

* 0.29.41

* clean

* 0.29.42

* clean

* 0.29.43

* re-export google pb classes from cjs

* re-export google pb classes from cjs

* 0.29.44

* 0.29.45

* add @latest for install

* 0.29.46
  • Loading branch information
huan authored Oct 4, 2021
1 parent 9cd78ee commit 9b62e9c
Show file tree
Hide file tree
Showing 15 changed files with 292 additions and 36 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,36 @@ protoc \

## OpenAPI

Learn more about the RESTful API service for Wechaty from [Wechaty OpenAPI](https://github.com/wechaty/openapi).

## gRPC Web

- [gRPC-Web ReactJS client, Golang Server](https://github.com/longfellowone/grpcwebtest)

## RESOURCES

### Documentation

- [Protocol Buffers Language Guide (proto3)](https://developers.google.com/protocol-buffers/docs/proto3)
- [Google Protocol Buffers Style Guide](https://developers.google.com/protocol-buffers/docs/style)
- [Protocol Buffers for TypeScript with Decorators](https://github.com/protobufjs/protobuf.js#using-decorators)
- [Troubleshooting gRPC](https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md)
- [gRPC environment variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md)
- [How to Interact With and Debug a gRPC Server](https://medium.com/@EdgePress/how-to-interact-with-and-debug-a-grpc-server-c4bc30ddeb0b)

### Links

- [探讨gRPC的Node技术生态及实现工具](https://xenojoshua.com/2018/02/grpc-node-ecosystem/)
- [gRPC Basics - Node.js](https://grpc.io/docs/tutorials/basic/node.html)
- [Building a gRPC service with Node.js](https://codelabs.developers.google.com/codelabs/cloud-grpc/)
- [gRPC in 3 minutes (Node.js)](https://github.com/grpc/grpc/tree/master/examples/node)
- [Listen gRPC and HTTP requests on the same port](https://medium.com/@drgarcia1986/listen-grpc-and-http-requests-on-the-same-port-263c40cb45ff)
- [gRPC to JSON proxy generator following the gRPC HTTP spec](https://github.com/grpc-ecosystem/grpc-gateway)
- [如何在 Node.js 中更优雅地使用 gRPC:grpc-helper](https://github.com/xizhibei/blog/issues/86)
- [Comparing OpenAPI With gRPC](https://dzone.com/articles/comparing-openapi-with-grpc)

#### Protocol Buffer

Thanks to the ecosystem of gRPC, we can generate OpenAPI Specification from our gRPC proto definitions automatically.

We are using [gRPC to JSON proxy generator following the gRPC HTTP spec](https://github.com/grpc-ecosystem/grpc-gateway) as the OpenAPI Specification generator ([protoc-gen-openapiv2](https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-openapiv2)), and using [Like grpc-gateway, but written in node and dynamic](https://github.com/konsumer/grpc-dynamic-gateway) project to serve an HTTP RESTful API to gRPC proxy.
Expand Down
11 changes: 11 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: all
all : docs

.PHONY: docs
docs:
protoc \
-I ../third-party/ \
-I ../proto/ \
--doc_out=./ \
--doc_opt=markdown,README.md \
../proto/wechaty/puppet.proto
120 changes: 120 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Protocol Documentation
<a name="top"></a>

## Table of Contents

- [wechaty/puppet.proto](#wechaty/puppet.proto)
- [Puppet](#wechaty.Puppet)

- [Scalar Value Types](#scalar-value-types)



<a name="wechaty/puppet.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## wechaty/puppet.proto
Wechaty Puppet gRPC Protocol Buffers
https://github.com/wechaty/grpc/
Huan LI &lt;zixia@zixia.net&gt;
Apr 2018
License: Apache-2.0

Google Protocol Buffers
Style Guide - https://developers.google.com/protocol-buffers/docs/style








<a name="wechaty.Puppet"></a>

### Puppet


| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| Start | [puppet.StartRequest](#wechaty.puppet.StartRequest) | [puppet.StartResponse](#wechaty.puppet.StartResponse) | Base |
| Stop | [puppet.StopRequest](#wechaty.puppet.StopRequest) | [puppet.StopResponse](#wechaty.puppet.StopResponse) | |
| Logout | [puppet.LogoutRequest](#wechaty.puppet.LogoutRequest) | [puppet.LogoutResponse](#wechaty.puppet.LogoutResponse) | |
| Ding | [puppet.DingRequest](#wechaty.puppet.DingRequest) | [puppet.DingResponse](#wechaty.puppet.DingResponse) | |
| Version | [puppet.VersionRequest](#wechaty.puppet.VersionRequest) | [puppet.VersionResponse](#wechaty.puppet.VersionResponse) | |
| Event | [puppet.EventRequest](#wechaty.puppet.EventRequest) | [puppet.EventResponse](#wechaty.puppet.EventResponse) stream | Event - Server Stream |
| DirtyPayload | [puppet.DirtyPayloadRequest](#wechaty.puppet.DirtyPayloadRequest) | [puppet.DirtyPayloadResponse](#wechaty.puppet.DirtyPayloadResponse) | |
| ContactSelfQRCode | [puppet.ContactSelfQRCodeRequest](#wechaty.puppet.ContactSelfQRCodeRequest) | [puppet.ContactSelfQRCodeResponse](#wechaty.puppet.ContactSelfQRCodeResponse) | Contact Self |
| ContactSelfName | [puppet.ContactSelfNameRequest](#wechaty.puppet.ContactSelfNameRequest) | [puppet.ContactSelfNameResponse](#wechaty.puppet.ContactSelfNameResponse) | |
| ContactSelfSignature | [puppet.ContactSelfSignatureRequest](#wechaty.puppet.ContactSelfSignatureRequest) | [puppet.ContactSelfSignatureResponse](#wechaty.puppet.ContactSelfSignatureResponse) | |
| ContactPayload | [puppet.ContactPayloadRequest](#wechaty.puppet.ContactPayloadRequest) | [puppet.ContactPayloadResponse](#wechaty.puppet.ContactPayloadResponse) | Contact |
| ContactAlias | [puppet.ContactAliasRequest](#wechaty.puppet.ContactAliasRequest) | [puppet.ContactAliasResponse](#wechaty.puppet.ContactAliasResponse) | |
| ContactAvatar | [puppet.ContactAvatarRequest](#wechaty.puppet.ContactAvatarRequest) | [puppet.ContactAvatarResponse](#wechaty.puppet.ContactAvatarResponse) | |
| ContactPhone | [puppet.ContactPhoneRequest](#wechaty.puppet.ContactPhoneRequest) | [puppet.ContactPhoneResponse](#wechaty.puppet.ContactPhoneResponse) | |
| ContactCorporationRemark | [puppet.ContactCorporationRemarkRequest](#wechaty.puppet.ContactCorporationRemarkRequest) | [puppet.ContactCorporationRemarkResponse](#wechaty.puppet.ContactCorporationRemarkResponse) | |
| ContactDescription | [puppet.ContactDescriptionRequest](#wechaty.puppet.ContactDescriptionRequest) | [puppet.ContactDescriptionResponse](#wechaty.puppet.ContactDescriptionResponse) | |
| ContactList | [puppet.ContactListRequest](#wechaty.puppet.ContactListRequest) | [puppet.ContactListResponse](#wechaty.puppet.ContactListResponse) | Huan(202002): consider changing response to a stream in the future for better performance |
| FriendshipPayload | [puppet.FriendshipPayloadRequest](#wechaty.puppet.FriendshipPayloadRequest) | [puppet.FriendshipPayloadResponse](#wechaty.puppet.FriendshipPayloadResponse) | Friendship |
| FriendshipSearchPhone | [puppet.FriendshipSearchPhoneRequest](#wechaty.puppet.FriendshipSearchPhoneRequest) | [puppet.FriendshipSearchPhoneResponse](#wechaty.puppet.FriendshipSearchPhoneResponse) | |
| FriendshipSearchWeixin | [puppet.FriendshipSearchWeixinRequest](#wechaty.puppet.FriendshipSearchWeixinRequest) | [puppet.FriendshipSearchWeixinResponse](#wechaty.puppet.FriendshipSearchWeixinResponse) | |
| FriendshipAdd | [puppet.FriendshipAddRequest](#wechaty.puppet.FriendshipAddRequest) | [puppet.FriendshipAddResponse](#wechaty.puppet.FriendshipAddResponse) | |
| FriendshipAccept | [puppet.FriendshipAcceptRequest](#wechaty.puppet.FriendshipAcceptRequest) | [puppet.FriendshipAcceptResponse](#wechaty.puppet.FriendshipAcceptResponse) | |
| MessageFile | [puppet.MessageFileRequest](#wechaty.puppet.MessageFileRequest) | [puppet.MessageFileResponse](#wechaty.puppet.MessageFileResponse) | @deprecated: using MessageFileStream to transfer files Huan(202010): will be removed (replaced by MessageFileStream) after Dec 31, 2021 |
| MessageImage | [puppet.MessageImageRequest](#wechaty.puppet.MessageImageRequest) | [puppet.MessageImageResponse](#wechaty.puppet.MessageImageResponse) | @deprecated: using MessageImageStream to transfer images Huan(202010): will be removed (replaced by MessageImageStream) after Dec 31, 2021 |
| MessageSendFile | [puppet.MessageSendFileRequest](#wechaty.puppet.MessageSendFileRequest) | [puppet.MessageSendFileResponse](#wechaty.puppet.MessageSendFileResponse) | @deprecated: using MesageSendFileStream to transfer file message to server Huan(202010): will be removed (replaced by MessageSendFileStream) after Dec 31, 2021 |
| MessagePayload | [puppet.MessagePayloadRequest](#wechaty.puppet.MessagePayloadRequest) | [puppet.MessagePayloadResponse](#wechaty.puppet.MessagePayloadResponse) | |
| MessageContact | [puppet.MessageContactRequest](#wechaty.puppet.MessageContactRequest) | [puppet.MessageContactResponse](#wechaty.puppet.MessageContactResponse) | |
| MessageFileStream | [puppet.MessageFileStreamRequest](#wechaty.puppet.MessageFileStreamRequest) | [puppet.MessageFileStreamResponse](#wechaty.puppet.MessageFileStreamResponse) stream | |
| MessageImageStream | [puppet.MessageImageStreamRequest](#wechaty.puppet.MessageImageStreamRequest) | [puppet.MessageImageStreamResponse](#wechaty.puppet.MessageImageStreamResponse) stream | |
| MessageMiniProgram | [puppet.MessageMiniProgramRequest](#wechaty.puppet.MessageMiniProgramRequest) | [puppet.MessageMiniProgramResponse](#wechaty.puppet.MessageMiniProgramResponse) | |
| MessageUrl | [puppet.MessageUrlRequest](#wechaty.puppet.MessageUrlRequest) | [puppet.MessageUrlResponse](#wechaty.puppet.MessageUrlResponse) | |
| MessageRecall | [puppet.MessageRecallRequest](#wechaty.puppet.MessageRecallRequest) | [puppet.MessageRecallResponse](#wechaty.puppet.MessageRecallResponse) | |
| MessageForward | [puppet.MessageForwardRequest](#wechaty.puppet.MessageForwardRequest) | [puppet.MessageForwardResponse](#wechaty.puppet.MessageForwardResponse) | |
| MessageSendContact | [puppet.MessageSendContactRequest](#wechaty.puppet.MessageSendContactRequest) | [puppet.MessageSendContactResponse](#wechaty.puppet.MessageSendContactResponse) | |
| MessageSendFileStream | [puppet.MessageSendFileStreamRequest](#wechaty.puppet.MessageSendFileStreamRequest) stream | [puppet.MessageSendFileStreamResponse](#wechaty.puppet.MessageSendFileStreamResponse) | |
| MessageSendText | [puppet.MessageSendTextRequest](#wechaty.puppet.MessageSendTextRequest) | [puppet.MessageSendTextResponse](#wechaty.puppet.MessageSendTextResponse) | |
| MessageSendMiniProgram | [puppet.MessageSendMiniProgramRequest](#wechaty.puppet.MessageSendMiniProgramRequest) | [puppet.MessageSendMiniProgramResponse](#wechaty.puppet.MessageSendMiniProgramResponse) | |
| MessageSendUrl | [puppet.MessageSendUrlRequest](#wechaty.puppet.MessageSendUrlRequest) | [puppet.MessageSendUrlResponse](#wechaty.puppet.MessageSendUrlResponse) | |
| RoomPayload | [puppet.RoomPayloadRequest](#wechaty.puppet.RoomPayloadRequest) | [puppet.RoomPayloadResponse](#wechaty.puppet.RoomPayloadResponse) | Room |
| RoomList | [puppet.RoomListRequest](#wechaty.puppet.RoomListRequest) | [puppet.RoomListResponse](#wechaty.puppet.RoomListResponse) | |
| RoomAdd | [puppet.RoomAddRequest](#wechaty.puppet.RoomAddRequest) | [puppet.RoomAddResponse](#wechaty.puppet.RoomAddResponse) | |
| RoomAvatar | [puppet.RoomAvatarRequest](#wechaty.puppet.RoomAvatarRequest) | [puppet.RoomAvatarResponse](#wechaty.puppet.RoomAvatarResponse) | |
| RoomCreate | [puppet.RoomCreateRequest](#wechaty.puppet.RoomCreateRequest) | [puppet.RoomCreateResponse](#wechaty.puppet.RoomCreateResponse) | |
| RoomDel | [puppet.RoomDelRequest](#wechaty.puppet.RoomDelRequest) | [puppet.RoomDelResponse](#wechaty.puppet.RoomDelResponse) | |
| RoomQuit | [puppet.RoomQuitRequest](#wechaty.puppet.RoomQuitRequest) | [puppet.RoomQuitResponse](#wechaty.puppet.RoomQuitResponse) | |
| RoomTopic | [puppet.RoomTopicRequest](#wechaty.puppet.RoomTopicRequest) | [puppet.RoomTopicResponse](#wechaty.puppet.RoomTopicResponse) | |
| RoomQRCode | [puppet.RoomQRCodeRequest](#wechaty.puppet.RoomQRCodeRequest) | [puppet.RoomQRCodeResponse](#wechaty.puppet.RoomQRCodeResponse) | |
| RoomAnnounce | [puppet.RoomAnnounceRequest](#wechaty.puppet.RoomAnnounceRequest) | [puppet.RoomAnnounceResponse](#wechaty.puppet.RoomAnnounceResponse) | |
| RoomMemberPayload | [puppet.RoomMemberPayloadRequest](#wechaty.puppet.RoomMemberPayloadRequest) | [puppet.RoomMemberPayloadResponse](#wechaty.puppet.RoomMemberPayloadResponse) | Room Member |
| RoomMemberList | [puppet.RoomMemberListRequest](#wechaty.puppet.RoomMemberListRequest) | [puppet.RoomMemberListResponse](#wechaty.puppet.RoomMemberListResponse) | |
| RoomInvitationPayload | [puppet.RoomInvitationPayloadRequest](#wechaty.puppet.RoomInvitationPayloadRequest) | [puppet.RoomInvitationPayloadResponse](#wechaty.puppet.RoomInvitationPayloadResponse) | Room Invitation |
| RoomInvitationAccept | [puppet.RoomInvitationAcceptRequest](#wechaty.puppet.RoomInvitationAcceptRequest) | [puppet.RoomInvitationAcceptResponse](#wechaty.puppet.RoomInvitationAcceptResponse) | |
| TagContactAdd | [puppet.TagContactAddRequest](#wechaty.puppet.TagContactAddRequest) | [puppet.TagContactAddResponse](#wechaty.puppet.TagContactAddResponse) | Tag |
| TagContactRemove | [puppet.TagContactRemoveRequest](#wechaty.puppet.TagContactRemoveRequest) | [puppet.TagContactRemoveResponse](#wechaty.puppet.TagContactRemoveResponse) | |
| TagContactDelete | [puppet.TagContactDeleteRequest](#wechaty.puppet.TagContactDeleteRequest) | [puppet.TagContactDeleteResponse](#wechaty.puppet.TagContactDeleteResponse) | Operate Sub-Collections https://cloud.google.com/apis/design/design_patterns#list_sub-collections |
| TagContactList | [puppet.TagContactListRequest](#wechaty.puppet.TagContactListRequest) | [puppet.TagContactListResponse](#wechaty.puppet.TagContactListResponse) | |





## Scalar Value Types

| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- |
| <a name="double" /> double | | double | double | float | float64 | double | float | Float |
| <a name="float" /> float | | float | float | float | float32 | float | float | Float |
| <a name="int32" /> 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) |
| <a name="int64" /> 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 |
| <a name="uint32" /> uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) |
| <a name="uint64" /> uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) |
| <a name="sint32" /> 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) |
| <a name="sint64" /> 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 |
| <a name="fixed32" /> 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) |
| <a name="fixed64" /> 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 |
| <a name="sfixed32" /> sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="sfixed64" /> sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="bool" /> bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| <a name="string" /> string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| <a name="bytes" /> bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-grpc",
"version": "0.29.38",
"version": "0.29.46",
"description": "gRPC for Wechaty",
"type": "module",
"exports": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"lint": "npm-run-all lint:es lint:ts lint:proto",
"lint:es": "eslint --ignore-pattern fixtures/ \"src/**/*.ts\" \"tests/**/*.ts\" \"examples/**/*.ts\"",
"lint:ts": "tsc --isolatedModules --noEmit",
"lint:proto": "bash -c 'protoc -I third-party -I proto --lint_out=. $(find proto/ -type f -name *.proto)'",
"lint:proto": "bash -c 'protoc -I third-party -I proto --lint_out=sort_imports:. $(find proto/ -type f -name *.proto)'",
"install:protoc": "bash -x scripts/install-protoc.sh",
"test": "npm-run-all lint test:unit test:commonjs",
"test:pack": "bash -x scripts/npm-pack-testing.sh",
Expand Down
8 changes: 4 additions & 4 deletions proto/wechaty/puppet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
syntax = "proto3";
package wechaty;

import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

import "wechaty/puppet/base.proto";
import "wechaty/puppet/contact.proto";
import "wechaty/puppet/event.proto";
import "wechaty/puppet/friendship.proto";
import "wechaty/puppet/message.proto";
import "wechaty/puppet/room.proto";
import "wechaty/puppet/room-invitation.proto";
import "wechaty/puppet/room-member.proto";
import "wechaty/puppet/room.proto";
import "wechaty/puppet/tag.proto";

import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option java_package="io.github.wechaty.grpc";
option go_package="github.com/wechaty/go-grpc/wechaty";

Expand Down
6 changes: 4 additions & 2 deletions proto/wechaty/puppet/friendship.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ message FriendshipSearchWeixinResponse {
message FriendshipAddRequest {
string contact_id = 1;
string hello = 2;
google.protobuf.StringValue source_room_id = 3;
google.protobuf.StringValue source_contact_id = 4;
google.protobuf.StringValue source_room_id_string_value_deprecated = 3 [deprecated = true]; // Deprecated: will be removed after Dec 31, 2022
google.protobuf.StringValue source_contact_id_string_value_deprecated = 4 [deprecated = true]; // Deprecated: will be removed after Dec 31, 2022
string source_room_id = 5;
string source_contact_id = 6;
}

message FriendshipAddResponse {}
Expand Down
Loading

0 comments on commit 9b62e9c

Please sign in to comment.