Overview of supported commands

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

Adding Elements

Deleting Elements

Setting Properties

Deleting Properties

General command structure

All Commands have three properties:

id
This property is a unique identifier for this particular command. It has to be a RFC4122 v4 compliant ID.

requestId
This property is a unique identifier for this particular request to the CQRS graph. In case only a single command is sent within the transaction, the requestId can be the same as the id.

sessionId
This property is a unique identifier for a particular (user) session. It is logged to improve debugging.

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

Parsing commands

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

🚧

Semantic validation

The CommandFactory only validates the syntax of the provided command, and does not check for duplicate elementId's or any other semantic errors.

var commands = require("cubitt-commands"); let jsonCommand = { /* jsonObject here */ }; try { var result = commands.CommandFactory.parse(jsonCommand); } catch(err) { // Do something with the error }

Add Commands

Add Model

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

Top level Model

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the new model. * @param elementType The type of the new model. * @param elementProperties The properties of the new model. * @param parentId The optional ID of the parent element */ var topLevelModelCommand = new commands.AddModelCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "EXAMPLE_MODEL", {"key" : "value" } );
{ "type" : "AddModelCommand", "elementType": "EXAMPLE_MODEL", "id" : "cee937c6-e890-423f-8f1b-1076d81c1894", "requestId" : "076db581-a705-4cf3-9254-87fbdda6f7f8", "sessionId" : "3cb87ad9-54ba-473a-bd09-247d42c1c95b", "elementId" : "e24311f8-1f2c-4972-a313-8b871430af33", "elementProperties" : { "key" : "value" } }

Child level Model

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the new model. * @param elementType The type of the new model. * @param elementProperties The properties of the new model. * @param parentId The optional ID of the parent element */ var childModelCommand = new commands.AddModelCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "EXAMPLE_MODEL", {"key" : "value" }, common.Guid.newGuid(), );
{ "id":"be27ff29-e258-4898-b4d1-f169d738b6a6", "requestId":"04aa2fa5-98b9-4a8c-8655-e079baed5383", "sessionId":"119d6c4f-4856-44dd-9032-295234a0c53d", "type":"AddModelCommand", "elementId":"847a3d48-acf2-4c95-91ad-b688134262df", "elementType":"EXAMPLE_MODEL", "elementProperties":{ "key":"value" }, "ParentId":"330325be-848d-4ca9-9cb1-5b9053528e75" }

Add Node

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the new node. * @param elementType The type of the new node. * @param elementProperties The properties of the new node. * @param modelId The RFC4122 v4 compliant ID of the model to which the new node belongs. */ var addNodeCommand = new commands.AddNodeCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "EXAMPLE_NODE", {"key" : "value" }, common.Guid.newGuid(), );
{ "id":"d1929101-c53b-4c47-806e-98767a810263", "requestId":"81f1baab-830a-4321-a9c1-4c548d6673ea", "sessionId":"63d94b4d-87f7-43af-b862-f56bfdd500c9", "type":"AddNodeCommand", "elementId":"b28c749a-c6dd-42d2-86b6-722d4de8e537", "elementType":"EXAMPLE_NODE", "elementProperties":{ "key":"value" }, "modelId":"cd51d469-04c4-4379-b5d2-64dd29224cbf" }

Add Connector

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the new connector. * @param elementType The type of the new connector. * @param elementProperties The properties of the new connector. * @param nodeId The RFC4122 v4 compliant ID of the node to which the new connector belongs. */ var addConnectorCommand = new commands.AddConnectorCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "EXAMPLE_NODE", {"key" : "value" }, common.Guid.newGuid(), );
{ "id":"b2e7608b-e3c0-4768-8e18-bcab07358f55", "requestId":"201026a9-3c8f-41de-91a8-37c7cc757f51", "sessionId":"b24a4912-349f-40d7-9677-4ac60a342482", "type":"AddConnectorCommand", "elementId":"324c1b35-1ba3-455c-8fcb-d9baefded311", "elementType":"EXAMPLE_CONNECTOR", "elementProperties":{ "key":"value" }, "nodeId":"8d7dc805-15c2-422f-a2ac-414ff8852496" }

