Commit Graph

777 Commits

Author SHA1 Message Date
Lance Ball 2ac731eb88
chore(refactor): prefer interfaces over concrete classes (#457)
* chore(refactor): protocol bindings use interfaces

This change modifies the protocol binding interfaces such as `Binding`,
`Serializer` and the like to use the `CloudEventV1` interface instead of the
implementation class `CloudEvent`. This should make extending the interfaces
simpler as this work has grown out of efforts around the implementation of
a second transport interface, Kafka.

See: https://github.com/cloudevents/sdk-javascript/pull/455/

This commit also includes the addition of a generic type to the `Message`
interface, defaulting to `string`.

There is also some minor clean up involving what is exported from the
`message/http` modules. Now, instead of exporting the entire implementation,
only the `HTTP` binding implementation is exported, and it is then reexported
by `message`.

Also, a static `CloudEvent.cloneWith()` method has been added which the
instance methods now use.

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: make the `cloneWith()` method is dependent on interfaces

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: remove unnecessary cast

Signed-off-by: Lance Ball <lball@redhat.com>
2022-01-07 14:24:56 -05:00
Lance Ball 320354f750
chore: update cucumber dependency and remove prettier (#453)
The combination of prettier and eslint was causing some conflicting error
messages in formatting between VSCode and using npm in the CLI. For the most
part, there were only a couple of required formatting changes that prettier
was covering, so the change is minor.

The cucumber dependency had a major version bump and was carrying some unsafe
dependencies in the older version. This commit bumps to the new version and
makes appropriate configuration changes.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-12-22 10:45:35 -05:00
github-actions[bot] d4cb42f94b
chore: release 5.2.0 (#451)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-12-07 18:05:22 -05:00
Lance Ball 9a46e335f5
feat: add batch mode (#448)
Adds a batched content mode for incoming events.

```js
// It's possible for this to return 1:N events
const ceArray = HTTP.toEvent(req.headers, req.body);
```

Signed-off-by: Lance Ball <lball@redhat.com>
2021-12-07 15:36:10 -05:00
github-actions[bot] d7e1c4178a
chore: release 5.1.0 (#449)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-12-02 08:36:34 -05:00
Snyk bot 0f5a4c0de2
fix: package.json & package-lock.json to reduce vulnerabilities (#439)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-12-01 09:55:58 -05:00
Lance Ball d941e2d4d9
feat: use generic type for CloudEvent data (#446)
Instead of using a big union of types, use a generic type for event data.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-11-29 17:03:12 -05:00
Lance Ball 52ea7de80d
fix: do not assume an empty content-type header is JSON (#444)
The parser for HTTP binary made the assumption that if there was no `content-type`
header in the incoming message, it should inject `application/json`. Discussion
about the rationale for this is in https://github.com/cloudevents/sdk-javascript/issues/441.

This commit, removes that injection and adds a test to ensure the bytes are
simply not parsed, but just passed along untouched.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-11-24 11:02:50 -05:00
Lance Ball b4266b1f37
chore: add test for text/plain data (#442)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-11-23 18:05:15 -05:00
github-actions[bot] f7b2840f82
chore: release 5.0.0 (#430)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-10-05 13:21:01 -04:00
Grant Timmerman b38a48fa59
feat: add native logging with headers and body to CloudEvent (#437)
* feat: add native logging with headers and body to CloudEvent

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* ci: simplify

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* ci: simplify

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* ci: returns to return

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* ci: Update test/integration/cloud_event_test.ts

Co-authored-by: Lance Ball <lball@redhat.com>

* ci: revert symbol change

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* refactor: improve ts for toString

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

Co-authored-by: Lance Ball <lball@redhat.com>
2021-10-04 11:11:38 -07:00
Lance Ball 2ff7852c36
fix: ensure source property has min length of 1 (#438)
Fixes: https://github.com/cloudevents/sdk-javascript/issues/383

Signed-off-by: Lance Ball <lball@redhat.com>
2021-09-29 09:55:37 -04:00
Snyk bot 2dc846c659
fix: package.json & package-lock.json to reduce vulnerabilities (#436)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-09-17 12:09:18 -04:00
Snyk bot 8814919923
fix: package.json & package-lock.json to reduce vulnerabilities (#434)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-09-17 12:08:59 -04:00
Lucas Holmquist a7db466c6e
chore: remove node 10 from ci (#435)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-09-17 11:02:08 -04:00
Snyk bot cf47248d25
fix: package.json & package-lock.json to reduce vulnerabilities (#433)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1579269

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-09-13 11:33:16 -04:00
Lucas Holmquist 272bcea2d8
fix: update express example with framework features. (#429)
fixes #379

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-08-30 16:46:12 -04:00
dependabot[bot] 1ceed024f8
build(deps): bump path-parse from 1.0.6 to 1.0.7 (#431)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-27 10:37:19 -04:00
Lance Ball 2bd9a5a1e4
src!: remove support for 0.3 events (#425)
It has been nearly two years since 1.0 became final. This change removes
support for 0.3 events in the interest of simplifying the project a little.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-27 10:34:32 -04:00
dependabot[bot] 36f5e2b5f8
build(deps): bump path-parse from 1.0.6 to 1.0.7 (#428)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-26 07:54:43 -04:00
Lance Ball 2118488a14
chore: use git submodules for conformance tests (#427)
I don't think downloading to `/tmp` for each `npm test` is such a great
idea. This does mean that contributors to this repo will need to run the
following command once on their clone after this commit lands.

```
git submodule init
git submodule update
```

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-05 09:47:43 -04:00
Lance Ball 061c122b86
chore: update eslint and prettier dependencies (#424)
There were some minor changes that resulted in a few code style changes, but not much.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-04 15:51:37 -04:00
github-actions[bot] b5100566c6
chore: release 4.0.3 (#412)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-07-06 14:34:19 -04:00
dependabot[bot] 5cbe1783fe
build(deps): bump set-getter from 0.1.0 to 0.1.1 (#422)
Bumps [set-getter](https://github.com/doowb/set-getter) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/doowb/set-getter/releases)
- [Commits](https://github.com/doowb/set-getter/commits/0.1.1)

---
updated-dependencies:
- dependency-name: set-getter
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 11:10:10 -04:00
dependabot[bot] b3d9cd4585
build(deps): bump browserslist from 4.14.7 to 4.16.6 (#421)
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.14.7 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.14.7...4.16.6)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 11:09:55 -04:00
Lance Ball 22e42ddb80
fix: do not modify incoming event's specversion (#419)
Even if the specversion is totally invalid, we should not change the value
received in an incoming `Message`. Previously we defaulted to 1.0 if we did
not recognize the version number. This commit changes that, leaving the value
unmodified. We default to parsing this mystery event with the 1.0 spec. When
the event is validated with `event.validate()` we return `false`.

One additional small change to eliminate a prettier warning about `parer`
being previously declared.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-25 11:10:46 -04:00
Lance Ball 7c05adee7b
fix: do not modify incoming event's specversion (#419)
Even if the specversion is totally invalid, we should not change the value
received in an incoming `Message`. Previously we defaulted to 1.0 if we did
not recognize the version number. This commit changes that, leaving the value
unmodified. We default to parsing this mystery event with the 1.0 spec. When
the event is validated with `event.validate()` we return `false`.

One additional small change to eliminate a prettier warning about `parer`
being previously declared.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-25 11:10:20 -04:00
Lance Ball 7f6b658858
fix: throw on validation if extensions are improperly named (#420)
Also fixes the case where UPPERCASED extension names were silently changed
to lowercase and then set as undefined. Even though uppercased extension
names are invalid, we should still accept them in incoming messsages and
only throw when validating the event.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-24 14:53:07 -04:00
Remi Cattiau 80d987c1f6
chore: add copyrights header and lint rules (#418)
Signed-off-by: Remi Cattiau <remi@cattiau.com>
2021-05-14 09:28:49 -04:00
Lance Ball db4be6b1da
src: be more forgiving parsing JSON as a string (#417)
* src: be more forgiving parsing JSON as a string

A simple string is considered valid JSON. However, our parsers do
not accept that unless the string has quotation marks. This commit
modifies the parser to look for strings declared as application/json
which do not begin with '[' '{' or '"' and surrounds them with
quotes.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-13 12:46:36 -04:00
dependabot[bot] e06147b9de
build(deps): bump handlebars from 4.7.6 to 4.7.7 (#414)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:08:31 -04:00
dependabot[bot] 6d7fb24636
build(deps): bump underscore from 1.11.0 to 1.13.1 (#413)
Bumps [underscore](https://github.com/jashkenas/underscore) from 1.11.0 to 1.13.1.
- [Release notes](https://github.com/jashkenas/underscore/releases)
- [Commits](https://github.com/jashkenas/underscore/compare/1.11.0...1.13.1)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:08:13 -04:00
dependabot[bot] d0ff345ef1
build(deps): bump lodash from 4.17.20 to 4.17.21 (#415)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:07:53 -04:00
dependabot[bot] 2c8cc45f64
build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#416)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:07:24 -04:00
Lance Ball 0c17ff3af4
doc: improve generated documentation (#410)
Adds some additional JSDoc properties so the docs are clearer.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-27 12:31:45 -04:00
Lance Ball d68b85a227
chore: add Lance Ball to maintainers in package.json (#411)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-27 12:12:07 -04:00
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