Overview of supported events

This page describes all events supported by the graph-cqrs module

Elements Added

Elements Deleted

Properties Set

Properties Deleted

General event structure

All Events have five properties:

sourceId
This property is the identifier of the command that triggered this event. It has to be a RFC4122 v4 compliant ID.

version
This property indicates the version of the graph as a result of applying this event. The version number is used to deduplicate events and might indicate missing events.

type
This string represents the type of the command, which is used when parsing the command.

timestamp
The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.

Parsing Events

Javascript/Typescript developers can reuse the EventFactory class inside the cubitt-events package. This class provides a static method parse which attempts to parse a event from a JSON object. It throws errors on failure.

var events = require("cubitt-events");

let jsonEvent = { /* jsonObject here */ };

try {
 var result = events.EventFactory.parse(jsonEvent); 
} catch(err) {
  // Do something with the error
}

Added Events

Model Added

A model can both be a top level element, or a child element

Top level Model

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
	 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
	 * @param version The new current version number.
	 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
	 * @param elementId The RFC4122 v4 compliant ID of the new element.
	 * @param elementType The type of the new element.
	 * @param elementProperties The properties of the new element.
   * @param parentId The ID of the optional parent element
	 */
var topLevelModelAddedEvent = new events.ModelAddedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "EXAMPLE_MODEL",
    {"key" : "value" }
);
{
    "sourceId": "134a45fd-f245-45c3-be9b-a859e1148334",
    "version": 1,
    "type": "ModelAddedEvent",
    "timestamp": 1465149054038,
    "elementId": "58ba7efc-957e-4fd1-b41a-7b218302130e",
    "elementType": "EXAMPLE_MODEL",
    "elementProperties": {
        "key": "value"
    }
}

Child level Model

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
	 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
	 * @param version The new current version number.
	 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
	 * @param elementId The RFC4122 v4 compliant ID of the new element.
	 * @param elementType The type of the new element.
	 * @param elementProperties The properties of the new element.
   * @param parentId The ID of the optional parent element
	 */
var childLevelModelAddedEvent = new events.ModelAddedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "EXAMPLE_MODEL",
    {"key" : "value" },
  	common.Guid.newGuid()
);
{
    "sourceId": "08774b65-aa05-406c-abf4-f7dffcfe39a7",
    "version": 1,
    "type": "ModelAddedEvent",
    "timestamp": 1465149186646,
    "elementId": "d126c44a-1327-4f1e-8a2d-59351e3b4e0d",
    "elementType": "EXAMPLE_MODEL",
    "elementProperties": {
        "key": "value"
    },
    "parentId": "f7962be4-f1e3-4931-abac-3ac465cce07c"
}

Node Added

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the new element.
 * @param elementType The type of the new element.
 * @param elementProperties The properties of the new element.
 * @param modelId The RFC4122 v4 compliant ID of the model to which the new node belongs.
 */
var event = new events.NodeAddedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "EXAMPLE_NODE",
    {"key" : "value" },
    common.Guid.newGuid()
);
{
    "sourceId": "14c766d6-336e-401d-b932-24aba2cc7d16",
    "version": 1,
    "type": "NodeAddedEvent",
    "timestamp": 1465149232371,
    "elementId": "70e3f508-0f22-45a7-92ab-04ae7ea58878",
    "elementType": "EXAMPLE_NODE",
    "elementProperties": {
        "key": "value"
    },
    "modelId": "d4ebccd2-364c-4d74-a4f0-6a4140b5d0e6"
}

Connector Added

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the new element.
 * @param elementType The type of the new element.
 * @param elementProperties The properties of the new element.
 * @param nodeId The RFC4122 v4 compliant ID of the node to which the new connector belongs.
 */