Add Edge

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the new edge. * @param elementType The type of the new edge. * @param elementProperties The properties of the new edge. * @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 starting point of the new edge. * @param endConnectorId The RFC4122 v4 compliant ID of the end point of the new edge. */ var addEdgeCommand = new commands.AddEdgeCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "TEST_EDGE", {"key" : "value" }, common.Guid.newGuid(), guid(), guid() );
{ "id":"fc768a6b-816d-4398-a1d3-306b4fffe552", "requestId":"eaf2c397-ed5f-44bb-8255-f33c2dbfacc7", "sessionId":"c7d6e5f8-8ea9-49f4-a05a-18f69bfc04cb", "type":"AddEdgeCommand", "elementId":"5eb17c2e-cc07-4c1f-98c7-0f6512f4efd2", "elementType":"TEST_EDGE", "elementProperties":{ "key":"value" }, "modelId":"4d5c6565-df9a-464a-b3bc-6ee248d64e62", "startConnectorId":"cbcd9422-d91c-47bc-83c0-c0464abd4c22", "endConnectorId":"f0af422d-22da-4fe1-86b3-4a7bbb3edbf9" }

Delete Commands

Delete Model

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the model that has to be deleted. */ var deleteModelCommand = new commands.DeleteModelCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), );
{ "id":"45e88260-fea5-45dd-855a-a268967aee6c", "requestId":"5f9595ae-e438-4890-8449-99a22982ed40", "sessionId":"fcb68a6f-1697-4d64-bc8c-d79ab6925108", "type":"DeleteModelCommand", "elementId":"2a5eafc2-d9a4-4c5b-be28-5d309f3c708f" }

Delete Node

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the node that has to be deleted. */ var deleteNodeCommand = new commands.DeleteNodeCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), );
{ "id":"51f015bf-e6cd-4304-95b2-d4440ac71220", "requestId":"0b1e9e69-6ec3-4c29-859e-092e3fa66c3f", "sessionId":"eb08ff3a-9ac8-4391-9ae3-c6c11c05b8bf", "type":"DeleteNodeCommand", "elementId":"ccfbf32f-3bcc-4ec7-9bb4-78a9c9cfa40f" }

Delete Connector

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the connector that has to be deleted. */ var deleteConnectorCommand = new commands.DeleteConnectorCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), );
{ "id":"ef55a062-ef17-4ba3-aa65-4647ef4cba16", "requestId":"b9ba5ad8-367a-4673-ae96-0181af17cf24", "sessionId":"e08d2239-6665-45fa-857d-6568a5109f2c", "type":"DeleteConnectorCommand", "elementId":"125cb3fe-2cef-489e-b193-7a4cbe74fbed" }

Delete Edge

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the edge that has to be deleted. */ var deleteEdgeCommand = new commands.DeleteEdgeCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), );
{ "id":"16228459-eb5b-44d1-9c79-46d81c415ca4", "requestId":"a63678c3-680d-40a9-8de7-c9685f6711ef", "sessionId":"7900836e-c390-4f4b-9077-5bd2ba2e20b7", "type":"DeleteEdgeCommand", "elementId":"174f95a9-d288-4b74-8e66-d3105aa74982" }

Set Property Commands

Set Model Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the model with the property that has to be set. * @param propertyName The name of the property that has to be set. * @param propertyValue The value of the property that has to be set. */ var setModelPropertyCommand = new commands.SetModelPropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname", "value" );
{ "id":"96df38f4-8764-439d-9594-64537d3e8916", "requestId":"5f71a078-4610-408b-822d-d21b3f4943c0", "sessionId":"b419950c-0e2e-4fe7-b1e9-5be459998828", "type":"SetModelPropertyCommand", "elementId":"889c5f10-0614-4992-94bb-f1131962fc42", "propertyName":"propertyname", "propertyValue":"value" }

