Graph.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. namespace RackPeek.Domain.Graph;
  2. public record GraphNode(
  3. string Id,
  4. string Label,
  5. string Kind,
  6. string? Subtitle = null,
  7. IReadOnlyDictionary<string, string>? Data = null,
  8. IReadOnlyList<GraphNodeRow>? Rows = null);
  9. /// <summary>
  10. /// A bullet/list row rendered inside a node label. Used by the logical
  11. /// view to fold a host's services into a single host card.
  12. /// </summary>
  13. public record GraphNodeRow(string Name, string? Detail = null);
  14. public record GraphEdge(
  15. string Source,
  16. string Target,
  17. string? Label,
  18. string Kind,
  19. IReadOnlyDictionary<string, string>? Data = null);
  20. /// <summary>
  21. /// A labelled cluster of nodes. Used to drive Mermaid <c>subgraph</c>
  22. /// blocks. Groups may nest via <see cref="ParentGroupId"/>.
  23. /// </summary>
  24. public record GraphGroup(
  25. string Id,
  26. string Label,
  27. IReadOnlyList<string> NodeIds,
  28. string? ParentGroupId = null);
  29. /// <summary>
  30. /// How a graph should be rendered. <see cref="Standard"/> is the
  31. /// hardware-topology view: one node per resource with shape-based kind
  32. /// signalling. <see cref="Compact"/> is the logical-services view:
  33. /// each host is a single card listing its services as rows, no edges,
  34. /// siblings packed vertically.
  35. /// </summary>
  36. public enum GraphRenderHint {
  37. Standard,
  38. Compact
  39. }
  40. public record Graph(
  41. IReadOnlyList<GraphNode> Nodes,
  42. IReadOnlyList<GraphEdge> Edges,
  43. IReadOnlyList<GraphGroup>? Groups = null,
  44. GraphRenderHint RenderHint = GraphRenderHint.Standard) {
  45. public static Graph Empty { get; } = new([], [], null);
  46. }