Commit Graph

746 Commits

Author SHA1 Message Date
Lance Ball b4d7aa9adb
chore: add an npm test:once script (#480)
Adds a convenience npm script that allows you to run only a single test
file at a time. Example usage:

```
sdk-javascript on  lance/update-deps-package-json [!?] is 📦 v5.3.2 via  v16.14.0
❯ npm run test:one

> cloudevents@5.3.2 test:one
> mocha --require ts-node/register

Error: No test files found

sdk-javascript on  lance/update-deps-package-json [!?] is 📦 v5.3.2 via  v16.14.0
❯ npm run test:one -- ./test/integration/batch_test.ts

> cloudevents@5.3.2 test:one
> mocha --require ts-node/register "./test/integration/batch_test.ts"

  A batched CloudEvent message over HTTP
    ✔ Can be created with a typed Message

  A batched CloudEvent message over Kafka
    ✔ Can be created with a typed Message

  2 passing (5ms)

sdk-javascript on  lance/update-deps-package-json [!?] is 📦 v5.3.2 via  v16.14.0
```

Signed-off-by: Lance Ball <lball@redhat.com>
2022-03-17 23:10:30 -04:00
Lance Ball 6204805bfc
chore: update package.json format and deps (#479)
Signed-off-by: Lance Ball <lball@redhat.com>
2022-03-17 23:09:29 -04:00
Lance Ball ae8cb96f8a
doc: update maintainers in README.md (#478)
This commit modifies the structure of the README.md to add a markdown
heading. This change is motiviated by the CLO tool provided by CNCF.
This repository is failing a check for maintainers as you can see on
the dashboard:
https://clomonitor.io/projects/cloudevents/cloudevents#sdk-javascript

Documentation for this change can be found here:
https://github.com/cncf/clomonitor/blob/main/docs/checks.md#maintainers

Signed-off-by: Lance Ball <lball@redhat.com>
2022-03-17 13:21:48 -04:00
Lance Ball c420da4793
chore: update the release documentation (#476)
It has been out of date since we switched to using release-please
for our release automation.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2022-02-16 12:09:45 -05:00
Lance Ball b13bde9b49
feat: precompile cloudevent schema (#471)
* feat: precompile cloudevent schema

This commit modifies the build pipleline so that the cloudevent schema is
precompiled for runtime validation. This eliminates the need to compile the
schema at runtime, improving both performance and security.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2022-02-15 14:06:42 -05:00
dependabot[bot] 4d8f03f7c6
build(deps): bump follow-redirects from 1.14.7 to 1.14.8 (#473)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-14 15:26:46 -05:00
github-actions[bot] 9046b369cf
chore: release 5.3.2 (#470)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-11 15:42:37 -08:00
Lance Ball c3d9f39a53
chore: bump typedoc to remove vuln (#472) 2022-02-10 22:25:48 -06:00
Lance Ball b5c0b56f52
fix: use `isolatedModules: true` in tsconfig.json (#469)
* fix: use `isolatedModules: true` in tsconfig.json

This setting ensures the module can be used in projects where the workflow
includes type checking and transpilation as two separate steps.

See: https://ncjamieson.com/dont-export-const-enums/

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

Signed-off-by: Lance Ball <lball@redhat.com>
2022-02-10 08:39:09 -05:00
github-actions[bot] f36a1f0428
chore: release 5.3.1 (#466)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-03 13:45:21 -05:00
Lance Ball cd4dea954b
fix: improve binary data detection in HTTP transport (#468) 2022-02-02 07:18:08 -05:00
Lucas Holmquist 8abbc114af
chore: update readme with current Node LTS versions and add Node 16 to the testing matrix(#465)
* chore: update readme with current Node LTS versions

* squash: add node 16 to action matrix

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2022-01-27 09:43:42 -05:00
Grant Timmerman 349b84c3da
docs: fix ts example (#467)
* docs: fix ts example

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

* docs: fix ts example

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

* docs: update quote mark

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2022-01-26 22:50:36 -06:00
David Pereira c603831e93
docs: add TS examples for CloudEvent usage (#461)
* docs: add TS examples for CloudEvent usage

Co-authored-by: Lance Ball <lball@redhat.com>
2022-01-26 16:54:49 -05:00
Snyk bot ae8fa799af
fix: package.json & package-lock.json to reduce vulnerabilities (#462)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-NANOID-2332193

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2022-01-24 18:49:01 -05:00
dependabot[bot] 225836f68f
build(deps): bump follow-redirects from 1.14.6 to 1.14.7 (#460)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.6 to 1.14.7.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.6...v1.14.7)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-21 17:05:05 -05:00
github-actions[bot] 98009d910d
chore: release 5.3.0 (#458)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-01-18 14:07:12 -05:00
Lance Ball 591d133f31
feat: add MQTT transport messaging (#459)
Add MQTT as a `Message` format.

This commit adds `MQTT` to the supported transport protocols by adding a `Binding` and the `MQTTMessage<T>` type, extending the base `Message` type, adding the MQTT fields for `payload`, `PUBLISH` and `User Properties`. The `payload` field directly maps to `Message#body`, while `User Properties` roughly maps to `Message#headers`, even though the properties here are not formatted with a `ce-` prefix like other transport protocols. This is per the spec. See: https://github.com/cloudevents/spec/blob/v1.0.1/mqtt-protocol-binding.md. 

Signed-off-by: Lance Ball <lball@redhat.com>
2022-01-14 11:41:15 -05:00
Lance Ball 5d1f744f50
feat: add support for kafka transport (#455)
This commit extends the `message` package to include Kafka transport.

Additionally, some of the type information has changed across the project
to more accurately reflect the type of `Message` (by including `T`).

Related: https://github.com/cloudevents/sdk-javascript/issues/390
Signed-off-by: Lance Ball <lball@redhat.com>
2022-01-07 16:14:09 -05:00
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