Skip to content

Remove All API's that are labeled "Remove in 4.0" #362

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,994 changes: 1,811 additions & 2,183 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -99,7 +99,6 @@
"homepage": "https://github.com/cloudevents/sdk-javascript#readme",
"dependencies": {
"ajv": "~6.12.3",
"axios": "~0.19.2",
"uuid": "~8.3.0"
},
"devDependencies": {
18 changes: 2 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -2,17 +2,8 @@ import { CloudEvent, Version } from "./event/cloudevent";
import { ValidationError } from "./event/validation";
import { CloudEventV03, CloudEventV03Attributes, CloudEventV1, CloudEventV1Attributes } from "./event/interfaces";

import {
Emitter,
TransportOptions,
Options,
TransportFunction,
EmitterFunction,
emitterFor,
} from "./transport/emitter";
import { Receiver } from "./transport/receiver";
import { Protocol } from "./transport/protocols";
import { Headers, Mode, Binding, HTTP, Message, Serializer, Deserializer, headersFor } from "./message";
import { Options, TransportFunction, EmitterFunction, emitterFor } from "./transport/emitter";
import { Headers, Mode, Binding, HTTP, Message, Serializer, Deserializer } from "./message";

import CONSTANTS from "./constants";

@@ -32,13 +23,8 @@ export {
Message,
Deserializer,
Serializer,
headersFor, // TODO: Deprecated. Remove for 4.0
HTTP,
// From transport
Emitter, // TODO: Deprecated. Remove for 4.0
Receiver, // TODO: Deprecated. Remove for 4.0
Protocol, // TODO: Deprecated. Remove for 4.0
TransportOptions, // TODO: Deprecated. Remove for 4.0
TransportFunction,
EmitterFunction,
emitterFor,
4 changes: 0 additions & 4 deletions src/message/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IncomingHttpHeaders } from "http";
import { CloudEvent } from "..";
import { binary, deserialize, structured, isEvent } from "./http";
import { headersFor } from "./http/headers";

/**
* Binding is an interface for transport protocols to implement,
@@ -71,6 +70,3 @@ export const HTTP: Binding = {
toEvent: deserialize as Deserializer,
isEvent: isEvent as Detector,
};

// TODO: Deprecated. Remove this for 4.0
export { headersFor };
74 changes: 0 additions & 74 deletions src/transport/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
import { CloudEvent } from "../event/cloudevent";
import { axiosEmitter } from "./http";
import { Protocol } from "./protocols";
import { Agent } from "http";
import { HTTP, Message, Mode } from "../message";

/**
* Options supplied to the Emitter when sending an event.
* In addition to url and protocol, TransportOptions may
* also accept custom options that will be passed to the
* Node.js http functions.
* @deprecated will be removed in 4.0.0
*/
export interface TransportOptions {
/**
* The endpoint that will receieve the event.
* @example http://cncf.example.com/receiver
*/
url?: string;
/**
* The network protocol over which the event will be sent.
* @example HTTPStructured
* @example HTTPBinary
*/
protocol?: Protocol;

[key: string]: string | Record<string, unknown> | Protocol | Agent | undefined;
}

/**
* Options is an additional, optional dictionary of options that may
* be passed to an EmitterFunction and TransportFunction
@@ -84,51 +58,3 @@ export function emitterFor(fn: TransportFunction, options = { binding: HTTP, mod
}
};
}

/**
* A class to send binary and structured CloudEvents to a remote endpoint.
* Currently, supported protocols are HTTPBinary and HTTPStructured.
*
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes
* @deprecated Will be removed in 4.0.0. Consider using the emitterFactory
*
*/
export class Emitter {
url?: string;
protocol: Protocol;
binaryEmitter: EmitterFunction;
structuredEmitter: EmitterFunction;

constructor(options: TransportOptions = { protocol: Protocol.HTTPBinary }) {
this.protocol = options.protocol as Protocol;
this.url = options.url;

this.binaryEmitter = emitterFor(axiosEmitter(this.url as string));
this.structuredEmitter = emitterFor(axiosEmitter(this.url as string), { binding: HTTP, mode: Mode.STRUCTURED });
}

/**
* Sends the {CloudEvent} to an event receiver over HTTP POST
*
* @param {CloudEvent} event the CloudEvent to be sent
* @param {Object} [options] The configuration options for this event. Options
* provided will be passed along to Node.js `http.request()`.
* https://nodejs.org/api/http.html#http_http_request_options_callback
* @param {string} [options.url] The HTTP/S url that should receive this event.
* The URL is optional if one was provided when this emitter was constructed.
* In that case, it will be used as the recipient endpoint. The endpoint can
* be overridden by providing a URL here.
* @returns {Promise} Promise with an eventual response from the receiver
* @deprecated Will be removed in 4.0.0. Consider using the emitterFactory
*/
send(event: CloudEvent, options?: TransportOptions): Promise<unknown> {
options = options || {};
options.url = options.url || this.url;
if (options.protocol != this.protocol) {
if (this.protocol === Protocol.HTTPBinary) return this.binaryEmitter(event, options);
return this.structuredEmitter(event, options);
}
return this.binaryEmitter(event, options);
}
}
27 changes: 0 additions & 27 deletions src/transport/receiver.ts

This file was deleted.

Loading