-
Notifications
You must be signed in to change notification settings - Fork 70
lib: rewrite in TypeScript #226
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
Conversation
I noticed a |
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.
This is great!
I added a few comments, but this is definitely an improvement. I understand there can be a lot of feature creep with the PR, so I hope my comments don't try to nit at the things we can fix in the future.
src/transport/protocols.ts
Outdated
@@ -0,0 +1 @@ | |||
export const enum Protocol { HTTPBinary, HTTPStructured, HTTP }; |
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.
For small files like these, it might be worth it to inline it rather than have a new file.
For example, we can inline the contents into the index.ts
file.
@lholmquist good catch! That's actually a bug on master. 🐛 |
This is a major rewrite of the entire codebase into TypeScript. Nearly all tests have been retained except where behavior is significantly different. Some highlights of these changes: * lowercase all CloudEvent properties and fix base64 encoded data Previously there was a format() function that would convert a CloudEvent object into JSON with all of the properties lowercased. With this rewrite a CloudEvent object can be converted to JSON simply with JSON.stringify(). However, in order to be compliant with the JSON representation outlined in the spec here https://github.com/cloudevents/spec/blob/v1.0/json-format.md all of the event properties must be all lowercase. * lib(transport): make transport mode an Enum * src: allow custom headers (#1) * lib(exports): export explicitly versioned names where appropriate * lib(cloudevent): modify ctor to accept extensions inline * lib(cloudevent): make extensions a part of the event object * test: convert all tests to typescript * examples: update all examples with latest API changes * docs: update README with latest API changes * src: add prettier for code style and fix a lot of linting errors * lib: move data decoding to occur within the CloudEvent object Signed-off-by: Lance Ball <[email protected]>
@cloudevents/sdk-javascript-maintainers I have completed all of the items on the checklist and addressed about 95% of the comments/nits. Please have a look. This is ready for final review and landing. |
Signed-off-by: Lance Ball <[email protected]>
Signed-off-by: Lance Ball <[email protected]>
const properties = { ...event }; | ||
|
||
this.id = (properties.id as string) || uuidv4(); | ||
delete properties.id; |
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.
These deletions seem unnecessary and do not affect the logic of the function. Do we really need to delete them? The whole properties
const is only scoped for this block and will be deleted at the end of the block naturally.
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.
As noted in the comment above, it is necessary to delete them if we want to have extensions as siblings of the event properties. We remove all of the known properties, and what's left are the extensions.
Looks good! 👍 A few comments. |
Signed-off-by: Lance Ball <[email protected]>
Signed-off-by: Lance Ball <[email protected]>
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.
Looks good.
The only thing is that the examples won't work until we do a release and update the version there. But overall, LGTM!
Deep breaths.... landing this. |
This is a major rewrite of the entire codebase into TypeScript. Where the code was overly complex, I have attempted to simplify things. A few things remain before it can land.
/examples
to work with the new APICloudEvent#extensions
and how they are mapped to https://github.com/cloudevents/spec/blob/v1.0/json-format.mdSome notes about the changes...
./dist
lib
folder has been removed and everything under it was pulled up intosrc
lib/bindings
folder has been moved tosrc/transport
Fixes: #223
Fixes: #219
Fixes: #203
Fixes: #195
Signed-off-by: Lance Ball [email protected]