diff --git a/CHANGELOG.md b/CHANGELOG.md index a9253890..43f4e243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [3.1.0](https://github.com/cloudevents/sdk-javascript/compare/v3.0.1...v3.1.0) (2020-08-11) + + +### Bug Fixes + +* Add Correct Headers to emitted Binary Event ([#302](https://github.com/cloudevents/sdk-javascript/issues/302)) ([ad0c434](https://github.com/cloudevents/sdk-javascript/commit/ad0c4340b2b3cf8a6204f7fb9e1df140092e23c9)), closes [#301](https://github.com/cloudevents/sdk-javascript/issues/301) +* ensure that data encoded as base64 is parsed as an object ([#285](https://github.com/cloudevents/sdk-javascript/issues/285)) ([ed9ea95](https://github.com/cloudevents/sdk-javascript/commit/ed9ea956d73491cc890751bf1baf4f0be828a9cb)) +* update browser name to cloudevents. ([#292](https://github.com/cloudevents/sdk-javascript/issues/292)) ([48d182b](https://github.com/cloudevents/sdk-javascript/commit/48d182bc5f3c6f7feb6dec9ce5bb68ff5ad14e66)), closes [#286](https://github.com/cloudevents/sdk-javascript/issues/286) + + +### Miscellaneous + +* fix promise tests to break the build when they fail ([#305](https://github.com/cloudevents/sdk-javascript/issues/305)) ([a5249de](https://github.com/cloudevents/sdk-javascript/commit/a5249de487da4a17b082c4bc59d362a62566ccaf)), closes [#303](https://github.com/cloudevents/sdk-javascript/issues/303) +* no import star ([#297](https://github.com/cloudevents/sdk-javascript/issues/297)) ([31c2005](https://github.com/cloudevents/sdk-javascript/commit/31c200592fb819a38d17c661ce6a76b8ed0ff157)) +* Update examples to use latest sdk changes ([#282](https://github.com/cloudevents/sdk-javascript/issues/282)) ([763838c](https://github.com/cloudevents/sdk-javascript/commit/763838c89cc704397bf75c9cbde79ae0f5c731c1)) +* Update readme with correct Receiver usage ([#287](https://github.com/cloudevents/sdk-javascript/issues/287)) ([e219a30](https://github.com/cloudevents/sdk-javascript/commit/e219a30708f061ef5fdb576d18d2e087f4ba5a25)) +* update the release script to signoff the commit ([#307](https://github.com/cloudevents/sdk-javascript/issues/307)) ([f3cc2b4](https://github.com/cloudevents/sdk-javascript/commit/f3cc2b429baa9d055ac480c433efee1438968ccc)) + + +### Documentation + +* improve readme receiver example ([#309](https://github.com/cloudevents/sdk-javascript/issues/309)) ([d590e3a](https://github.com/cloudevents/sdk-javascript/commit/d590e3a0079e749a9e108b445911eaf544271ec4)) +* Release Guidelines ([#306](https://github.com/cloudevents/sdk-javascript/issues/306)) ([08bf15d](https://github.com/cloudevents/sdk-javascript/commit/08bf15d161d5781b712f6065f78d31d59f8ba549)) +* update badge name ([#289](https://github.com/cloudevents/sdk-javascript/issues/289)) ([3fab5f2](https://github.com/cloudevents/sdk-javascript/commit/3fab5f2c92859b22363b33024f8000dc3ceac1c3)) + ### [3.0.1](https://github.com/cloudevents/sdk-javascript/compare/v3.0.0...v3.0.1) (2020-07-29) diff --git a/README.md b/README.md index e8fb4107..5b2b763f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bd66e7c52002481993cd6d610534b0f7)](https://www.codacy.com/app/fabiojose/sdk-javascript?utm_source=github.com&utm_medium=referral&utm_content=cloudevents/sdk-javascript&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/bd66e7c52002481993cd6d610534b0f7)](https://www.codacy.com/app/fabiojose/sdk-javascript?utm_source=github.com&utm_medium=referral&utm_content=cloudevents/sdk-javascript&utm_campaign=Badge_Coverage) ![Node.js CI](https://github.com/cloudevents/sdk-javascript/workflows/Node.js%20CI/badge.svg) -[![npm version](https://img.shields.io/npm/v/cloudevents-sdk.svg)](https://www.npmjs.com/package/cloudevents-sdk) +[![npm version](https://img.shields.io/npm/v/cloudevents.svg)](https://www.npmjs.com/package/cloudevents) [![vulnerabilities](https://snyk.io/test/github/cloudevents/sdk-javascript/badge.svg)](https://snyk.io/test/github/cloudevents/sdk-javascript) The CloudEvents SDK for JavaScript. @@ -34,17 +34,14 @@ You can choose almost any popular web framework for port binding. Use an binary and structured events in either the 1.0 or 0.3 protocol formats. ```js -const { - CloudEvent, - Receiver -} = require("cloudevents"); +const app = require("express")(); +const {Receiver} = require("cloudevents"); -// Create a receiver to accept events over HTTP -const receiver = new Receiver(); - -// body and headers come from an incoming HTTP request, e.g. express.js -const receivedEvent = receiver.accept(req.headers, req.body); -console.log(receivedEvent); +app.post("/", (req, res) => { + // body and headers come from an incoming HTTP request, e.g. express.js + const receivedEvent = Receiver.accept(req.headers, req.body); + console.log(receivedEvent); +}); ``` #### Emitting Events @@ -157,4 +154,4 @@ We love contributions from the community! Please check the for information on how to get involved. [v1spec]: https://github.com/cloudevents/spec/tree/v1.0 -[v103pec]: https://github.com/cloudevents/spec/tree/v0.3 \ No newline at end of file +[v103pec]: https://github.com/cloudevents/spec/tree/v0.3 diff --git a/RELEASE_GUIDELINES.md b/RELEASE_GUIDELINES.md new file mode 100644 index 00000000..ae29e11b --- /dev/null +++ b/RELEASE_GUIDELINES.md @@ -0,0 +1,62 @@ +# Module Release Guidelines + +## Create a Proposal Issue + +To prepare for a new release, create a [new issue](https://github.com/cloudevents/sdk-javascript/issues/new?assignees=&labels=&template=feature-request.md&title=) where the title of the issue cleary reflects the version to be released. + +For example: "Proposal for 3.2.0 release", or something similar. If you are not sure which version is the next version to be released, you can run `npm run release -- --dry-run` to find out what the next version will be. + +The body of the issue should be the commits that will be part of the release. This can be easily accomplished by running a git log command with a defined **range**. This range should start at the most recent version tag and end at the latest commit in the master branch. + +For example: + +``` +git log v3.0.1..upstream/master --oneline +``` + +This will output all the commits from the 3.0.1 tag to the latest commits in the remote upstream/master branch. + +This output should be pasted into the issue as normal text. This will allow Github to magically turn all commit hashes and PR/Issues numbers to links. + +### Get Consensus + +Before a release can be finalized, other maintainers should give a +1 or a thumbs up or some other identifying mark that they are good with the changes. + +## Create and Publish the release + +Once consensus has been reached on the proposal it is time to create the release and publish it to npm. + +### Create the Release + +Creating the release is as simple as running the release script: + +``` +npm run release +``` + +This will update the CHANGELOG.md and create a new tag based on the version. This can then be pushed upstream by doing: + +``` +git push upstream master --follow-tags +``` + +### Create the release on GitHub + +Once the release tag has been created and pushed up to Github, we should draft a new release using the Github UI, which is [located here](https://github.com/cloudevents/sdk-javascript/releases/new) + +* Tag Version should be the tag that was just created +* The release title should be something like "VERSION Release" +* And the Changelog entries for the current release should be copied/pasted into the comments + + +### Publish to npm + +Once the new version has been created, we need to push it to npm. Assuming you have all the rights to do so, just run: + +``` +npm publish +``` + +## Close the Issue + +Once the release has been completed, the issue can be closed. diff --git a/examples/express-ex/README.md b/examples/express-ex/README.md index 5a41f8fa..9342c515 100644 --- a/examples/express-ex/README.md +++ b/examples/express-ex/README.md @@ -67,7 +67,7 @@ curl -X POST \ -H'ce-source:https://github.com/cloudevents/spec/pull/123' \ -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \ -H'ce-time:2019-11-06T11:17:00Z' \ - -H'ce-my-extension:extension value' \ + -H'ce-myextension:extension value' \ http://localhost:3000/ ``` @@ -110,6 +110,17 @@ curl -X POST \ http://localhost:3000/ ``` +__A Structured One with Base64 Event Data__ + +> Payload [example](../payload/v03/structured-event-2.json) + +```bash +curl -X POST \ + -d'@../payload/v03/structured-event-2.json' \ + -H'Content-Type:application/cloudevents+json' \ + http://localhost:3000/ +``` + __A Binary One__ ```bash @@ -135,7 +146,7 @@ curl -X POST \ -H'ce-source:https://github.com/cloudevents/spec/pull/123' \ -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \ -H'ce-time:2019-06-21T17:31:00Z' \ - -H'ce-my-extension:extension value' \ + -H'ce-myextension:extension value' \ http://localhost:3000/ ``` diff --git a/examples/express-ex/index.js b/examples/express-ex/index.js index da72cf89..57a71e1c 100644 --- a/examples/express-ex/index.js +++ b/examples/express-ex/index.js @@ -1,10 +1,9 @@ /* eslint-disable no-console */ const express = require("express"); -const { Receiver } = require("cloudevents-sdk"); +const {Receiver} = require("cloudevents"); const app = express(); -const receiver = new Receiver(); app.use((req, res, next) => { let data = ""; @@ -20,12 +19,12 @@ app.use((req, res, next) => { }); }); -app.post("/", function (req, res) { +app.post("/", (req, res) => { console.log("HEADERS", req.headers); console.log("BODY", req.body); try { - const event = receiver.accept(req.headers, req.body); + const event = Receiver.accept(req.headers, req.body); console.log(`Accepted event: ${event}`); res.status(201).json(event); } catch (err) { @@ -34,6 +33,6 @@ app.post("/", function (req, res) { } }); -app.listen(3000, function () { +app.listen(3000, () => { console.log("Example app listening on port 3000!"); }); diff --git a/examples/express-ex/package.json b/examples/express-ex/package.json index ae7e226f..3d483f18 100644 --- a/examples/express-ex/package.json +++ b/examples/express-ex/package.json @@ -14,7 +14,7 @@ "author": "fabiojose@gmail.com", "license": "Apache-2.0", "dependencies": { - "cloudevents-sdk": "~2.0.2", + "cloudevents": "~3.0.0", "express": "^4.17.1" } } diff --git a/examples/payload/v03/structured-event-1.json b/examples/payload/v03/structured-event-1.json index 945b3494..a96db00c 100644 --- a/examples/payload/v03/structured-event-1.json +++ b/examples/payload/v03/structured-event-1.json @@ -8,7 +8,7 @@ "data":{ "much":"wow" }, - "my-extension" : { + "myextension" : { "some" : "thing" } } diff --git a/examples/payload/v03/structured-event-2.json b/examples/payload/v03/structured-event-2.json index 2745df36..63ce7880 100644 --- a/examples/payload/v03/structured-event-2.json +++ b/examples/payload/v03/structured-event-2.json @@ -7,7 +7,7 @@ "datacontenttype":"application/json", "datacontentencoding":"base64", "data":"eyJtdWNoIjoid293In0=", - "my-extension" : { + "myextension" : { "some" : "thing" } } diff --git a/examples/payload/v1/structured-event-1.json b/examples/payload/v1/structured-event-1.json index 87b8b706..5551b448 100644 --- a/examples/payload/v1/structured-event-1.json +++ b/examples/payload/v1/structured-event-1.json @@ -8,5 +8,5 @@ "data":{ "much":"wow" }, - "my-extension" : "something" + "myextension" : "something" } diff --git a/examples/payload/v1/structured-event-2.json b/examples/payload/v1/structured-event-2.json index 6401d67e..c4190d4e 100644 --- a/examples/payload/v1/structured-event-2.json +++ b/examples/payload/v1/structured-event-2.json @@ -6,5 +6,5 @@ "time":"2019-11-06T11:08:00Z", "datacontenttype":"application/json", "data_base64":"eyJtdWNoIjoid293In0=", - "my-extension" : "something" + "myextension" : "something" } diff --git a/examples/typescript-ex/package.json b/examples/typescript-ex/package.json index c577e5fb..111195e7 100644 --- a/examples/typescript-ex/package.json +++ b/examples/typescript-ex/package.json @@ -24,8 +24,10 @@ }, "devDependencies": { "@types/node": "^8.9.0", - "cloudevents-sdk": "~2.0.2", "gts": "^1.1.0", "typescript": "~3.9.5" + }, + "dependencies": { + "cloudevents": "~3.0.1" } } diff --git a/examples/typescript-ex/src/index.ts b/examples/typescript-ex/src/index.ts index 0a871ad3..af084a6b 100644 --- a/examples/typescript-ex/src/index.ts +++ b/examples/typescript-ex/src/index.ts @@ -1,8 +1,6 @@ -import { CloudEvent, CloudEventV1, Receiver } from "cloudevents-sdk"; - -export function doSomeStuff() { - const receiver = new Receiver(); +import { CloudEvent, CloudEventV1, Receiver } from "cloudevents"; +export function doSomeStuff(): void { const myevent: CloudEventV1 = new CloudEvent({ source: "/source", type: "type", @@ -10,8 +8,8 @@ export function doSomeStuff() { dataschema: "https://d.schema.com/my.json", subject: "cha.json", data: "my-data", + extension1: "some extension data" }); - myevent.extension1 = "some extension data"; console.log("My structured event:", myevent); @@ -23,7 +21,7 @@ export function doSomeStuff() { // Typically used with an incoming HTTP request where myevent.format() is the actual // body of the HTTP - console.log("Received structured event:", receiver.accept(headers, myevent)); + console.log("Received structured event:", Receiver.accept(headers, myevent)); // ------ receiver binary const data = { @@ -40,10 +38,9 @@ export function doSomeStuff() { "ce-extension1": "extension1", }; - console.log("My binary event:", receiver.accept(attributes, data)); - console.log("My binary event extensions:", receiver.accept(attributes, data)); + console.log("My binary event:", Receiver.accept(attributes, data)); + console.log("My binary event extensions:", Receiver.accept(attributes, data)); - return true; } doSomeStuff(); diff --git a/examples/websocket/README.md b/examples/websocket/README.md index 8c5b7d2d..f39ce101 100644 --- a/examples/websocket/README.md +++ b/examples/websocket/README.md @@ -24,7 +24,7 @@ responds with a CloudEvent containing the body of the Weather API response as th event data. You will need to change one line in the `server.js` file and provide your Open -Weather API key. +Weather API key. You can also create a environment variable `OPEN_WEATHER_API_KEY` and store your key there. To start the server, run `node server.js`. diff --git a/examples/websocket/client.js b/examples/websocket/client.js index eb949c8f..d656571e 100644 --- a/examples/websocket/client.js +++ b/examples/websocket/client.js @@ -3,7 +3,7 @@ const readline = require("readline"); const WebSocket = require("ws"); const ws = new WebSocket("ws://localhost:8080"); -const { CloudEvent } = require("cloudevents-sdk"); +const { CloudEvent } = require("cloudevents"); const rl = readline.createInterface({ input: process.stdin, diff --git a/examples/websocket/index.html b/examples/websocket/index.html index da6ba43d..8b83b5ea 100644 --- a/examples/websocket/index.html +++ b/examples/websocket/index.html @@ -2,10 +2,10 @@ CloudEvent Example - +