Set Node Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the node with the property that has to be set. * @param propertyName The name of the property that has to be set. * @param propertyValue The value of the property that has to be set. */ var setNodePropertyCommand = new commands.SetNodePropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname", "value" );
{ "id":"7d15ed0d-0369-47fd-8243-fa42fa4dcd56", "requestId":"c5777f2a-dc5d-4698-99e7-071d97afbeb0", "sessionId":"db9b1c3d-d09f-4b17-a4f5-39f2b0519648", "type":"SetNodePropertyCommand", "elementId":"c095471c-e605-486b-889c-578b693155ac", "propertyName":"propertyname", "propertyValue":"value" }

Set Connector Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the connector with the property that has to be set. * @param propertyName The name of the property that has to be set. * @param propertyValue The value of the property that has to be set. */ var setConnectorPropertyCommand = new commands.SetConnectorPropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname", "value" );
{ "id":"46d6047d-36e7-4470-b760-a9451938504d", "requestId":"ce7a0d95-ab83-40c4-9b39-a24b7f879ded", "sessionId":"0cb5c997-588d-4d24-89d3-4b35860b99a3", "type":"SetConnectorPropertyCommand", "elementId":"6a8598d3-8204-42c9-9cdb-6b12c0531484", "propertyName":"propertyname", "propertyValue":"value" }

Set Edge Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the edge with the property that has to be set. * @param propertyName The name of the property that has to be set. * @param propertyValue The value of the property that has to be set. */ var setEdgePropertyCommand = new commands.SetEdgePropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname", "value" );
{ "id": "0cb58198-7908-4aaa-989b-1d44d6ec10e3", "requestId": "6a50d19e-0c05-4a3f-9493-58b5f16ae3e7", "sessionId": "1a31dffd-de12-42b9-8480-4b953df90949", "type": "SetEdgePropertyCommand", "elementId": "f4dea282-b4d7-462b-a5cf-576ae0cbabd3", "propertyName": "propertyname", "propertyValue": "value" }

Delete Element Property Commands

Delete Model Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the model with the property that has to be deleted. * @param propertyName The name of the property that has to be deleted. */ var deleteModelPropertyCommand = new commands.DeleteModelPropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname" );

Delete Node Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the node with the property that has to be deleted. * @param propertyName The name of the property that has to be deleted. */ var deleteNodePropertyCommand = new commands.DeleteNodePropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname" );
{ "id": "742166e0-4b21-4fe0-9958-d49dab7d58e4", "requestId": "52d3e29c-0d36-4af9-b20a-8e5d1a9767c8", "sessionId": "1c71c6fb-e0f6-4ff1-95fc-256c3595d076", "type": "DeleteNodePropertyCommand", "elementId": "9131f11b-b342-493d-8dfd-be10d6884e6e", "propertyName": "propertyname" }

Delete Connector Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the connector with the property that has to be deleted. * @param propertyName The name of the property that has to be deleted. */ var deleteConnectorPropertyCommand = new commands.DeleteConnectorPropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname" );
{ "id": "a41a8bde-d8bd-4ff7-97ea-8bdce624aa9f", "requestId": "4e1ae4ff-50a7-478d-b519-bf6429822c85", "sessionId": "673e3dfb-38af-4184-9969-2aa7b95a59b3", "type": "DeleteConnectorPropertyCommand", "elementId": "118046d3-8bb4-442c-8f32-fcc39ce70d47", "propertyName": "propertyname" }

Delete Edge Property

var common = require("cubitt-common"); var commands = require("cubitt-commands"); /** * @param id The RFC4122 v4 compliant ID of this command. * @param requestId The RFC4122 v4 compliant ID of the request that created this command. * @param sessionId The RFC4122 v4 compliant ID of the session that created this command. * @param elementId The RFC4122 v4 compliant ID of the edge with the property that has to be deleted. * @param propertyName The name of the property that has to be deleted. */ var deleteEdgePropertyCommand = new commands.DeleteEdgePropertyCommand( common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), common.Guid.newGuid(), "propertyname" );
{ "id": "10143436-0d97-4748-bd4d-e4fe55167bb4", "requestId": "cdfeec1c-489e-4c97-af79-e4eb6c3e2b7e", "sessionId": "b9a4bcb9-7cc2-4110-bc7d-31409f66dabf", "type": "DeleteEdgePropertyCommand", "elementId": "a34f1540-f088-4d17-b4bf-04dbfffe3e25", "propertyName": "propertyname" }