Skip to content

Remove All Version-Specific Methods #275

Closed

Description

@grant

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);
}

Activity

  1. lholmquist commented on Jul 27, 2020

    @lholmquist
    Contributor

    It looks like #277 addresses at least those 2 functions from above

  2. lance commented on Aug 17, 2020

    @lance
    Member

    @lholmquist there are no other version specific functions that I am aware of being exported at the top level. I am closing this. @grant - If there are specific functions in nested files that should be addressed, please open a specific issue for them.

  3. grant commented on Aug 17, 2020

    @grant
    MemberAuthor

    Yup, looks good to close @lance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions