Commit Graph

667 Commits

Author SHA1 Message Date
github-actions[bot] 97cf2f7785
chore: release 4.0.0 (#368)
* chore: release 4.0.0

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lucas Holmquist <lholmqui@redhat.com>
2020-12-11 14:28:02 -05:00
dependabot[bot] d656362cd9
build(deps): bump highlight.js from 10.3.2 to 10.4.1 (#372)
Bumps [highlight.js](https://github.com/highlightjs/highlight.js) from 10.3.2 to 10.4.1.
- [Release notes](https://github.com/highlightjs/highlight.js/releases)
- [Changelog](https://github.com/highlightjs/highlight.js/blob/master/CHANGES.md)
- [Commits](https://github.com/highlightjs/highlight.js/compare/10.3.2...10.4.1)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-07 11:22:38 -05:00
Lucas Holmquist 79296a8e63
chore: add a transition guide. fixes #360 (#363)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-12-07 11:21:30 -05:00
Lance Ball 9f86cfdf0e fix: improve error messages when validating extensions
This commit changes the messages produced when validating extension names and
values, including the offending name or value in the message, and including
text from the CloudEvent specification, or a link to the type system.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-11-30 17:38:49 -05:00
snyk-bot 132f052f1f fix: package.json & package-lock.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-Y18N-1021887

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-11-25 11:31:12 -05:00
Remi Cattiau 6adb578402 ci: disable @typescript-eslint/no-explicit-any linter rule
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2020-11-17 08:41:16 -05:00
Remi Cattiau 43d9e01972 feat: allow ensureDelivery to be able to ensure delivery on emit
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2020-11-17 08:41:16 -05:00
Remi Cattiau d418a50c56 ci: add unit test for emitter
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2020-11-17 08:41:16 -05:00
Remi Cattiau bda8581464 docs: add Emitter logic example
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2020-11-17 08:41:16 -05:00
Remi Cattiau 25f9c48601 feat: add EventEmitter to Emitter and singleton paradigm
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2020-11-17 08:41:16 -05:00
Lucas Holmquist 875f70017a
feat!: Remove All API's that are labeled "Remove in 4.0" (#362)
* feat!: remove all 4.0 deprecation.

* This removes all the APIs that were deprecated in the 3.x releases and marked as "remove in 4.0".

* Also removes any tests associated with those API's

* squash: remove axios as a dependecy


Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-11-13 14:12:26 -05:00
Snyk bot 8205bc96ae
chore(package): Upgrade mocha from 7.1.2 to 8.2.0 (#354)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-FLAT-596927

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-10-26 12:16:44 -04:00
Lance Ball 765b81cdec
chore: tag v3.2.0 as release-v3.2.0 for release-please (#353)
Signed-off-by: Lance Ball <lball@redhat.com>
2020-10-15 21:02:08 -04:00
Lance Ball c4afacbad3
chore(ci,releases): bump release-please-action to 2.5.5 (#350)
This should hopefully resolve the problem we are seeing with too many
commits included in the changelog.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-10-13 11:12:23 -04:00
Lance Ball f6be285b83
fix: extend Node.js IncomingHttpHeaders in our Headers type (#346)
This commit extends Node.js IncomingHttpHeaders in our Headers type.
Changes the Headers type to make it more compatible with Node.js TypeScript projects.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-10-06 15:50:33 -04:00
Lance Ball 14468980f7
fix: do not alter an event's data attribute (#344)
* fix: do not alter an event's data attribute

When setting an event's data attribute we were trying to be really clever
and this is problematic. Instead, keep the data attribute unchanged. Per
the 1.0 specification, the data attribute is still inspected to determine
if it is binary, and if so, a data_base64 attribute is added with the
contents of the data property encoded as base64.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-10-06 08:20:54 -04:00
Lance Ball 138de37084
docs: update README with latest API changes (#347)
Signed-off-by: Lance Ball <lball@redhat.com>
2020-10-01 15:12:19 -04:00
Lucas Holmquist 76688c4c01
chore: update release please to the latest release(2.4.1) (#345)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-10-01 11:42:21 -04:00
Lance Ball e334b6eceb
feat: add emitterFactory and friends (#342)
* feat: add emitterFactory and friends

This commit adds an emitterFactory function that returns an EmitterFunction
object. The EmitterFunction may be used to emit events over a supported
network transport layer. Currently, only HTTP is supported.

Parameters provided to the emitterFactory are the transport Binding (only
HTTP supported), the encoding mode (Mode.BINARY or Mode.STRUCTURED), and
a TransportFunction.

The implementation for emitBinary and emitStructured has been replaced
with this simple pattern and those two functions have been removed.

Example:

```js
// The endpoint URL that will receive the event
const sink = 'https://my-event-sink';

// A function that uses Axios to send a message over HTTP
function axiosEmitter(message: Message, options?: Options): Promise<unknown> {
  return axios.post(sink, message.body, { headers: message.headers, ...options });
}

// Create an event emitter
const emit = emitterFactory(HTTP, Mode.BINARY, axiosEmitter);

// Emit an event, sending it to the endpoint URL
emit(new CloudEvent{ source: '/example', type: 'example' });
```

Signed-off-by: Lance Ball <lball@redhat.com>
2020-09-25 17:25:15 -04:00
Lucas Holmquist a9114b7123
chore: add an automated GH action for releases (#329)
This commits adds the release-please github action to automate the creation of release PR's

This is only for creating GH releases and they automation of publication to npm will come in the future


Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-09-17 14:03:48 -04:00
Snyk bot eca43d9074
fix: package.json & package-lock.json to reduce vulnerabilities (#338)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-DOTPROP-543489
- https://snyk.io/vuln/SNYK-JS-MARKED-584281

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-09-09 09:46:13 -04:00
Lance Ball 0a12146565
docs: update README with maintainer names (#337)
This commit changes the README to include all currently active contributors

Signed-off-by: Lance Ball <lball@redhat.com>
2020-09-09 09:45:47 -04:00
Lance Ball 1fa3a05aed
feat: add a constructor parameter for loose validation (#328)
* feat: add a constructor parameter for loose validation

This commit adds a second, optional boolean parameter to the `CloudEvent`
constructor. When `false` is provided, the event constructor will not
perform validation of the event properties, values and extension names.

This commit also modifies the ValidationError class so that the error message
string includes the JSON.stringified version of any schema validation
errors. It also makes the HTTP.toEvent() function create CloudEvent
objects with loose/no validation.

Incorporates comments from https://github.com/cloudevents/sdk-javascript/pull/328

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-09-08 15:32:16 -04:00
Lucas Holmquist 7423acb7fc
fix: upgrade cloudevents from 3.0.1 to 3.1.0 (#335)
Snyk has created this PR to upgrade cloudevents from 3.0.1 to 3.1.0.

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

See this project in Snyk:
https://app.snyk.io/org/lance/project/cb2960b0-db0c-4e77-9ab2-e78efded812e?utm_source=github&utm_medium=upgrade-pr

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-09-03 14:52:50 -04:00
Philip Hayes 4779d89ad0
chore(example): Replaced body parser with express JSON parser (#334)
Signed-off-by: Philip Hayes <phayes@redhat.com>

Co-authored-by: Philip Hayes <phayes@redhat.com>
2020-09-02 17:09:53 -04:00
Lance Ball 6cd310c141
src(event)!: make the event's time property only a string (#330)
Previously, the event's `time` property could be either a string or a date.
this commit modifies that to ensure that the object can only be created with
a timestamp in string format. As long as the string is a valid date, that
can be parsed by `new Date(Date.parse(str))` then whenever the event is
serialized as JSON, the `time` attribute will be formatted as per RFC 3339.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2020-09-01 10:10:16 -04:00
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