Skip to content

Commit 74c8b53

Browse files
committed
feat: use CloudEvents not cloudevents everywhere
Signed-off-by: Grant Timmerman <[email protected]>
1 parent 005d532 commit 74c8b53

15 files changed

+71
-73
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Checkout the new expressive additions.
4242
> There is full example: [typescript-ex](./examples/typescript-ex)
4343
4444
```ts
45-
import Cloudevent, {
45+
import CloudEvent, {
4646
event,
4747
StructuredHTTPEmitter,
4848
BinaryHTTPEmitter,
@@ -51,7 +51,7 @@ import Cloudevent, {
5151
BinaryHTTPReceiver
5252
} from 'cloudevents-sdk/v1';
5353

54-
let myevent: Cloudevent = event()
54+
let myevent: CloudEvent = event()
5555
.source('/source')
5656
.type('type')
5757
.dataContentType('text/plain')
@@ -231,7 +231,7 @@ app.post("/", (req, res) => {
231231
- `ext`: external stuff, e.g, Cloud Events JSONSchema
232232
- `lib/bindings`: every binding implementation goes here
233233
- `lib/bindings/http`: every http binding implementation goes here
234-
- `lib/cloudevent.js`: implementation of Cloudevent, an interface
234+
- `lib/cloudevent.js`: implementation of CloudEvent, an interface
235235
- `lib/formats/`: every format implementation goes here
236236
- `lib/specs/`: every spec implementation goes here
237237

@@ -245,18 +245,18 @@ npm test
245245

246246
## The API
247247

248-
### `Cloudevent` class
248+
### `CloudEvent` class
249249

250250
```js
251251
/*
252252
* Format the payload and return an Object.
253253
*/
254-
Object Cloudevent.format()
254+
Object CloudEvent.format()
255255

256256
/*
257257
* Format the payload as String.
258258
*/
259-
String Cloudevent.toString()
259+
String CloudEvent.toString()
260260
```
261261

262262
### `Formatter` classes
@@ -265,12 +265,12 @@ Every formatter class must implement these methods to work properly.
265265

266266
```js
267267
/*
268-
* Format the Cloudevent payload argument and return an Object.
268+
* Format the CloudEvent payload argument and return an Object.
269269
*/
270270
Object Formatter.format(Object)
271271

272272
/*
273-
* Format the Cloudevent payload as String.
273+
* Format the CloudEvent payload as String.
274274
*/
275275
String Formatter.toString(Object)
276276
```
@@ -297,9 +297,9 @@ Every Spec class must implement these methods to work properly.
297297

298298
```js
299299
/*
300-
* The constructor must receives the Cloudevent type.
300+
* The constructor must receives the CloudEvent type.
301301
*/
302-
Spec(Cloudevent)
302+
Spec(CloudEvent)
303303

