The unique identifier of the diagram, which is used to reference the diagram within the application and for serialization purposes.
An array of nodes that belong to the diagram, which represent the entities and elements that can be connected and manipulated within the diagram.
An optional array of groups that belong to the diagram, which can be used to organize nodes into visual collections. Grouped nodes maintain their relative positions.
An array of layers that belong to the diagram, which can be used to organize nodes into different visual layers.
Optionalsheet_An optional identifier for the sheet associated with the diagram, which can be used to apply specific styles and configurations to the diagram's nodes and connections.
OptionalbackgroundAn optional background fill style for the diagram, which can be used to set the background color or gradient of the diagram area.
OptionalmetaAn optional metadata object for the diagram, which can be used to store additional information about the diagram that is not part of its core structure. This can include custom properties, annotations, or any other relevant data that is not related to diagram rendering.
The diagram's sheet repository, for managing and applying spec sheets to the diagram and its nodes.
The SheetRepository instance associated with the diagram.
Sets the diagram's sheet repository, allowing for the management and application of spec sheets to the diagram and its nodes.
The SheetRepository instance to set for the diagram. Cannot be null or undefined.
The diagram's asset store, for registering and resolving image/SVG asset sources.
The AssetStore instance associated with the diagram.
Gets the metadata object for the diagram. If no metadata exists, an empty object is returned.
The metadata object for the diagram.
Sets the metadata object for the diagram. If a null or undefined value is provided, the metadata is cleared.
The metadata object to set for the diagram.
Releases model-managed resources.
Retrieves a node by its ID.
The ID of the node to retrieve.
The node with the specified ID, or undefined if not found.
Returns a group by its ID.
The ID of the group to return.
The group with the specified ID, or undefined if not found.
Retrieves a layer by its ID.
The ID of the layer to retrieve.
The layer with the specified ID, or undefined if not found.
Add or remove a node from a group. If the groupId is undefined, the node is removed from any group it belongs to. A node can only belong to one group at a time. If the node is already in a different group, it will be removed from that group before being added to the new group.
The node or node ID to add to the group.
The ID of the group to add the node to, or undefined to remove the node from any group.
ProtectedgroupAdd or remove a node from a layer. If the layerId is undefined, the node is removed from any layer it belongs to. A node can only belong to one layer at a time. If the node is already in a different layer, it will be removed from that layer before being added to the new layer.
The node or node ID to add to the layer.
The ID of the layer to add the node to, or undefined to remove the node from any layer.
Deletes a node from the diagram.
The ID of the node to delete.
Deletes a group from the diagram. Effectively ungrouping nodes.
The ID of the group to delete.
Deletes a layer from the diagram.
The ID of the layer to delete.
Resolves the concrete image source for a node image reference.
Clears all in-memory image assets. Intended for teardown paths.
Clears all nodes, layers, metadata, and assets from the diagram, effectively resetting it to an empty state while retaining the same ID. Intended for reuse scenarios where the diagram instance should be preserved but its content should be cleared.
Gets the value of a specific metadata key for the diagram.
Optionalkey: stringThe key of the metadata to retrieve.
The value of the specified metadata key, or undefined if the key does not exist.
Sets the value of a specific metadata key for the diagram.
The key of the metadata to set.
The value to set for the specified metadata key.
Deletes a specific metadata key from the diagram.
Optionalkey: stringThe key of the metadata to delete. If not provided, all metadata for the diagram is deleted.
Gets the value of a specific metadata key for a node.
The node or node ID to retrieve metadata from.
The key of the metadata to retrieve.
The value of the specified metadata key, or undefined if the key does not exist.
Sets the value of a specific metadata key for a node.
The node or node ID to set metadata for.
The key of the metadata to set.
The value to set for the specified metadata key.
Deletes a specific metadata key from a node.
The node or node ID to delete metadata from.
Optionalkey: stringThe key of the metadata to delete. If not provided, all metadata for the node is deleted.
Loads the diagram data from a serialized JSON object.
The serialized diagram data.
Optionalserializer: ISerializerThe serializer to use for reading the data (optional if source is already an object).
The diagram instance.
Writes the diagram data to the specified serializer.
The serializer to use for writing the data.
The serialized diagram data.
Exports the current diagram in a native format. Supported formats are JSON text, UTF-8 bytes, and Blob (browser runtime).
The format to export the diagram in ('json', 'bytes', or 'blob'). (defaults to 'json')
Whether to pretty-print the output (applicable to JSON format). (defaults to true)
The serializer to use for exporting the diagram. (optional)
The exported diagram data in the specified format.
Saves the current diagram directly from the model. In Node.js this writes to the file system; in browsers this triggers a file download.
The options for saving the diagram, including path, file name, serializer, pretty-printing, and MIME type.
A promise that resolves to the path or download URL of the saved file.
ProtectedapplyProtectedserializeProtectedserializeProtectedcreateCreates a new layer with the specified properties.
The ID of the layer.
The name of the layer.
Whether the layer is visible.
The nodes within the layer.
The created layer.
A diagram is the core data structure that holds all nodes, layers, and metadata. It provides methods for managing these elements and supports serialization and deserialization for persistence and data exchange.
It does not support viewing. For that, use DiagramView which extends this base model and adds rendering, selection, and interaction capabilities. It does not support editing. For that, use DiagramController which manages user interactions and updates the Diagram model accordingly.