You can use this tool to implement the conversion of .proto files into custom object typescript files quickly.
Currently, the supported .proto Types are: double, float, int32, int64, uint32, uint64, bool, string, bytes and enum. Nested definitions are not supported.
Every .proto file should contain a NoneObject, As follows:
message NoneObject {
}
- Convert a .proto file into several custom object typescript files.
cyfs-objs-generator -i ./obj_proto.proto -o ./test_out
- To retrieve the tool version.
cyfs-objs-generator --version
- For helps.
cyfs-objs-generator --help
Use protoc to compile .proto files into XX_pb.js and XX_pb.d.ts. It is recommended to use cyfs-dapp-cli to create template projects. The project project already contains protoc programs and quick generation commands. Then, You can use this tool to generate objects .ts files.
syntax = "proto3";
enum ArticleType {
NEWS = 0;
ENTERTAINMENT = 1;
HEALTHY = 2;
HISTORY = 3;
}
message Article {
ArticleType type = 1;
string title = 2;
string content = 3;
bytes authorId = 4;
float rewardAmount = 5;
bool isPassed = 6;
uint64 timestamp = 7;
}
message NoneObject {
}