Commit Graph

20 Commits

Author SHA1 Message Date
Lance Ball f3953a9a5a
feat: introduce Message, Serializer, Deserializer and Binding interfaces (#324)
* lib(messages): Implement a 4.0 Messages and other supporting interfaces

This commit introduces the Message, Serializer and Deserializer, and Binding
interfaces used to convert a CloudEvent into a Message that can be sent across
a transport protocol. The first protocol implemented for this is HTTP, and some
of the functionality formerly in src/transport/http has been simplified,
reduced and/or moved to /src/messages/http.

Test for V1 and V3 events are in place. Conformance tests have been modified to use
these new interfaces vs. the HTTP Receiver class.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-08-26 18:26:50 -04:00
Grant Timmerman d590e3a007
docs: improve readme receiver example (#309)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-08-11 09:31:05 -04:00
Lucas Holmquist 763838c89c
chore: Update examples to use latest sdk changes (#282)
* This updates all the examples to use the latest module version(3.0.0)


Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-30 09:24:02 -04:00
Lance Ball 276b810dd8
BREAKING CHANGE(lib): rewrite in TypeScript (#226)
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 <lball@redhat.com>
2020-06-29 14:46:20 -04:00
Lucas Holmquist dcb3c4e98a
chore: Update examples to use the latest sdk version(2.0.2) (#206)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-06-09 18:08:15 -04:00
Lance Ball a5befbe0cf
fix: introduce CloudEventV1 and CloudEventV03 interfaces (#194)
This extracts all of the attributes from a `CloudEventVX` that
are not generated by the constructor (id and specversion) into their
own `CloudEventVXAttributes` interface which the `CloudEventVX`
interface extends. This allows TS devs to optionally provide `id`
and `specversion` with proper autocompletion.

Additionally, I have added a union type, `CE` in `cloudevent.ts` which
represents any of `CloudEventV1`, `CloudEventv03`, `CloudEventV1Attributes`
and `CloudEventV03Attributes` interfaces.

Finally, this commit changes all of the user facing API to be `.ts` instead
of `.js` files.

The existing documentation in `./docs` was removed. It should be replaced with generated
HTML from tsdocs, pending some other method of publishing API documentation. That will
come as a separate, docs-only PR.

Fixes: https://github.com/cloudevents/skd-javascript/issues/188

Signed-off-by: Lance Ball <lball@redhat.com>
2020-05-29 17:49:02 -04:00
Lance Ball b866edddd9
docs: update README and examples with new API (#138)
This commit modifies the README to show new API usage for the
`HTTPReceiver` and `CloudEvent` classes, and updates the examples
to use this as well.

Overall structure and content has been modified to look more like
the sdk-go README.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/128

Signed-off-by: Lance Ball <lball@redhat.com>
2020-05-11 09:41:05 -04:00
Lance Ball 5110ad4c67 src,fix: drop support for v0.2 and clean up contenttype
This commit removes support for the v0.2 specification. It also removes the
`contenttype` attribute from the `CloudEvent` object. While the HTTP protocol
binding specifies that in binary mode, the `datacontenttype` attribute should
map to the HTTP Content-Type header, that doesn't mean that the `CloudEvent`
object should have a `contenttype` property.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/61
Fixes: https://github.com/cloudevents/sdk-javascript/issues/66

Signed-off-by: Lance Ball <lball@redhat.com>
2020-04-28 17:37:49 -03:00
Lance Ball 3f238a0124
src: add eslint configuration and npm script
Automatically fixed > 2000 issues. The remaining 200+ issues need
to be fixed by hand. Additionally, all strings are double quotes
which is not typically standard and I wonder about fixing that too.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-04-22 10:15:05 -04:00
Fabio José 36d61f190e Express examples with Spev 1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:21:53 -03:00
Fabio José c8675ca103 Fix the unmashaller import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:25 -03:00
Fabio José a9dc14f617 Expose the /v02 for spec 0.2 and /v03 for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:21:57 -03:00
Fabio José 10fbc1df7a Import the new way of require specifications
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-05 15:11:39 -03:00
Fabio José 852cad0832 Fix the examples and use the same names
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 12:08:04 -03:00
Fabio José e1b04bdcdb Change to use promise
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 12:05:02 -03:00
Fabio José b39a32152f Double quotes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:02:14 -03:00
Fabio José 6c5b7e2c86 When incorrect, reply the errors too
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 10:54:39 -03:00
Fabio José 5baa52dd2b Fix example body read
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:43:25 -03:00
Fabio José d21881a2b5 WIP: example with expressjs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-16 21:10:26 -03:00
Fabio José 9b98aad083 Examples folder start with expressjs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-16 21:05:10 -03:00