Skip to content
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

Add encoding/decoding for Fauna Bytes #260

Merged
merged 8 commits into from
May 10, 2024
Merged

Add encoding/decoding for Fauna Bytes #260

merged 8 commits into from
May 10, 2024

Conversation

ptpaterson
Copy link
Contributor

@ptpaterson ptpaterson commented May 6, 2024

Ticket(s): FE-4855

Problem

Fauna supports a Bytes type which is transmitted as a base-64-encoded string
https://docs.fauna.com/fauna/current/reference/fql_reference/types#bytes

We also had a type issue where JS Date could not be used as a query argument, so I added Date to arg type as well as a test.

Solution

Add encoding and decoding of the Bytes type

Result

ArrayBuffers and Uint8Array (as well as Node's Buffer since that extends Uint8Array) classes are encoded to Fauna Bytes. Attempting to encode any other TypedArray results in an error.

Fauna Bytes are decoded into Uint8Array, which can be used to create the desired type.

See tests for examples.

Out of scope

N/A

Testing

Added unit and integration tests.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ptpaterson ptpaterson requested review from freels and cleve-fauna May 6, 2024 20:16
@ptpaterson ptpaterson requested a review from cleve-fauna May 8, 2024 16:59
Copy link
Member

@freels freels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take it with a grain of salt, but LGTM

lol

@ptpaterson ptpaterson merged commit 5c503ee into beta May 10, 2024
5 checks passed
@ptpaterson ptpaterson deleted the bytes branch May 10, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants