-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support for Google.Protobuf.Value, ListValue and Struct #396
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@boukeversteegh this is great!
I think the CI build will fail b/c you didn't include the generated code for the struct
test in the PR (it's a little odd, but checking in the generated code is a nice way to see in the diffs "did I unintentionally change the codegen output?").
And maybe throw in an update to the readme somewhere to advertise the well-known types we support, but otherwise looks great! Thanks!
:-) Alright! Should I also include the .bins, or just the .ts files? The bin files are all changed... I ran update-bins on windows, using
edit: obviously i will include the bin files for the new tests |
@boukeversteegh yeah, just the new bins would be great. The whole |
@stephenh ok, no problem. I saw the discussion in another thread. Then does this mean that the I am also interested in dockerizing protoc for my own project. I'll share my solution once I have it. |
It is stable for a given platform + version of And, really, even the version changes are "real" differences, i.e. new versions of So, that's really it, I think just slightly different versions of comments across If you hash
Thanks! That'd be great. |
Ah, I see. Then this is more about the stability of the ProtoMessageDescriptors, and not about how proto messages themselves are encoded in binary. It makes sense that this would change from time to time yes, but between platforms is a bit surprising, considering they should be the same implementation. Just fixed the remaining build errors. I will update the readme in a bit. |
Hi there! I think I'm done for now. I still see possible improvements but I will keep them for another PR (moving the generated unwrapping-util functions to inside Value, ListValue, and Struct, so that they are not generated in multiple files) LGTM? |
@boukeversteegh yep, lgtm, the readme updates look amazing, thank you! |
# [1.88.0](v1.87.1...v1.88.0) (2021-11-22) ### Features * Support for Google.Protobuf.Value, ListValue and Struct ([#396](#396)) ([7dd9c16](7dd9c16))
🎉 This PR is included in version 1.88.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Awesome, thank you for the swift action! |
Summary
Dear friends of TsProto,
I've worked the last two days to built an implementation to support some important remaining well known types.
Tests are included that demonstrate it is working.
Benefits
If you are using ts-proto with another server or client that supports Google's Well Known Types, it may send you lists such as
[1, true, "hello"]
, using theListValue
type. Currently, ts-proto will generate a complex object structure for such a type, and will fail while trying to extract the data from the simplified list.With this PR, you can now read the implicitly converted JSON objects sent by your server, or client with WKT support, and write them back as well, both in binary or JSON.
Added Well Known Values:
Value
— translates toany
in Typescript.ListValue
— translates toany[]
in Typescript.Struct
— translates to{[key: string]: any}
in Typescript.Usable areas:
repeated
map<_, WellKnownValue>
Features:
encoding
/decoding
to binary, the structure is re-converted to/from the Protobuf well-known type.fromJSON
andtoJSON
don't do any real conversion, because the Typescript data format is essentially already in JSON-compatible formatUsage example:
Not included:
map<WellKnownValue, _>
is not implemented in this PR.{"stringValue": "hello world"}
instead of"hello world"
, you would actually get the entire object where you would have expected a string.Fixes #336