forked from cloudevents/sdk-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add tsc type checking in the ci/test pipeline
This commit introduces TypeScript checks and generates type declarations for the existing JavaScript codebase using `tsc` prior to running the linter task. Ref: cloudevents#9 Signed-off-by: Lance Ball <lball@redhat.com>
- Loading branch information
Showing
24 changed files
with
495 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const CloudEvent: typeof import("./lib/cloudevent.js"); | ||
export const HTTPReceiver: typeof import("./lib/bindings/http/http_receiver.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export function sanityAndClone(headers: any): {}; | ||
export function sanityContentType(contentType: any): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
declare const _exports: { | ||
readonly HEADERS: string; | ||
readonly CHARSET_DEFAULT: string; | ||
readonly SPEC_V03: string; | ||
readonly SPEC_V1: string; | ||
readonly DEFAULT_SPEC_VERSION_HEADER: string; | ||
readonly ENCODING_BASE64: string; | ||
readonly DATA_ATTRIBUTE: string; | ||
readonly MIME_JSON: string; | ||
readonly MIME_OCTET_STREAM: string; | ||
readonly MIME_CE: string; | ||
readonly MIME_CE_JSON: string; | ||
readonly HEADER_CONTENT_TYPE: string; | ||
readonly DEFAULT_CONTENT_TYPE: string; | ||
readonly DEFAULT_CE_CONTENT_TYPE: string; | ||
readonly BINARY_HEADERS_03: { | ||
TYPE: string; | ||
SPEC_VERSION: string; | ||
SOURCE: string; | ||
ID: string; | ||
TIME: string; | ||
SCHEMA_URL: string; | ||
CONTENT_ENCONDING: string; | ||
SUBJECT: string; | ||
EXTENSIONS_PREFIX: string; | ||
}; | ||
readonly STRUCTURED_ATTRS_03: { | ||
TYPE: string; | ||
SPEC_VERSION: string; | ||
SOURCE: string; | ||
ID: string; | ||
TIME: string; | ||
SCHEMA_URL: string; | ||
CONTENT_ENCONDING: string; | ||
CONTENT_TYPE: string; | ||
SUBJECT: string; | ||
DATA: string; | ||
}; | ||
readonly BINARY_HEADERS_1: { | ||
TYPE: string; | ||
SPEC_VERSION: string; | ||
SOURCE: string; | ||
ID: string; | ||
TIME: string; | ||
DATA_SCHEMA: string; | ||
SUBJECT: string; | ||
EXTENSIONS_PREFIX: string; | ||
}; | ||
readonly STRUCTURED_ATTRS_1: { | ||
TYPE: string; | ||
SPEC_VERSION: string; | ||
SOURCE: string; | ||
ID: string; | ||
TIME: string; | ||
DATA_SCHEMA: string; | ||
CONTENT_TYPE: string; | ||
SUBJECT: string; | ||
DATA: string; | ||
DATA_BASE64: string; | ||
}; | ||
}; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export = HTTPReceiver; | ||
/** | ||
* A class to receive a CloudEvent from an HTTP POST request. | ||
*/ | ||
declare class HTTPReceiver { | ||
receivers: { | ||
v1: { | ||
structured: import("./receiver_structured_1.js"); | ||
binary: import("./receiver_binary_1.js"); | ||
}; | ||
v03: { | ||
structured: import("./receiver_structured_0_3.js"); | ||
binary: import("./receiver_binary_0_3.js"); | ||
}; | ||
}; | ||
/** | ||
* Acceptor for an incoming HTTP CloudEvent POST. Can process | ||
* binary and structured incoming CloudEvents. | ||
* | ||
* @param {Object} headers HTTP headers keyed by header name ("Content-Type") | ||
* @param {Object|JSON} body The body of the HTTP request | ||
// @ts-ignore tsc can't find CloudEvent - is that because it's not imported? | ||
* @return {CloudEvent} A new {CloudEvent} instance | ||
*/ | ||
accept(headers: any, body: any): any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export = BinaryHTTPReceiver; | ||
declare function BinaryHTTPReceiver(parsersByEncoding: any, setterByHeader: any, allowedContentTypes: any, requiredHeaders: any, Spec: any, specversion: any, extensionsPrefix: any, checkDecorator: any): void; | ||
declare class BinaryHTTPReceiver { | ||
constructor(parsersByEncoding: any, setterByHeader: any, allowedContentTypes: any, requiredHeaders: any, Spec: any, specversion: any, extensionsPrefix: any, checkDecorator: any); | ||
parsersByEncoding: any; | ||
setterByHeader: any; | ||
allowedContentTypes: any; | ||
requiredHeaders: any; | ||
Spec: any; | ||
spec: any; | ||
specversion: any; | ||
extensionsPrefix: any; | ||
checkDecorator: any; | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export = Receiver; | ||
declare function Receiver(configuration: any): void; | ||
declare class Receiver { | ||
constructor(configuration: any); | ||
receiver: import("./receiver_binary.js"); | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export = Receiver; | ||
declare function Receiver(configuration: any): void; | ||
declare class Receiver { | ||
constructor(configuration: any); | ||
receiver: import("./receiver_binary.js"); | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export = StructuredHTTPReceiver; | ||
declare function StructuredHTTPReceiver(parserByMime: any, parserMap: any, allowedContentTypes: any, Spec: any): void; | ||
declare class StructuredHTTPReceiver { | ||
constructor(parserByMime: any, parserMap: any, allowedContentTypes: any, Spec: any); | ||
parserByMime: any; | ||
parserMap: any; | ||
allowedContentTypes: any; | ||
Spec: any; | ||
spec: any; | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export = Receiver; | ||
declare function Receiver(configuration: any): void; | ||
declare class Receiver { | ||
constructor(configuration: any); | ||
receiver: import("./receiver_structured.js"); | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export = Receiver; | ||
declare function Receiver(configuration: any): void; | ||
declare class Receiver { | ||
constructor(configuration: any); | ||
receiver: import("./receiver_structured.js"); | ||
check(payload: any, headers: any): void; | ||
parse(payload: any, headers: any): import("../../cloudevent.js"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
export = CloudEvent; | ||
/** | ||
* An instance of a CloudEvent. | ||
*/ | ||
declare class CloudEvent { | ||
/** | ||
* Creates a new CloudEvent instance | ||
* @param {Spec} [userSpec] A CloudEvent version specification | ||
* @param {Formatter} [userFormatter] Converts the event into a readable string | ||
*/ | ||
constructor(userSpec?: import("./specs/spec_1.js"), userFormatter?: import("./formats/json/formatter.js")); | ||
spec: any; | ||
formatter: any; | ||
extensions: {}; | ||
/** | ||
* Get the formatters available to this CloudEvent | ||
* @returns {Object} a JSON formatter | ||
*/ | ||
getFormats(): any; | ||
/** | ||
* Formats the CloudEvent as JSON. Validates the event according | ||
* to the CloudEvent specification and throws an exception if | ||
* it's invalid. | ||
* @returns {JSON} the CloudEvent in JSON form | ||
*/ | ||
format(): JSON; | ||
/** | ||
* Formats the CLoudEvent as JSON. No specification validation | ||
* is performed. | ||
* @returns {JSON} the CloudEvent in JSON form | ||
*/ | ||
toString(): JSON; | ||
/** | ||
* Sets the event type | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type | ||
* @param {string} type the type of event related to the originating source | ||
* @returns {CloudEvent} this CloudEvent | ||
*/ | ||
type(type: string): CloudEvent; | ||
/** | ||
* Gets the event type | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type | ||
* @returns {String} the type of event related to the originating source | ||
*/ | ||
getType(): string; | ||
specversion(version: any): any; | ||
/** | ||
* Gets the CloudEvent specification version | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#specversion | ||
* @returns {string} The CloudEvent version that this event adheres to | ||
*/ | ||
getSpecversion(): string; | ||
/** | ||
* Sets the origination source of this event. | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1 | ||
// @ts-ignore tsc can't find URI type | ||
* @param {URI} source the context in which the event happened | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
source(source: any): CloudEvent; | ||
/** | ||
* Gets the origination source of this event. | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1 | ||
* @returns {string} the event source | ||
*/ | ||
getSource(): string; | ||
/** | ||
* Sets the event id. Source + id must be unique for each distinct event. | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#id | ||
* @param {string} id source+id must be unique for each distinct event | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
id(id: string): CloudEvent; | ||
/** | ||
* Gets the event id. | ||
* @returns {string} the event id | ||
*/ | ||
getId(): string; | ||
/** | ||
* Sets the timestamp for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time | ||
* @param {Date} time timestamp when the event occurred | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
time(time: Date): CloudEvent; | ||
/** | ||
* Gets the timestamp for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time | ||
* @returns {Date} the timestamp for this event | ||
*/ | ||
getTime(): Date; | ||
schemaurl(schemaurl: any): CloudEvent; | ||
getSchemaurl(): any; | ||
/** | ||
* Sets the content type of the data value for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype | ||
* @param {string} contenttype per https://tools.ietf.org/html/rfc2046 | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
dataContenttype(contenttype: string): CloudEvent; | ||
/** | ||
* Gets the content type of the data value for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype | ||
* @returns {string} the content type for the data in this event | ||
*/ | ||
getDataContenttype(): string; | ||
/** | ||
* Sets the data for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data | ||
* @param {*} data any data associated with this event | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
data(data: any): CloudEvent; | ||
/** | ||
* Gets any data that has been set for this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data | ||
* @returns {*} any data set for this event | ||
*/ | ||
getData(): any; | ||
/** | ||
* Adds an extension attribute to this CloudEvent | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes | ||
* @param {*} key the name of the extension attribute | ||
* @param {*} value the value of the extension attribute | ||
* @returns {CloudEvent} this CloudEvent instance | ||
*/ | ||
addExtension(key: any, value: any): CloudEvent; | ||
/** | ||
* Gets the extension attributes, if any, associated with this event | ||
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes | ||
* @returns {Object} the extensions attributes - if none exist will will be {} | ||
* // TODO - this should return null or undefined if no extensions | ||
*/ | ||
getExtensions(): any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export = Base64Parser; | ||
declare class Base64Parser { | ||
constructor(decorator: any); | ||
decorator: any; | ||
parse(payload: any): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export = JSONFormatter; | ||
declare class JSONFormatter { | ||
format(payload: any): any; | ||
toString(payload: any): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export = JSONParser; | ||
declare class JSONParser { | ||
constructor(decorator: any); | ||
decorator: any; | ||
/** | ||
* Parses the payload with an optional decorator | ||
* @param {object|string} payload the JSON payload | ||
* @return {object} the parsed JSON payload. | ||
*/ | ||
parse(payload: any): any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export = Spec03; | ||
declare function Spec03(_caller: any): void; | ||
declare class Spec03 { | ||
constructor(_caller: any); | ||
payload: { | ||
specversion: string; | ||
id: any; | ||
}; | ||
caller: any; | ||
check(ce: any): void; | ||
id(_id: any): Spec03; | ||
getId(): any; | ||
source(_source: any): Spec03; | ||
getSource(): any; | ||
specversion(): Spec03; | ||
getSpecversion(): string; | ||
type(_type: any): Spec03; | ||
getType(): any; | ||
dataContentEncoding(encoding: any): Spec03; | ||
getDataContentEncoding(): any; | ||
dataContentType(_contenttype: any): Spec03; | ||
getDataContentType(): any; | ||
schemaurl(_schemaurl: any): Spec03; | ||
getSchemaurl(): any; | ||
subject(_subject: any): Spec03; | ||
getSubject(): any; | ||
time(_time: any): Spec03; | ||
getTime(): any; | ||
data(_data: any): Spec03; | ||
getData(): any; | ||
addExtension(key: any, value: any): Spec03; | ||
} |
Oops, something went wrong.