Skip to content

A Cloudevent class per spec version #28

Closed

Description

@fabiojose

Today we have just one cloudevent.js that makes the interface with Spec classes. This is ok with vanilla js, because of flexibility which exists in js programming we inject new methods we needed.

Now it's time to stabilize the things. We are reaching the v1.0 and some attribute names are getting stable, in special the required ones: id, source, specversion and type.

We need:

  • a base class with required attributes
  • a class that extends the base one and makes specializations with it's own attributes
  • every implementation MUST follow the immutable object philosophy

Activity

  1. self-assigned this
    on Aug 7, 2019
  2. fabiojose commented on Aug 8, 2019

    @fabiojose
    ContributorAuthor

    @grant What do you think about this definition? May be would be better in ts?

    /*!
     * cloudevents.io
     * Apache-2.0 Licensed
     */
    
    "use strict";
    
    /**
     * CloudEvent prototype
     *
     * @example
     * let event = new CloudEvent("A234-1234-1234", "https://github.com/cloudevents/spec/pull", "com.github.pull.create", {
     *     "comexampleextension1" : "value",
     *     "comexampleextension2" : {
     *         "othervalue" : 5
     *     }
     * });
     *
     * @constructor
     * @class
     * @param {String} id - Identifies the event
     * @param {String} source - Identifies the context in which an event happened
     * @param {String} type - The originating occurrence
     * @param {Object} extensions - Custom additional context attributes
    
     * @param {Object} data - Data attribute
     * @public
     */
    function CloudEvent(id, source, type, extensions, data) {
    
    }
    
    CloudEvent.prototype.data = (data) => {
    
    };
    
    /**
     * Returns the internal representation of context attributes, extension
     * attribute and data attribute.
     *
     * @example
     * let event = new CloudEvent("A234-1234-1234", "https://github.com/cloudevents/spec/pull", "com.github.pull.create");
     * event
     *   .then((payload) => {
     *     // use the event payload, which is valid
     *     payload.id;
     *     payload.source;
     *     payload.specversion;
     *   })
     *   .catch((err) => {
     *     // threat the err reporting an invalid payload
     *   });
     *
     * @return {Promise} To resolve the event as object notation
     * @public
     */
    CloudEvent.prototype.asObject = () => {
    
    };
    
    /**
     * Validates the payload against the definitions, but if something
     * is wrong throws and exception.
     *
     */
    CloudEvent.prototype.validate = () => {
    
    };
    
    module.exports = CloudEvent;
  3. grant commented on Aug 8, 2019

    @grant
    Member

    Looks ok.
    Would be much better with modern javascript (class) or TypeScript.

  4. fabiojose commented on Aug 8, 2019

    @fabiojose
    ContributorAuthor

    @grant Would like to help us with these definitions?

  5. grant commented on Sep 30, 2019

    @grant
    Member

    @fabiojose Sent email to you to discuss more first.

  6. lance commented on May 9, 2020

    @lance
    Member

    Given how the repo has evolved since this issue has been opened, I suggest closing this. @grant @fabiojose WDYT?

  7. fabiojose commented on May 9, 2020

    @fabiojose
    ContributorAuthor

    It's ok for me.

  8. lance commented on May 11, 2020

    @lance
    Member

    @fabiojose OK closing for now - as things progress we may revisit this, or not. :)

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

Metadata

Metadata

Assignees

Labels

type/enhancementNew feature or requestversion/1.xIssues related to version 1.x of this library

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions