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

fix: Make CloudEvent data field immutable and enumerable #516

Merged
merged 1 commit into from Nov 1, 2022

Conversation

PSanetra
Copy link
Contributor

Proposed Changes

  • CloudEvent class:
    • Make data field immutable like the other fields in the class
    • Make data field enumerable via Object.keys() and Object.entries()
    • toJSON() does not return a data field anymore if data_base64 is set to comply with the JSON format spec 3.1.1 Out of this follows that the presence of the data and data_base64 members is mutually exclusive in a JSON serialized CloudEvent.

Fixes #515

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

@PSanetra thanks for this contribution! The atob function does not exist in Node.js LTS prior to version 16. Could you please add atob to dependencies and @types/atob to the dev-dependencies section, and add an import statement in validation.ts? This should get CI passing.

….keys() (cloudevents#515)

Signed-off-by: Philip Sanetra <code@psanetra.de>
@PSanetra
Copy link
Contributor Author

PSanetra commented Nov 1, 2022

@lance I have changed the code to support node.js runtime and browser runtime without a additional dependency.

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Great addition. Thank you.

@lance lance merged commit 2d5fab1 into cloudevents:main Nov 1, 2022
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.

Avoid jest#13535 and planttheidea/fast-equals#91
3 participants