var event = new events.ConnectorAddedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "EXAMPLE_CONNECTOR",
    {"key" : "value" },
    common.Guid.newGuid()
);
{
    "sourceId": "5667ec15-3382-432d-a85a-f5465ecdc01a",
    "version": 1,
    "type": "ConnectorAddedEvent",
    "timestamp": 1465149360376,
    "elementId": "0bbe576a-cbed-47c8-b50d-86eb3c056284",
    "elementType": "EXAMPLE_CONNECTOR",
    "elementProperties": {
        "key": "value"
    },
    "nodeId": "1b2b0d15-ef35-4c5d-bd41-7d0289e41893"
}

Edge Added

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the new element.
 * @param elementType The type of the new element.
 * @param elementProperties The properties of the new element.
 * @param modelId The RFC4122 v4 compliant ID of the model to which the new edge belongs.
 * @param startConnectorId The RFC4122 v4 compliant ID of the connector where the new edge starts.
 * @param endConnectorId The RFC4122 v4 compliant ID of the connector where the new edge ends.
 */
var event = new events.EdgeAddedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "EXAMPLE_EDGE",
    {"key" : "value" },
    common.Guid.newGuid(),
    common.Guid.newGuid(),
    common.Guid.newGuid()
);
{
    "sourceId": "d9f1ba95-8000-4ab5-af89-4f03216c8f91",
    "version": 1,
    "type": "EdgeAddedEvent",
    "timestamp": 1465149675205,
    "elementId": "260e3a81-3b3d-4add-89cb-6f49d5fa0663",
    "elementType": "EXAMPLE_EDGE",
    "elementProperties": {
        "key": "value"
    },
    "modelId": "b0e4398d-ea3a-4957-83bd-478a1a328432",
    "startConnectorId": "8f686ea5-f1ab-4ee3-bc80-088c85e7ea5b",
    "endConnectorId": "f6fb4645-9a0d-4644-b9e8-78f7ae50ddf5"
}

Deleted Events

Model Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the deleted element.
 */
var event = new events.ModelDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid()
);
{
    "sourceId": "21087380-a194-4c1b-94af-2c943967d49c",
    "version": 1,
    "type": "ModelDeletedEvent",
    "timestamp": 1465149807263,
    "elementId": "fdc71579-507d-4355-b9bd-443bdb560b2c"
}

Node Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the deleted element.
 */
var event = new events.NodeDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid()
);
{
    "sourceId": "6a7fa710-6d20-4914-ae58-8cf6e5f6ae70",
    "version": 1,
    "type": "NodeDeletedEvent",
    "timestamp": 1465149892266,
    "elementId": "0c5ab34a-be3b-4d5f-8a9f-f73da8041294"
}

Connector Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the deleted element.
 */
var event = new events.ConnectorDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid()
);
{
    "sourceId": "8734a10e-6ca1-4f8a-96d7-db4467d8eff5",
    "version": 1,
    "type": "ConnectorDeletedEvent",
    "timestamp": 1465149918224,
    "elementId": "0c51e353-138e-4360-adc9-460516c21ae8"
}

Edge Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the deleted element.
 */
var event = new events.EdgeDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid()
);
{
    "sourceId": "2a77d49d-3a02-4c47-a7a7-dbe66021ca04",
    "version": 1,
    "type": "EdgeDeletedEvent",
    "timestamp": 1465149987823,
    "elementId": "eaaf8887-7997-4be1-945e-e61062f88970"
}

Property Set Events

Model Property Set

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element for which the property was set.
 * @param propertyName The name of the property that was set.
 * @param propertyValue The value of the property that was set.
 */
var event = new events.ModelPropertySetEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname",
  	"value"
);
{
    "sourceId": "4b681592-1bd8-410e-8ffc-0a10483c0d99",
    "version": 1,
    "type": "ModelPropertySetEvent",
    "timestamp": 1465150149414,
    "elementId": "113cbd2a-5896-47d4-99a2-49c468751626",
    "propertyName": "propertyname",
    "propertyValue": "value"
}

Node Property Set

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element for which the property was set.
 * @param propertyName The name of the property that was set.
 * @param propertyValue The value of the property that was set.
 */
