Add support for byte translation#230
Merged
MOmarMiraj merged 28 commits into1Password:mainfrom Feb 21, 2025
Merged
Conversation
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
hculea
reviewed
Feb 19, 2025
…nctions and update tests
hculea
reviewed
Feb 19, 2025
…instead of struct level
hculea
reviewed
Feb 20, 2025
hculea
reviewed
Feb 20, 2025
…m translation logic more scaleable
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
hculea
reviewed
Feb 21, 2025
…sary diff, and update typescript logic to be more scaleable
hculea
approved these changes
Feb 21, 2025
Member
|
Functionally tested and code reviewed, looks good! Thanks for the contribution here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for translating
Vec<u8>to the appropriate byte translation for Go, Python, and Typescript.To maintain backwards compatibility, decided to opt against adding a
BytesinSpecialRustTypeas there could be some devs translatingVec<u8>into a non byte translation and will be a breaking change.There was two options I was considering when implementing this feature:
This option would allow us to use the existing decorators functionality to parse each specific field to determine whether or not we can translate it to its appropriate byte translation.
The issue with this implementation is it would cause a pretty big refactor as the
format_special_typefunction does not have access to decorators and allowing the function to have access whether passing it as an argument or attaching it to each language struct as a field would be overly complex for achieving not the greatest result.The second option is what this PR does, which is take adavantage of the
type_mappingsfield which allows us to use thetypeshare.tomlto translate theVec<u8>to its appropriate translation in each target language. This way is the least complex and is backwards compatible as the user would have to specify inside thetypeshare.tomlif they want the byte translation otherwise it would keep the current implementation intact.I added some tests in Go, Python, and Typescript to test this out.
With typescript, as there is no native support for
Uint8Arrayfor JSON serialization/deserialization, we have to add thesereviverandreplacerfunctions to not lose context of theUint8Arrayduring serialization/deserialization and the same thing goes for the Python implementation.