Commit Graph

641 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
Lance Ball 17d4bc85df
chore: add cucumber.js to list of files to lint and /docs to .gitignore (#327)
Signed-off-by: Lance Ball <lball@redhat.com>
2020-08-25 16:38:17 -04:00
Lucas Holmquist 73f0becc2b
chore: Update README with correct links for the support specification versions (#321)
* chore(readme): Remove reference of HTTPReceiver

* chore(readme): fix support specification links.

* This adds the real links to the v0.3 and v1.0 specification.

fixes #320

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-19 15:39:37 -04:00
Lucas Holmquist 0adcc3532d
chore: Remove commented version import. (#319)
* The commented out version import now gets imported from the cloudevent.ts file

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-19 05:38:33 -04:00
Snyk bot 6e2390ed6b fix: upgrade uuid from 8.2.0 to 8.3.0 (#317)
Snyk has created this PR to upgrade uuid from 8.2.0 to 8.3.0.

See this package in npm:
https://www.npmjs.com/package/uuid

See this project in Snyk:
https://app.snyk.io/org/lance/project/37afc620-45ad-41a3-9acc-1ac155caebc7?utm_source=github&utm_medium=upgrade-pr

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-18 18:50:51 -04:00
Lucas Holmquist 4bf2eb838a
chore: Update references of master to main (#316)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-12 19:00:02 -04:00
Lance Ball b5cf8865b9
test: implement pending tests leftover from TS rewrite (#315)
This commit implements 4 of the 6 pending tests that were not completed
during the TypeScript rewrite. The two tests that were not implemented
were (one for each of v1 and v03):

```
it("returns a JSON string even if format is invalid");
```

I don't really know what that's supposed to be/mean, so I removed them.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-08-12 16:49:21 -04:00
Grant Timmerman 8ac3eb0c69
refactor: validate cloudevent version agnostic (#311)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-08-11 10:08:55 -05:00
Doug Davis 81623ac443
chore: typo (#313)
Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-08-11 11:01:40 -04:00
Doug Davis b3624c2b1a
docs: add ref to CoC and other things (#244)
* add ref to CoC and other things

Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-08-11 10:18:47 -04:00
Lucas Holmquist 1cdf0f684b "chore(release): 3.1.0"
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-11 09:34:19 -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 08bf15d161
docs: Release Guidelines (#306)
* This adds a guide on how to do releases 

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-11 09:25:08 -04:00
Lucas Holmquist f3cc2b429b
chore: update the release script to signoff the commit (#307)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-11 09:23:29 -04:00
Lucas Holmquist a5249de487
chore: fix promise tests to break the build when they fail (#305)
* squash: return the promise that is being tested

fixes #303 

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-07 09:00:49 -04:00
Lucas Holmquist ad0c4340b2
fix: Add Correct Headers to emitted Binary Event (#302)
* fix: Binary emitter should add a basic application/json header.

fixes #301

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-06 10:36:53 -04:00
Lucas Holmquist a7e0aa07ac
lib: expose constants in a more intuitive way (#299)
* Constants can now be accessed more easily from the top level import/require

users can now do `const { CONSTANTS } = require('cloudevents')`

fixes #298

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-08-04 09:42:28 -04:00
dependabot[bot] bc81242c7c
build(deps): bump elliptic from 6.5.2 to 6.5.3 (#290)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-03 14:33:35 -04:00
Grant Timmerman 31c200592f
refactor: no import star (#297)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-31 13:21:19 -07:00
Lucas Holmquist 48d182bc5f
fix: update browser name to cloudevents. (#292)
* This updates the broswer based version to cloudevents instead of cloudevents-sdk.

Fixes: #286

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-30 13:55:57 -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
Grant Timmerman 3fab5f2c92
docs: update badge name (#289)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-30 08:43:51 -04:00
Lance Ball ed9ea956d7
fix: ensure that data encoded as base64 is parsed as an object (#285)
The 0.3 specification states that `datacontentencoding` may be set to base64.
If an incoming event arrives over HTTP with this value set, and the content type
is either application/json or application/cloudevents+json, then ensure that
the data is decoded and parsed.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/284
See: https://github.com/cloudevents/sdk-javascript/pull/282


Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-30 08:39:47 -04:00
Lucas Holmquist e219a30708
chore: Update readme with correct Receiver usage (#287)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-29 18:48:14 -04:00
Lance Ball 07e0bef696
"chore(release): 3.0.1" 2020-07-29 08:50:26 -04:00
Lance Ball b99f728190
fix: ensure that event data can be an array, number, boolean or null (#281)
The schema incorrectly limits data values to only object and string. This is
incorrect, since JSON can be an array, boolean, a single number or null as well.

This commit modifies the schema to allow for array, boolean and null, and adds
tests.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-29 08:35:23 -04:00
Lucas Holmquist c76dda6d10
chore: move typedoc them to a dev dependency. (#279)
fixes #278

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-28 15:04:43 -04:00
Lance Ball 4a371b34de
"chore(release): 3.0.0" 2020-07-27 14:46:48 -04:00
Lance Ball a86cedcafa
lib: remove unused event creation functions (#277)
This commit removes two functions that are not used.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-27 14:06:33 -04:00
Grant Timmerman 3d82fb6291
refactor: simplify ce version parsers (#274)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-27 10:25:11 -07:00
Lucas Holmquist 3c8273f114
lib: validate extension values (#251)
BREAKING CHANGE:

This validates the value of the cloud event extension based on the spec, 
https://github.com/cloudevents/spec/blob/master/spec.md#type-system

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-27 13:19:09 -04:00
Grant Timmerman 129ec485d9
refactor: combine v03 and v1 event interfaces, specs and schemas into single files(#270)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-24 15:35:18 -04:00
Grant Timmerman 45850e329a
chore: consolidate HTTP parsers and header maps into single files (#267)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-24 15:10:51 -04:00
Lance Ball 1613595a38
chore: add vscode task JSON and GitHub issue/pr templates (#268)
This commit adds templates for GitHub issues and PRs, and a configuration
file for VSCode to enable build and test tasks in the IDE.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-24 15:10:03 -04:00
Grant Timmerman a6124cc350
refactor: simplify parser logic and duplicated code (#269)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-24 15:08:52 -04:00
Lance Ball 9ae32c76cb
lib: change Receiver#accept() to be static Receiver.accept (#271)
Note that I did not add a third `Protocol` parameter to `Receiver.accept` since
that would not currently be used. It's non-breaking to add a third parameter
in the future once additional protocols are supported.

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

BREAKING CHANGE

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-24 15:07:46 -04:00
Grant Timmerman 565f867424
feat: use npm name cloudevents (#260)
BREAKING CHANGE:  This changes the modules name from cloudevents-sdk to cloudevents

* feat: use npm name cloudevents
fixes #215

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-24 10:04:25 -04:00
Grant Timmerman 4b54b272a5
feat: simplify validation logic/imports (#265)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-23 16:09:07 -07:00
Grant Timmerman 4014da26f5
feat: remove unused plugins (#262)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-07-23 15:43:02 -07:00
Lance Ball a7c326b48c fix: do not require an HTTP body on incoming binary event messages
This commit modifies the HTTP receivers/parsers to allow for the incoming body
of an HTTP request to be empty if the event message is sent using the binary
mode. In structured mode, a `ValidationError` will still be thrown, since the
entire event must be encoded in the HTTP body.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-23 14:22:14 -04:00
dependabot[bot] d866691e29
build(deps): bump lodash from 4.17.15 to 4.17.19 (#254)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-23 10:19:33 -04:00
Sidharth Vinod cfde6d50f8
Add Copyright Date and Holder name (#257)
* Add Copyright Date and Holder name

Signed-off-by: Sidharth Vinod <sidharthv96@gmail.com>
2020-07-21 10:06:01 -04:00
Snyk bot 2ed5f84457
fix: package.json & package-lock.json to reduce vulnerabilities (#253)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AJV-584908

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-21 09:22:50 -04:00
Lance Ball c49693189d
docs: clean up spec compliance table on README.md (#252)
This commit separates the spec compliance table in the README.md file
into three: the core spec, event formats, and transport protocols.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/166
Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-16 17:45:03 -04:00
Lucas Holmquist 84f1ed9cfe
feat(src): add ext name validation (#246)
BREAKING CHANGE:

* Extension names are now validated during object creation.  The values are defined by the specification, and can be lowercase(a-z) or digits(0-9) and must be no longer that 20 characters

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-15 09:53:52 -04:00
Lucas Holmquist de6f0a2945
docs(README): Update readme to mention that CloudEvents are read-only now (#248)
* also update readme with a mention about the cloneWith method

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-15 09:50:46 -04:00
Snyk bot 13bcdb4b98
fix: upgrade uuid from 8.1.0 to 8.2.0 (#250)
Snyk has created this PR to upgrade uuid from 8.1.0 to 8.2.0.

See this package in NPM:
https://www.npmjs.com/package/uuid

See this project in Snyk:
https://app.snyk.io/org/lance/project/37afc620-45ad-41a3-9acc-1ac155caebc7?utm_source=github&utm_medium=upgrade-pr

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-15 09:45:38 -04:00
dependabot[bot] 8e79fdcfed
build(deps-dev): bump standard-version from 7.1.0 to 8.0.1 (#247)
Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 7.1.0 to 8.0.1.
- [Release notes](https://github.com/conventional-changelog/standard-version/releases)
- [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md)
- [Commits](https://github.com/conventional-changelog/standard-version/compare/v7.1.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 16:45:23 -04:00
Lucas Holmquist c7a84772d5
feat(src): A CloudEvent should be readonly but provide a way to augment itself. (#234)
BREAKING CHANGE:

* This change makes the CloudEvent Read-only and validates the input during object creation.

* To augment an already created CloudEvent object, we have added a `cloneWith` method that takes attributes to add/update.

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-13 15:15:32 -04:00
Lance Ball dca2811627
test: inplement the cucumber conformance tests from cloudevents/spec (#238)
This commit adds cucumber-js conformance steps and includes the cucumber
tests in 'npm test'.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-07-13 09:47:02 -04:00