304304
/*
305305
* Checks the spec constraints, throwing an error if do not pass.
@@ -320,7 +320,7 @@ Every Binding class must implement these methods to work properly.
320320

321321
#### Emitter Binding
322322

323-
Following we have the signature for the binding to emit Cloudevents.
323+
Following we have the signature for the binding to emit CloudEvents.
324324

325325
```js
326326
/*
@@ -329,14 +329,14 @@ Following we have the signature for the binding to emit Cloudevents.
329329
Binding(config)
330330

331331
/*
332-
* Emits the event using an instance of Cloudevent.
332+
* Emits the event using an instance of CloudEvent.
333333
*/
334-
Binding.emit(cloudevent)
334+
Binding.emit(cloudEvent)
335335
```
336336

337337
#### Receiver Binding
338338

339-
Following we have the signature for the binding to receive Cloudevents.
339+
Following we have the signature for the binding to receive CloudEvents.
340340

341341
```js
342342
/*
@@ -351,9 +351,9 @@ Receiver(config)
351351
Receiver.check(Object, Map)
352352

353353
/*
354-
* Checks and parse as Cloudevent
354+
* Checks and parse as CloudEvent
355355
*/
356-
Cloudevent Receiver.parse(Object, Map)
356+
CloudEvent Receiver.parse(Object, Map)
357357
```
358358

359359
> See how to implement the method injection [here](lib/specs/spec_0_1.js#L17)

examples/typescript-ex/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Cloudevent, {
1+
import CloudEvent, {
22
event,
33
StructuredHTTPEmitter,
44
BinaryHTTPEmitter,
@@ -8,7 +8,7 @@ import Cloudevent, {
88

99
export function doSomeStuff() {
1010

11-
const myevent: Cloudevent = event()
11+
const myevent: CloudEvent = event()
1212
.source('/source')
1313
.type('type')
1414
.dataContentType('text/plain')

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var Cloudevent = require("./lib/cloudevent.js");
1+
var CloudEvent = require("./lib/cloudevent.js");
22

3-
module.exports = Cloudevent;
3+
module.exports = CloudEvent;

lib/bindings/http/receiver_binary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Constants = require("./constants.js");
22
const Commons = require("./commons.js");
3-
const Cloudevent = require("../../cloudevent.js");
3+
const CloudEvent = require("../../cloudevent.js");
44

55
const {
66
isDefinedOrThrow,
@@ -88,7 +88,7 @@ BinaryHTTPReceiver.prototype.parse = function(payload, headers) {
8888
const sanityHeaders = Commons.sanityAndClone(headers);
8989

9090
const processedHeaders = [];
91-
const cloudevent = new Cloudevent(this.Spec);
91+
const cloudevent = new CloudEvent(this.Spec);
9292

9393
// dont worry, check() have seen what was required or not
9494
Array.from(Object.keys(this.setterByHeader))

lib/bindings/http/receiver_structured.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Constants = require("./constants.js");
22
const Commons = require("./commons.js");
3-
const Cloudevent = require("../../cloudevent.js");
3+
const CloudEvent = require("../../cloudevent.js");
44

55
const {
66
isDefinedOrThrow,
@@ -61,7 +61,7 @@ StructuredHTTPReceiver.prototype.parse = function(payload, headers) {
6161
this.spec.check(event);
6262

6363
const processedAttributes = [];
64-
const cloudevent = new Cloudevent(this.Spec);
64+
const cloudevent = new CloudEvent(this.Spec);
6565

6666
Array.from(Object.keys(this.setterByAttribute))
6767
.filter((attribute) => event[attribute])

test/bindings/http/receiver_binary_0_3_tests.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
147147
});
148148

149149
describe("Parse", () => {
150-
it("Cloudevent contains 'type'", () => {
150+
it("CloudEvent contains 'type'", () => {
151151
// setup
152152
var payload = {
153153
data: "dataString"
@@ -170,7 +170,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
170170
.to.equal("type");
171171
});
172172

173-
it("Cloudevent contains 'specversion'", () => {
173+
it("CloudEvent contains 'specversion'", () => {
174174
// setup
175175
var payload = {
176176
data: "dataString"
@@ -193,7 +193,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
193193
.to.equal("0.3");
194194
});
195195

196-
it("Cloudevent contains 'source'", () => {
196+
it("CloudEvent contains 'source'", () => {
197197
// setup
198198
var payload = {
199199
data: "dataString"
@@ -216,7 +216,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
216216
.to.equal("/source");
217217
});
218218

219-
it("Cloudevent contains 'id'", () => {
219+
it("CloudEvent contains 'id'", () => {
220220
// setup
221221
var payload = {
222222
data: "dataString"
@@ -239,7 +239,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
239239
.to.equal("id");
240240
});
241241

242-
it("Cloudevent contains 'time'", () => {
242+
it("CloudEvent contains 'time'", () => {
243243
// setup
244244
var payload = {
245245
data: "dataString"
@@ -262,7 +262,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
262262
.to.equal("2019-06-16T11:42:00.000Z");
263263
});
264264

265-
it("Cloudevent contains 'schemaurl'", () => {
265+
it("CloudEvent contains 'schemaurl'", () => {
266266
// setup
267267
var payload = {
268268
data: "dataString"
@@ -285,7 +285,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
285285
.to.equal("http://schema.registry/v1");
286286
});
287287

288-
it("Cloudevent contains 'datacontenttype' (application/json)", () => {
288+
it("CloudEvent contains 'datacontenttype' (application/json)", () => {
289289
// setup
290290
var payload = {
291291
data: "dataString"
@@ -308,7 +308,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
308308
.to.equal("application/json");
309309
});
310310

311-
it("Cloudevent contains 'datacontenttype' (application/octet-stream)",
311+
it("CloudEvent contains 'datacontenttype' (application/octet-stream)",
312312
() => {
313313
// setup
314314
var payload = "The payload is binary data";
@@ -330,7 +330,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
330330
.to.equal("application/octet-stream");
331331
});
332332

333-
it("Cloudevent contains 'data' (application/json)", () => {
333+
it("CloudEvent contains 'data' (application/json)", () => {
334334
// setup
335335
var payload = {
336336
data: "dataString"
@@ -353,7 +353,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
353353
.to.deep.equal(payload);
354354
});
355355

356-
it("Cloudevent contains 'data' (application/octet-stream)", () => {
356+
it("CloudEvent contains 'data' (application/octet-stream)", () => {
357357
// setup
358358
var payload = "The payload is binary data";
359359
var attributes = {

test/bindings/http/receiver_binary_1_tests.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
148148
});
149149

150150
describe("Parse", () => {
151-
it("Cloudevent contains 'type'", () => {
151+
it("CloudEvent contains 'type'", () => {
152152
// setup
153153
var payload = {
154154
data: "dataString"
@@ -171,7 +171,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
171171
.to.equal("type");
172172
});
173173

174-
it("Cloudevent contains 'specversion'", () => {
174+
it("CloudEvent contains 'specversion'", () => {
175175
// setup
176176
var payload = {
177177
data: "dataString"
@@ -194,7 +194,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
194194
.to.equal("1.0");
195195
});
196196

197-
it("Cloudevent contains 'source'", () => {
197+
it("CloudEvent contains 'source'", () => {
198198
// setup
199199
var payload = {
200200
data: "dataString"
@@ -217,7 +217,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
217217
.to.equal("/source");
218218
});
219219

220-
it("Cloudevent contains 'id'", () => {
220+
it("CloudEvent contains 'id'", () => {
221221
// setup
222222
var payload = {
223223
data: "dataString"
@@ -240,7 +240,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
240240
.to.equal("id");
241241
});
242242

243-
it("Cloudevent contains 'time'", () => {
243+
it("CloudEvent contains 'time'", () => {
244244
// setup
245245
var payload = {
246246
data: "dataString"
@@ -263,7 +263,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
263263
.to.equal("2019-06-16T11:42:00.000Z");
264264
});
265265

266-
it("Cloudevent contains 'dataschema'", () => {
266+
it("CloudEvent contains 'dataschema'", () => {
267267
// setup
268268
var payload = {
269269
data: "dataString"
@@ -286,7 +286,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
286286
.to.equal("http://schema.registry/v1");
287287
});
288288

289-
it("Cloudevent contains 'contenttype' (application/json)", () => {
289+
it("CloudEvent contains 'contenttype' (application/json)", () => {
290290
// setup
291291
var payload = {
292292
data: "dataString"
@@ -309,7 +309,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
309309
.to.equal("application/json");
310310
});
311311

312-
it("Cloudevent contains 'contenttype' (application/octet-stream)", () => {
312+
it("CloudEvent contains 'contenttype' (application/octet-stream)", () => {
313313
// setup
314314
var payload = "The payload is binary data";
315315
var attributes = {
@@ -330,7 +330,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
330330
.to.equal("application/octet-stream");
331331
});
332332

333-
it("Cloudevent contains 'data' (application/json)", () => {
333+
it("CloudEvent contains 'data' (application/json)", () => {
334334
// setup
335335
var payload = {
336336
data: "dataString"
@@ -353,7 +353,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
353353
.to.deep.equal(payload);
354354
});
355355

356-
it("Cloudevent contains 'data' (application/octet-stream)", () => {
356+
it("CloudEvent contains 'data' (application/octet-stream)", () => {
357357
// setup
358358
var payload = "The payload is binary data";
359359
var attributes = {

test/bindings/http/receiver_structured_1_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var expect = require("chai").expect;
22
var v1 = require("../../../v1/index.js");
3-
var Cloudevent = require("../../../index.js");
3+
var CloudEvent = require("../../../index.js");
44

55
const { asBase64 } = require("../../../lib/utils/fun.js");
66

@@ -82,7 +82,7 @@ describe("HTTP Transport Binding Structured Receiver for CloudEvents v1.0",
8282
it("Throw error when the event does not follow the spec", () => {
8383
// setup
8484
var payload =
85-
new Cloudevent()
85+
new CloudEvent()
8686
.type(type)
8787
.source(source)
8888
.time(now)

test/bindings/http/unmarshaller_0_3_tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var expect = require("chai").expect;
22
var Unmarshaller = require("../../../lib/bindings/http/unmarshaller_0_3.js");
3-
var Cloudevent = require("../../../index.js");
3+
var CloudEvent = require("../../../index.js");
44
var v03 = require("../../../v03/index.js");
55

66
const type = "com.github.pull.create";
@@ -117,7 +117,7 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
117117
it("Should accept event that follow the spec 0.3", () => {
118118
// setup
119119
var payload =
120-
new Cloudevent(v03.Spec)
120+
new CloudEvent(v03.Spec)
121121
.type(type)
122122
.source(source)
123123
.dataContentType(ceContentType)
@@ -146,7 +146,7 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
146146
it("Should parse 'data' stringfied json to json object", () => {
147147
// setup
148148
var payload =
149-
new Cloudevent(v03.Spec)
149+
new CloudEvent(v03.Spec)
150150
.type(type)
151151
.source(source)
152152
.dataContentType(ceContentType)

0 commit comments

Comments
 (0)