Closed
Description
Describe the Bug
This module includes a lot of public methods that assume there are are only 2 versions of the spec. We shouldn't copy-and-paste functions across versions. Rather, we should just pass a parameter to specify the CloudEvent version.
Here's an example:
Actual
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 createV03(attributes: CloudEventV03Attributes): CloudEventV03 {
const event: CloudEventV03 = {
specversion: schemaV03.definitions.specversion.const,
id: uuidv4(),
time: new Date().toISOString(),
...attributes,
};
return new CloudEvent(event);
}
Expected
export function create(attributes: CloudEventV03Attributes | CloudEventV1Attributes): CloudEvent {
...
return new CloudEvent(event);
}
Metadata
Metadata
Assignees
Labels
No labels