Commit Graph

44 Commits

Author SHA1 Message Date
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
Lance Ball 99bb88be00
examples: add a WebSocket example (#218)
There is nothing really to do in order to support events over websockets.
Since a `CloudEvent` can easily be represented in full with JSON, it can
be sent over a websocket as `event.toString()`. This example illustrates
sending a `CloudEvent` over websocket from a browser or CLI.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/156
Signed-off-by: Lance Ball <lball@redhat.com>
2020-06-10 17:50:35 -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
Lucas Holmquist ed1d3286fa
docs: Update references of specific versions to use Latest Supported. (#211)
* docs: Update references of specific versions to use Latest Supported.

fixes #160

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-06-08 15:47:30 -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
Grant Timmerman 05ecbdea4f
feat: use CloudEvents not cloudevents everywhere (#101)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-04-30 16:14:13 -07:00
Helio Frota bb8e0f9e0c
fix: Fix Express example installation (#77)
Signed-off-by: Helio Frota <00hf11@gmail.com>
2020-04-29 10:44:02 -07: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é a7e8354d56 Set the version of sdk to 1.0.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:22:04 -03: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é 03f8796b3f Examples of payload using spec 1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:20:41 -03:00
Fabio José c35af5b66e Fix link to requestbin
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-04 10:00:30 -03:00
Fabio José 807d60462b ts Example using binary receiver
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-04 09:54:16 -03:00
Fabio José 0d8c8a13ae ts example with binary emitter
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-29 21:43:21 -03:00
Fabio José b4b04963b9 Typescript examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-29 20:49:54 -03:00
Fabio José 06927a9fac Lock of package for examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-07 12:37:03 -03:00
Fabio José 83adbf1ee0 Fix reference to cloudevents-sdk
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-07 12:36:23 -03:00
Fabio José 7bdd116b1f Add line feed
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:50 -03:00
Fabio José 2cdbbc9d98 Node package lock of examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:35 -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é 2b48302bad Node package lock of examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:05:56 -03:00
Fabio José 762f77ce0b Base 64 data example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:22:56 -03:00
Fabio José 6f2cbd61e4 Document example for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:22:27 -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é d38c857c03 Identify the example payload
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:21:24 -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é e602736c20 Spec v0.3 examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-05 15:10:50 -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é c7341baf96 Example for structured with extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:08:09 -03:00
Fabio José 1497934bed Example of payload with extenstion
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:07:56 -03:00
Fabio José b12c6d75d4 fix type, ex with extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:05:00 -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é 99310d1920 Fix binary example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:48:08 -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é 365e0871b7 Fix binary data attribute example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:42:55 -03:00
Fabio José a2ae5b9231 Express example doc
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 10:55:28 -03:00
Fabio José 951008d797 Temporary ref to dep from git
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 09:08:11 -03:00
Fabio José abdcf0f9f0 CloudEvent payloads examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 09:05:37 -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