Commit Graph

691 Commits

Author SHA1 Message Date
github-actions[bot] 1fe4f5b62a
chore: release 4.0.2 (#396)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-23 12:21:46 -04:00
Lance Ball 66f0b42f0d
chore: update codacy badges (#409)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-21 17:13:05 -04:00
Lance Ball a0009f6189
chore: remove @types/axios and add axios in dev (#408)
This commit removes @types/axios from the devDependencies and replaces
it with straight up axios. The @types package is deprecated and has not
been updated in four years. Plus it was raising a security alert. Plus
axios publishes their own types now.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-21 10:13:10 -04:00
Lance Ball 26ceb908db
chore: tweak PR template (#407)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-21 10:12:44 -04:00
Lance Ball 192c6a3a5c
chore: externalize remark-lint config (#406)
This way Codacy will use our configuration instead of its own.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-21 10:12:31 -04:00
Lance Ball fea5ac2d05
chore: add markdown linter (#403)
Also fixes a few minor linting issues from CHANGELOG.md.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-20 11:53:23 -04:00
Lance Ball cc43f3bd10
chore: update CI workflow to include Node.js 14.x (#404)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-20 11:46:38 -04:00
Lance Ball edd3c7fbac
chore: remove standard-version (#402)
Now that we are using release-please, this is not necessary.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-16 15:08:14 -04:00
Lance Ball d10fee05ba
doc: fix README.md coverage/quality badge links (#401)
For some reason they had never been changed from @fabiojose

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-15 18:49:10 -04:00
Snyk bot d3593556f1
fix: examples/typescript-ex/package.json to reduce vulnerabilities (#395)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-HOSTEDGITINFO-1088355

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-06 10:58:06 -04:00
dependabot[bot] 643c914da8
build(deps): bump y18n from 4.0.0 to 4.0.1 (#397)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 09:48:02 -04:00
Lance Ball 0f11b02a01
fix: defaults properly handled for emitterFor() (#399)
* fix: defaults properly handled for emitterFor()

Fixes: https://github.com/cloudevents/sdk-javascript/issues/391
2021-04-05 13:14:04 -04:00
Lance Ball 447252e0c7
docs: fix 'npm run generate-docs' (#398)
Fixes: https://github.com/cloudevents/sdk-javascript/issues/392

This commit also removes the external doc theme, since the new version
generates decent looking docs.

After this lands, docs should be published.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-05 10:18:59 -04:00
Lance Ball efe466ac7d
fix: ensure loose validation for isEvent and toEvent (#394)
The `HTTP.isEvent()` and `HTTP.toEvent()` functions both had some validation
code that violated the principle of loose validation when receiving an
event over HTTP. As discussed, the validation should be managed by the
receiver in this case with `event.validate()`

Signed-off-by: Lance Ball <lball@redhat.com>
2021-03-25 12:37:05 -04:00
github-actions[bot] 93f02130f6
chore: release 4.0.1 (#378)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-23 11:55:26 -04:00
Lance Ball 39812f77d0
fix: package.json & package-lock.json to reduce vulnerabilities (#384)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-MARKED-1070800

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

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
2021-03-08 18:32:41 -05:00
Lance Ball e7d99eb882
test: add a test for extension names with all caps. (#389)
See: https://github.com/cloudevents/sdk-javascript/issues/380

Signed-off-by: Lance Ball <lball@redhat.com>
2021-03-08 16:07:24 -05:00
Lance Ball b006b90122 fixup: incorporate review comments
Signed-off-by: Lance Ball <lball@redhat.com>
2021-02-27 19:27:20 -05:00
Lance Ball 1af3d43341 fix: Emitter should not extend EventEmitter
This change modifies Emitter so that it does not directly extend the Node.js
EventEmitter class. Instead, it holds a singleton instance of an EventEmitter
but is not an instance of EventEmitter itself.

This commit also updates the typescript example to use a modern version of
@types/node and typescript.

Finally there are a few minor formatting changes picked up by eslint.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-02-27 19:27:20 -05:00
Snyk bot 6be3b27514
fix: cloudevents from 3.2.0 to 4.0.0 (#376)
* fix: examples/express-ex/package.json to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1038255

* fix(examples): remove the body-parser module.

* When a structured formatted CloudEvent comes in, the body parser module does know how to parse it since the content type is not application/json, which resulted in an empty request body

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

Co-authored-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 13:46:21 -05:00
Snyk bot f8514062d4
[Snyk] Security upgrade cloudevents from 3.1.0 to 4.0.0 (#377)
* fix: examples/typescript-ex/package.json to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1038255

* chore: update example to use the 4.0 API

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

Co-authored-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 09:55:37 -05:00
Snyk bot 2b1e1ec5a2
fix: examples/websocket/package.json to reduce vulnerabilities (#375)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1038255

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 09:44:31 -05:00
dependabot[bot] 8243fa10f1
build(deps): bump ini from 1.3.5 to 1.3.7 (#373)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-04 11:03:27 -05:00
Ali Ok ed8148326b
chore(docs): Fix minor import problems in README (#374)
Signed-off-by: Ali Ok <aliok@redhat.com>
2021-01-04 11:02:53 -05:00
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