var event = new events.NodePropertySetEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname",
  	"value"
);
{
    "sourceId": "20e135aa-39b5-4a98-8d00-e88527e79296",
    "version": 1,
    "type": "NodePropertySetEvent",
    "timestamp": 1465150201131,
    "elementId": "fa9a4a2d-9c40-4d8a-8925-3c50cd92544b",
    "propertyName": "propertyname",
    "propertyValue": "value"
}

Connector Property Set

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element for which the property was set.
 * @param propertyName The name of the property that was set.
 * @param propertyValue The value of the property that was set.
 */
var event = new events.ConnectorPropertySetEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname",
  	"value"
);
{
    "sourceId": "d2d33817-b095-414f-90f2-898e508fb341",
    "version": 1,
    "type": "ConnectorPropertySetEvent",
    "timestamp": 1465150241578,
    "elementId": "1a06c9da-19ed-45a9-86a3-8dac5d4550a5",
    "propertyName": "propertyname",
    "propertyValue": "value"
}

Edge Property Set

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element for which the property was set.
 * @param propertyName The name of the property that was set.
 * @param propertyValue The value of the property that was set.
 */
var event = new events.EdgePropertySetEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname",
  	"value"
);
{
    "sourceId": "408bd320-a448-4fd8-91ae-4380bd7514ca",
    "version": 1,
    "type": "EdgePropertySetEvent",
    "timestamp": 1465150288355,
    "elementId": "49440683-365e-437d-b23d-0179ad062646",
    "propertyName": "propertyname",
    "propertyValue": "value"
}

Element Property Deleted Events

Model Property Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element of which the property was deleted.
 * @param propertyName The name of the property that is deleted.
 */
var event = new events.ModelPropertyDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname"
);
{
    "sourceId": "86b2a01d-190d-42dc-9174-d3e69e7704a6",
    "version": 1,
    "type": "ModelPropertyDeletedEvent",
    "timestamp": 1465150422466,
    "elementId": "3882345f-27d0-43da-90fc-547c40c289b8",
    "propertyName": "propertyname"
}

Node Property Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element of which the property was deleted.
 * @param propertyName The name of the property that is deleted.
 */
var event = new events.NodePropertyDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname"
);
{
    "sourceId": "0a72b40f-f89d-4140-80f7-a94a6ced0c4f",
    "version": 1,
    "type": "NodePropertyDeletedEvent",
    "timestamp": 1465150491911,
    "elementId": "2fce8858-3d87-4740-9d9a-6c83deb88275",
    "propertyName": "propertyname"
}

Connector Property Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element of which the property was deleted.
 * @param propertyName The name of the property that is deleted.
 */
var event = new events.ConnectorPropertyDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname"
);
{
    "sourceId": "23df9f74-3778-4195-8a76-737609ae357f",
    "version": 1,
    "type": "ConnectorPropertyDeletedEvent",
    "timestamp": 1465150533931,
    "elementId": "60d22f13-fbaf-46a2-8b89-c3c3c122ef6a",
    "propertyName": "propertyname"
}

Edge Property Deleted

var common = require("cubitt-common");
var events = require("cubitt-events");

/**
 * @param sourceId The RFC4122 v4 compliant ID of the command that caused this event.
 * @param version The new current version number.
 * @param timestamp The timestamp for the moment this event was created in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
 * @param elementId The RFC4122 v4 compliant ID of the element of which the property was deleted.
 * @param propertyName The name of the property that is deleted.
 */
var event = new events.EdgePropertyDeletedEvent(
    common.Guid.newGuid(),
    1,
    Date.now(),
    common.Guid.newGuid(),
    "propertyname"
);
{
    "sourceId": "ad6cc6ab-7fe2-4c4f-8ce8-7d90b7e69455",
    "version": 1,
    "type": "EdgePropertyDeletedEvent",
    "timestamp": 1465150608999,
    "elementId": "f30c6db4-f04e-4601-9b6c-b077e51ac365",
    "propertyName": "propertyname"
}