const { jsonEvent } = require("@eventstore/db-client");
const { v4 } = require('uuid');
const uuidv4 = v4;
class Event {

    // extra info if needed
    extra = {};

    //isJson
    isJson = true;

    constructor(eventType, data, extra = {}) {
        this.eventType = eventType;
        this.data = data;
        this.extra = extra;
    }

    send() {
        return jsonEvent({
            id: uuidv4(),
            type: this.eventType,
            data: this.data
        })
    }

}

exports.Event = Event;