Skip to content

Commit 875f700

Browse files
authored
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 <[email protected]>
1 parent 8205bc9 commit 875f700

File tree

9 files changed

+1814
-2785
lines changed

9 files changed

+1814
-2785
lines changed

package-lock.json

Lines changed: 1811 additions & 2183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
"homepage": "https://github.com/cloudevents/sdk-javascript#readme",
100100
"dependencies": {
101101
"ajv": "~6.12.3",
102-
"axios": "~0.19.2",
103102
"uuid": "~8.3.0"
104103
},
105104
"devDependencies": {

src/index.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@ import { CloudEvent, Version } from "./event/cloudevent";
22
import { ValidationError } from "./event/validation";
33
import { CloudEventV03, CloudEventV03Attributes, CloudEventV1, CloudEventV1Attributes } from "./event/interfaces";
44

5-
import {
6-
Emitter,
7-
TransportOptions,
8-
Options,
9-
TransportFunction,
10-
EmitterFunction,
11-
emitterFor,
12-
} from "./transport/emitter";
13-
import { Receiver } from "./transport/receiver";
14-
import { Protocol } from "./transport/protocols";
15-
import { Headers, Mode, Binding, HTTP, Message, Serializer, Deserializer, headersFor } from "./message";
5+
import { Options, TransportFunction, EmitterFunction, emitterFor } from "./transport/emitter";
6+
import { Headers, Mode, Binding, HTTP, Message, Serializer, Deserializer } from "./message";
167

178
import CONSTANTS from "./constants";
189

@@ -32,13 +23,8 @@ export {
3223
Message,
3324
Deserializer,
3425
Serializer,
35-
headersFor, // TODO: Deprecated. Remove for 4.0
3626
HTTP,
3727
// From transport
38-
Emitter, // TODO: Deprecated. Remove for 4.0
39-
Receiver, // TODO: Deprecated. Remove for 4.0
40-
Protocol, // TODO: Deprecated. Remove for 4.0
41-
TransportOptions, // TODO: Deprecated. Remove for 4.0
4228
TransportFunction,
4329
EmitterFunction,
4430
emitterFor,

src/message/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { IncomingHttpHeaders } from "http";
22
import { CloudEvent } from "..";
33
import { binary, deserialize, structured, isEvent } from "./http";
4-
import { headersFor } from "./http/headers";
54

65
/**
76
* Binding is an interface for transport protocols to implement,
@@ -71,6 +70,3 @@ export const HTTP: Binding = {
7170
toEvent: deserialize as Deserializer,
7271
isEvent: isEvent as Detector,
7372
};
74-
75-
// TODO: Deprecated. Remove this for 4.0
76-
export { headersFor };

src/transport/emitter.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
import { CloudEvent } from "../event/cloudevent";
2-
import { axiosEmitter } from "./http";
3-
import { Protocol } from "./protocols";
4-
import { Agent } from "http";
52
import { HTTP, Message, Mode } from "../message";
63

7-
/**
8-
* Options supplied to the Emitter when sending an event.
9-
* In addition to url and protocol, TransportOptions may
10-
* also accept custom options that will be passed to the
11-
* Node.js http functions.
12-
* @deprecated will be removed in 4.0.0
13-
*/
14-
export interface TransportOptions {
15-
/**
16-
* The endpoint that will receieve the event.
17-
* @example http://cncf.example.com/receiver
18-
*/
19-
url?: string;
20-
/**
21-
* The network protocol over which the event will be sent.
22-
* @example HTTPStructured
23-
* @example HTTPBinary
24-
*/
25-
protocol?: Protocol;
26-
27-
[key: string]: string | Record<string, unknown> | Protocol | Agent | undefined;
28-
}
29-
304
/**
315
* Options is an additional, optional dictionary of options that may
326
* be passed to an EmitterFunction and TransportFunction
@@ -84,51 +58,3 @@ export function emitterFor(fn: TransportFunction, options = { binding: HTTP, mod
8458
}
8559
};
8660
}
87-
88-
/**
89-
* A class to send binary and structured CloudEvents to a remote endpoint.
90-
* Currently, supported protocols are HTTPBinary and HTTPStructured.
91-
*
92-
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md
93-
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes
94-
* @deprecated Will be removed in 4.0.0. Consider using the emitterFactory
95-
*
96-
*/
97-
export class Emitter {
98-
url?: string;
99-
protocol: Protocol;
100-
binaryEmitter: EmitterFunction;
101-
structuredEmitter: EmitterFunction;
102-
103-
constructor(options: TransportOptions = { protocol: Protocol.HTTPBinary }) {
104-
this.protocol = options.protocol as Protocol;
105-
this.url = options.url;
106-
107-
this.binaryEmitter = emitterFor(axiosEmitter(this.url as string));
108-
this.structuredEmitter = emitterFor(axiosEmitter(this.url as string), { binding: HTTP, mode: Mode.STRUCTURED });
109-
}
110-
111-
/**
112-
* Sends the {CloudEvent} to an event receiver over HTTP POST
113-
*
114-
* @param {CloudEvent} event the CloudEvent to be sent
115-
* @param {Object} [options] The configuration options for this event. Options
116-
* provided will be passed along to Node.js `http.request()`.
117-
* https://nodejs.org/api/http.html#http_http_request_options_callback
118-
* @param {string} [options.url] The HTTP/S url that should receive this event.
119-
* The URL is optional if one was provided when this emitter was constructed.
120-
* In that case, it will be used as the recipient endpoint. The endpoint can
121-
* be overridden by providing a URL here.
122-
* @returns {Promise} Promise with an eventual response from the receiver
123-
* @deprecated Will be removed in 4.0.0. Consider using the emitterFactory
124-
*/
125-
send(event: CloudEvent, options?: TransportOptions): Promise<unknown> {
126-
options = options || {};
127-
options.url = options.url || this.url;
128-
if (options.protocol != this.protocol) {
129-
if (this.protocol === Protocol.HTTPBinary) return this.binaryEmitter(event, options);
130-
return this.structuredEmitter(event, options);
131-
}
132-
return this.binaryEmitter(event, options);
133-
}
134-
}

src/transport/receiver.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)