diff --git a/src/event/cloudevent.ts b/src/event/cloudevent.ts index 93516e2..4cc7fcb 100644 --- a/src/event/cloudevent.ts +++ b/src/event/cloudevent.ts @@ -1,7 +1,14 @@ import { v4 as uuidv4 } from "uuid"; -import { CloudEventV1, validateV1, CloudEventV1Attributes, CloudEventV1OptionalAttributes } from "./v1"; -import { CloudEventV03, validateV03, CloudEventV03Attributes, CloudEventV03OptionalAttributes } from "./v03"; +import { + CloudEventV03, + CloudEventV03Attributes, + CloudEventV03OptionalAttributes, + CloudEventV1, + CloudEventV1Attributes, + CloudEventV1OptionalAttributes, +} from "./interfaces"; +import { validateV1, validateV03 } from "./spec"; import { ValidationError, isBinary, asBase64 } from "./validation"; import CONSTANTS from "../constants"; import { isString } from "util"; diff --git a/src/event/index.ts b/src/event/index.ts deleted file mode 100644 index e852d4e..0000000 --- a/src/event/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./cloudevent"; -export * from "./validation"; -export * from "./v1"; -export * from "./v03"; diff --git a/src/event/v03/cloudevent.ts b/src/event/interfaces.ts similarity index 50% rename from src/event/v03/cloudevent.ts rename to src/event/interfaces.ts index 9d4b5d6..f886cb1 100644 --- a/src/event/v03/cloudevent.ts +++ b/src/event/interfaces.ts @@ -1,3 +1,141 @@ +/** + * The object interface for CloudEvents 1.0. + * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md + */ +export interface CloudEventV1 extends CloudEventV1Attributes { + // REQUIRED Attributes + /** + * [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id` + * is unique for each distinct event. If a duplicate event is re-sent (e.g. due + * to a network error) it MAY have the same `id`. Consumers MAY assume that + * Events with identical `source` and `id` are duplicates. + * @required Non-empty string. Unique within producer. + * @example An event counter maintained by the producer + * @example A UUID + */ + id: string; + + /** + * [REQUIRED] The version of the CloudEvents specification which the event + * uses. This enables the interpretation of the context. Compliant event + * producers MUST use a value of `1.0` when referring to this version of the + * specification. + * @required MUST be a non-empty string. + */ + specversion: string; +} + +export interface CloudEventV1Attributes extends CloudEventV1OptionalAttributes { + /** + * [REQUIRED] Identifies the context in which an event happened. Often this + * will include information such as the type of the event source, the + * organization publishing the event or the process that produced the event. The + * exact syntax and semantics behind the data encoded in the URI is defined by + * the event producer. + * Producers MUST ensure that `source` + `id` is unique for each distinct event. + * An application MAY assign a unique `source` to each distinct producer, which + * makes it easy to produce unique IDs since no other producer will have the same + * source. The application MAY use UUIDs, URNs, DNS authorities or an + * application-specific scheme to create unique `source` identifiers. + * A source MAY include more than one producer. In that case the producers MUST + * collaborate to ensure that `source` + `id` is unique for each distinct event. + * @required Non-empty URI-reference + */ + source: string; + + /** + * [REQUIRED] This attribute contains a value describing the type of event + * related to the originating occurrence. Often this attribute is used for + * routing, observability, policy enforcement, etc. The format of this is + * producer defined and might include information such as the version of the + * `type` - see + * [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes) + * for more information. + * @required MUST be a non-empty string + * @should SHOULD be prefixed with a reverse-DNS name. The prefixed domain dictates the + * organization which defines the semantics of this event type. + * @example com.github.pull.create + * @example com.example.object.delete.v2 + */ + type: string; +} + +export interface CloudEventV1OptionalAttributes { + /** + * The following fields are optional. + */ + + /** + * [OPTIONAL] Content type of `data` value. This attribute enables `data` to + * carry any type of content, whereby format and encoding might differ from that + * of the chosen event format. For example, an event rendered using the + * [JSON envelope](./json-format.md#3-envelope) format might carry an XML payload + * in `data`, and the consumer is informed by this attribute being set to + * "application/xml". The rules for how `data` content is rendered for different + * `datacontenttype` values are defined in the event format specifications; for + * example, the JSON event format defines the relationship in + * [section 3.1](./json-format.md#31-handling-of-data). + */ + datacontenttype?: string; + /** + * [OPTIONAL] Identifies the schema that `data` adheres to. Incompatible + * changes to the schema SHOULD be reflected by a different URI. See + * [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes) + * for more information. + * If present, MUST be a non-empty URI. + */ + dataschema?: string; + /** + * [OPTIONAL] This describes the subject of the event in the context of the + * event producer (identified by `source`). In publish-subscribe scenarios, a + * subscriber will typically subscribe to events emitted by a `source`, but the + * `source` identifier alone might not be sufficient as a qualifier for any + * specific event if the `source` context has internal sub-structure. + * + * Identifying the subject of the event in context metadata (opposed to only in + * the `data` payload) is particularly helpful in generic subscription filtering + * scenarios where middleware is unable to interpret the `data` content. In the + * above example, the subscriber might only be interested in blobs with names + * ending with '.jpg' or '.jpeg' and the `subject` attribute allows for + * constructing a simple and efficient string-suffix filter for that subset of + * events. + * + * If present, MUST be a non-empty string. + * @example "https://example.com/storage/tenant/container" + * @example "mynewfile.jpg" + */ + subject?: string; + /** + * [OPTIONAL] Timestamp of when the occurrence happened. If the time of the + * occurrence cannot be determined then this attribute MAY be set to some other + * time (such as the current time) by the CloudEvents producer, however all + * producers for the same `source` MUST be consistent in this respect. In other + * words, either they all use the actual time of the occurrence or they all use + * the same algorithm to determine the value used. + * @example "2020-08-08T14:48:09.769Z" + */ + time?: Date | string; + /** + * [OPTIONAL] The event payload. This specification does not place any restriction + * on the type of this information. It is encoded into a media format which is + * specified by the datacontenttype attribute (e.g. application/json), and adheres + * to the dataschema format when those respective attributes are present. + */ + data?: Record | string | number | boolean | null | unknown; + + /** + * [OPTIONAL] The event payload encoded as base64 data. This is used when the + * data is in binary form. + * @see https://github.com/cloudevents/spec/blob/v1.0/json-format.md#31-handling-of-data + */ + data_base64?: string; + + /** + * [OPTIONAL] CloudEvents extension attributes. + */ + [key: string]: unknown; +} + /** * The object interface for CloudEvents 0.3. * @see https://github.com/cloudevents/spec/blob/v0.3/spec.md diff --git a/src/event/v1/schema.ts b/src/event/schemas.ts similarity index 51% rename from src/event/v1/schema.ts rename to src/event/schemas.ts index f56d76e..6591e3f 100644 --- a/src/event/v1/schema.ts +++ b/src/event/schemas.ts @@ -1,4 +1,4 @@ -const schemaV1 = { +export const schemaV1 = { $ref: "#/definitions/event", definitions: { specversion: { @@ -79,4 +79,75 @@ const schemaV1 = { type: "object", }; -export { schemaV1 }; +export const schemaV03 = { + $ref: "#/definitions/event", + definitions: { + specversion: { + const: "0.3", + }, + datacontenttype: { + type: "string", + }, + data: { + type: ["object", "string"], + }, + event: { + properties: { + specversion: { + $ref: "#/definitions/specversion", + }, + datacontenttype: { + $ref: "#/definitions/datacontenttype", + }, + data: { + $ref: "#/definitions/data", + }, + id: { + $ref: "#/definitions/id", + }, + time: { + $ref: "#/definitions/time", + }, + schemaurl: { + $ref: "#/definitions/schemaurl", + }, + subject: { + $ref: "#/definitions/subject", + }, + type: { + $ref: "#/definitions/type", + }, + source: { + $ref: "#/definitions/source", + }, + }, + required: ["specversion", "id", "type", "source"], + type: "object", + }, + id: { + type: "string", + minLength: 1, + }, + time: { + format: "date-time", + type: "string", + }, + schemaurl: { + type: "string", + format: "uri-reference", + }, + subject: { + type: "string", + minLength: 1, + }, + type: { + type: "string", + minLength: 1, + }, + source: { + format: "uri-reference", + type: "string", + }, + }, + type: "object", +}; diff --git a/src/event/v03/spec.ts b/src/event/spec.ts similarity index 50% rename from src/event/v03/spec.ts rename to src/event/spec.ts index 280d728..6317130 100644 --- a/src/event/v03/spec.ts +++ b/src/event/spec.ts @@ -1,17 +1,36 @@ -import { v4 as uuidv4 } from "uuid"; import Ajv from "ajv"; -import { ValidationError, isBase64 } from "../validation"; -import { CloudEventV03, CloudEventV03Attributes } from "./cloudevent"; -import { CloudEvent } from "../.."; -import { schema } from "./schema"; -import CONSTANTS from "../../constants"; +import { v4 as uuidv4 } from "uuid"; +import { ValidationError, isBase64 } from "./validation"; + +import { CloudEvent } from "./cloudevent"; +import { CloudEventV1, CloudEventV1Attributes, CloudEventV03, CloudEventV03Attributes } from "./interfaces"; +import { schemaV03, schemaV1 } from "./schemas"; +import CONSTANTS from "../constants"; const ajv = new Ajv({ extendRefs: true }); -const isValidAgainstSchema = ajv.compile(schema); +const isValidAgainstSchemaV1 = ajv.compile(schemaV1); +const isValidAgainstSchemaV03 = ajv.compile(schemaV03); + +export function createV1(attributes: CloudEventV1Attributes): CloudEventV1 { + const event: CloudEventV1 = { + specversion: schemaV1.definitions.specversion.const, + id: uuidv4(), + time: new Date().toISOString(), + ...attributes, + }; + return new CloudEvent(event); +} + +export function validateV1(event: CloudEventV1): boolean { + if (!isValidAgainstSchemaV1(event)) { + throw new ValidationError("invalid payload", isValidAgainstSchemaV1.errors); + } + return true; +} export function createV03(attributes: CloudEventV03Attributes): CloudEventV03 { const event: CloudEventV03 = { - specversion: schema.definitions.specversion.const, + specversion: schemaV03.definitions.specversion.const, id: uuidv4(), time: new Date().toISOString(), ...attributes, @@ -20,8 +39,8 @@ export function createV03(attributes: CloudEventV03Attributes): CloudEventV03 { } export function validateV03(event: CloudEventV03): boolean { - if (!isValidAgainstSchema(event)) { - throw new ValidationError("invalid payload", isValidAgainstSchema.errors); + if (!isValidAgainstSchemaV03(event)) { + throw new ValidationError("invalid payload", isValidAgainstSchemaV03.errors); } return checkDataContentEncoding(event); } diff --git a/src/event/v03/index.ts b/src/event/v03/index.ts deleted file mode 100644 index e207dd4..0000000 --- a/src/event/v03/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./cloudevent"; -export * from "./spec"; -export * from "./schema"; diff --git a/src/event/v03/schema.ts b/src/event/v03/schema.ts deleted file mode 100644 index f6423d4..0000000 --- a/src/event/v03/schema.ts +++ /dev/null @@ -1,74 +0,0 @@ -const schemaV03 = { - $ref: "#/definitions/event", - definitions: { - specversion: { - const: "0.3", - }, - datacontenttype: { - type: "string", - }, - data: { - type: ["object", "string"], - }, - event: { - properties: { - specversion: { - $ref: "#/definitions/specversion", - }, - datacontenttype: { - $ref: "#/definitions/datacontenttype", - }, - data: { - $ref: "#/definitions/data", - }, - id: { - $ref: "#/definitions/id", - }, - time: { - $ref: "#/definitions/time", - }, - schemaurl: { - $ref: "#/definitions/schemaurl", - }, - subject: { - $ref: "#/definitions/subject", - }, - type: { - $ref: "#/definitions/type", - }, - source: { - $ref: "#/definitions/source", - }, - }, - required: ["specversion", "id", "type", "source"], - type: "object", - }, - id: { - type: "string", - minLength: 1, - }, - time: { - format: "date-time", - type: "string", - }, - schemaurl: { - type: "string", - format: "uri-reference", - }, - subject: { - type: "string", - minLength: 1, - }, - type: { - type: "string", - minLength: 1, - }, - source: { - format: "uri-reference", - type: "string", - }, - }, - type: "object", -}; - -export { schemaV03 as schema }; diff --git a/src/event/v1/cloudevent.ts b/src/event/v1/cloudevent.ts deleted file mode 100644 index f9f2729..0000000 --- a/src/event/v1/cloudevent.ts +++ /dev/null @@ -1,137 +0,0 @@ -/** - * The object interface for CloudEvents 1.0. - * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md - */ -export interface CloudEventV1 extends CloudEventV1Attributes { - // REQUIRED Attributes - /** - * [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id` - * is unique for each distinct event. If a duplicate event is re-sent (e.g. due - * to a network error) it MAY have the same `id`. Consumers MAY assume that - * Events with identical `source` and `id` are duplicates. - * @required Non-empty string. Unique within producer. - * @example An event counter maintained by the producer - * @example A UUID - */ - id: string; - - /** - * [REQUIRED] The version of the CloudEvents specification which the event - * uses. This enables the interpretation of the context. Compliant event - * producers MUST use a value of `1.0` when referring to this version of the - * specification. - * @required MUST be a non-empty string. - */ - specversion: string; -} - -export interface CloudEventV1Attributes extends CloudEventV1OptionalAttributes { - /** - * [REQUIRED] Identifies the context in which an event happened. Often this - * will include information such as the type of the event source, the - * organization publishing the event or the process that produced the event. The - * exact syntax and semantics behind the data encoded in the URI is defined by - * the event producer. - * Producers MUST ensure that `source` + `id` is unique for each distinct event. - * An application MAY assign a unique `source` to each distinct producer, which - * makes it easy to produce unique IDs since no other producer will have the same - * source. The application MAY use UUIDs, URNs, DNS authorities or an - * application-specific scheme to create unique `source` identifiers. - * A source MAY include more than one producer. In that case the producers MUST - * collaborate to ensure that `source` + `id` is unique for each distinct event. - * @required Non-empty URI-reference - */ - source: string; - - /** - * [REQUIRED] This attribute contains a value describing the type of event - * related to the originating occurrence. Often this attribute is used for - * routing, observability, policy enforcement, etc. The format of this is - * producer defined and might include information such as the version of the - * `type` - see - * [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes) - * for more information. - * @required MUST be a non-empty string - * @should SHOULD be prefixed with a reverse-DNS name. The prefixed domain dictates the - * organization which defines the semantics of this event type. - * @example com.github.pull.create - * @example com.example.object.delete.v2 - */ - type: string; -} - -export interface CloudEventV1OptionalAttributes { - /** - * The following fields are optional. - */ - - /** - * [OPTIONAL] Content type of `data` value. This attribute enables `data` to - * carry any type of content, whereby format and encoding might differ from that - * of the chosen event format. For example, an event rendered using the - * [JSON envelope](./json-format.md#3-envelope) format might carry an XML payload - * in `data`, and the consumer is informed by this attribute being set to - * "application/xml". The rules for how `data` content is rendered for different - * `datacontenttype` values are defined in the event format specifications; for - * example, the JSON event format defines the relationship in - * [section 3.1](./json-format.md#31-handling-of-data). - */ - datacontenttype?: string; - /** - * [OPTIONAL] Identifies the schema that `data` adheres to. Incompatible - * changes to the schema SHOULD be reflected by a different URI. See - * [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes) - * for more information. - * If present, MUST be a non-empty URI. - */ - dataschema?: string; - /** - * [OPTIONAL] This describes the subject of the event in the context of the - * event producer (identified by `source`). In publish-subscribe scenarios, a - * subscriber will typically subscribe to events emitted by a `source`, but the - * `source` identifier alone might not be sufficient as a qualifier for any - * specific event if the `source` context has internal sub-structure. - * - * Identifying the subject of the event in context metadata (opposed to only in - * the `data` payload) is particularly helpful in generic subscription filtering - * scenarios where middleware is unable to interpret the `data` content. In the - * above example, the subscriber might only be interested in blobs with names - * ending with '.jpg' or '.jpeg' and the `subject` attribute allows for - * constructing a simple and efficient string-suffix filter for that subset of - * events. - * - * If present, MUST be a non-empty string. - * @example "https://example.com/storage/tenant/container" - * @example "mynewfile.jpg" - */ - subject?: string; - /** - * [OPTIONAL] Timestamp of when the occurrence happened. If the time of the - * occurrence cannot be determined then this attribute MAY be set to some other - * time (such as the current time) by the CloudEvents producer, however all - * producers for the same `source` MUST be consistent in this respect. In other - * words, either they all use the actual time of the occurrence or they all use - * the same algorithm to determine the value used. - * @example "2020-08-08T14:48:09.769Z" - */ - time?: Date | string; - /** - * [OPTIONAL] The event payload. This specification does not place any restriction - * on the type of this information. It is encoded into a media format which is - * specified by the datacontenttype attribute (e.g. application/json), and adheres - * to the dataschema format when those respective attributes are present. - */ - data?: Record | string | number | boolean | null | unknown; - - /** - * [OPTIONAL] The event payload encoded as base64 data. This is used when the - * data is in binary form. - * @see https://github.com/cloudevents/spec/blob/v1.0/json-format.md#31-handling-of-data - */ - data_base64?: string; - - /** - * [OPTIONAL] CloudEvents extension attributes. - */ - [key: string]: unknown; -} diff --git a/src/event/v1/index.ts b/src/event/v1/index.ts deleted file mode 100644 index e207dd4..0000000 --- a/src/event/v1/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./cloudevent"; -export * from "./spec"; -export * from "./schema"; diff --git a/src/event/v1/spec.ts b/src/event/v1/spec.ts deleted file mode 100644 index e4af5a8..0000000 --- a/src/event/v1/spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import Ajv from "ajv"; -import { v4 as uuidv4 } from "uuid"; - -import { CloudEvent } from "../cloudevent"; -import { CloudEventV1, CloudEventV1Attributes } from "./cloudevent"; -import { ValidationError } from "../validation"; - -import { schemaV1 } from "./schema"; - -const ajv = new Ajv({ extendRefs: true }); -const isValidAgainstSchema = ajv.compile(schemaV1); - -export function createV1(attributes: CloudEventV1Attributes): CloudEventV1 { - const event: CloudEventV1 = { - specversion: schemaV1.definitions.specversion.const, - id: uuidv4(), - time: new Date().toISOString(), - ...attributes, - }; - return new CloudEvent(event); -} - -export function validateV1(event: CloudEventV1): boolean { - if (!isValidAgainstSchema(event)) { - throw new ValidationError("invalid payload", isValidAgainstSchema.errors); - } - return true; -} diff --git a/src/index.ts b/src/index.ts index 3f630b7..b77e2e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,7 @@ -import { - CloudEvent, - CloudEventV03, - CloudEventV03Attributes, - CloudEventV1, - CloudEventV1Attributes, - ValidationError, - Version, -} from "./event"; +import { CloudEvent, Version } from "./event/cloudevent"; +import { ValidationError } from "./event/validation"; +// import {Version} from './event/' +import { CloudEventV03, CloudEventV03Attributes, CloudEventV1, CloudEventV1Attributes } from "./event/interfaces"; import { Emitter, Receiver, Mode, Protocol, TransportOptions } from "./transport"; import { Headers, headersFor } from "./transport/http/headers"; diff --git a/src/transport/emitter.ts b/src/transport/emitter.ts index 316d39e..2cc9d9d 100644 --- a/src/transport/emitter.ts +++ b/src/transport/emitter.ts @@ -1,4 +1,4 @@ -import { CloudEvent } from "../event"; +import { CloudEvent } from "../event/cloudevent"; import { emitBinary, emitStructured } from "./http"; import { Protocol } from "."; import { AxiosResponse } from "axios"; diff --git a/src/transport/http/binary_emitter.ts b/src/transport/http/binary_emitter.ts index cdaa0dc..1ea8eb0 100644 --- a/src/transport/http/binary_emitter.ts +++ b/src/transport/http/binary_emitter.ts @@ -1,6 +1,6 @@ import axios, { AxiosRequestConfig, AxiosResponse } from "axios"; -import { CloudEvent, Version } from "../../event"; +import { CloudEvent, Version } from "../../event/cloudevent"; import { TransportOptions } from "../emitter"; import { Headers, headersFor } from "./headers"; import { asData } from "../../event/validation"; diff --git a/src/transport/http/binary_receiver.ts b/src/transport/http/binary_receiver.ts index 83cda5c..91fd579 100644 --- a/src/transport/http/binary_receiver.ts +++ b/src/transport/http/binary_receiver.ts @@ -1,6 +1,6 @@ import { CloudEvent, Version } from "../.."; -import { CloudEventV1, validateV1 } from "../../event/v1"; -import { CloudEventV03, validateV03 } from "../../event/v03"; +import { CloudEventV1, CloudEventV03 } from "../../event/interfaces"; +import { validateV1, validateV03 } from "../../event/spec"; import { Headers, validate } from "./headers"; import { binaryParsers as v1Parsers } from "./v1"; import { binaryParsers as v03Parsers } from "./v03"; diff --git a/src/transport/http/headers.ts b/src/transport/http/headers.ts index 22506cf..8c80074 100644 --- a/src/transport/http/headers.ts +++ b/src/transport/http/headers.ts @@ -1,7 +1,7 @@ import { ValidationError, CloudEvent } from "../.."; import { headerMap as v1Map } from "./v1"; import { headerMap as v03Map } from "./v03"; -import { Version } from "../../event"; +import { Version } from "../../event/cloudevent"; import { MappedParser } from "../../parsers"; import CONSTANTS from "../../constants"; diff --git a/src/transport/http/structured_emitter.ts b/src/transport/http/structured_emitter.ts index b147d33..af6ec6b 100644 --- a/src/transport/http/structured_emitter.ts +++ b/src/transport/http/structured_emitter.ts @@ -1,5 +1,5 @@ import axios, { AxiosRequestConfig, AxiosResponse } from "axios"; -import { CloudEvent } from "../../event"; +import { CloudEvent } from "../../event/cloudevent"; import { TransportOptions } from "../emitter"; import CONSTANTS from "../../constants"; diff --git a/src/transport/http/structured_receiver.ts b/src/transport/http/structured_receiver.ts index afff110..9a073ba 100644 --- a/src/transport/http/structured_receiver.ts +++ b/src/transport/http/structured_receiver.ts @@ -5,8 +5,8 @@ import { parserByContentType } from "../../parsers"; import { structuredParsers as v1Parsers } from "./v1"; import { structuredParsers as v03Parsers } from "./v03"; import { isString, isBase64, ValidationError, isStringOrObjectOrThrow } from "../../event/validation"; -import { CloudEventV1, validateV1 } from "../../event/v1"; -import { CloudEventV03, validateV03 } from "../../event/v03"; +import { CloudEventV1, CloudEventV03 } from "../../event/interfaces"; +import { validateV1, validateV03 } from "../../event/spec"; import CONSTANTS from "../../constants"; /** diff --git a/src/transport/receiver.ts b/src/transport/receiver.ts index aeb0459..5c83ec5 100644 --- a/src/transport/receiver.ts +++ b/src/transport/receiver.ts @@ -2,8 +2,7 @@ import { Headers, sanitize } from "./http/headers"; import { CloudEvent, Version, ValidationError } from ".."; import { BinaryHTTPReceiver as BinaryReceiver } from "./http/binary_receiver"; import { StructuredHTTPReceiver as StructuredReceiver } from "./http/structured_receiver"; -import { CloudEventV03 } from "../event/v03"; -import { CloudEventV1 } from "../event/v1"; +import { CloudEventV1, CloudEventV03 } from "../event/interfaces"; import CONSTANTS from "../constants"; /** diff --git a/test/integration/cloud_event_test.ts b/test/integration/cloud_event_test.ts index 8a98a62..7de5da7 100644 --- a/test/integration/cloud_event_test.ts +++ b/test/integration/cloud_event_test.ts @@ -1,7 +1,6 @@ import { expect } from "chai"; import { CloudEvent, Version } from "../../src"; -import { CloudEventV03 } from "../../src/event/v03"; -import { CloudEventV1 } from "../../src/event/v1"; +import { CloudEventV03, CloudEventV1 } from "../../src/event/interfaces"; const type = "org.cncf.cloudevents.example"; const source = "http://unit.test"; diff --git a/test/integration/http_receiver_test.ts b/test/integration/http_receiver_test.ts index 308ecc5..20a88f9 100644 --- a/test/integration/http_receiver_test.ts +++ b/test/integration/http_receiver_test.ts @@ -1,7 +1,7 @@ import "mocha"; import { expect } from "chai"; import { CloudEvent, Receiver, ValidationError } from "../../src"; -import { CloudEventV1 } from "../../src/event/v1"; +import { CloudEventV1 } from "../../src/event/interfaces"; const id = "1234"; const type = "org.cncf.cloudevents.test";