@eventcatalog/visualiser 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ import { Node, Edge } from '@xyflow/react';
2
+
3
+ type LayoutGraph = {
4
+ nodes: Node[];
5
+ edges: Edge[];
6
+ };
7
+ type LayoutSize = {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ type EdgeRoute = {
12
+ points: {
13
+ x: number;
14
+ y: number;
15
+ }[];
16
+ label?: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ /** Where the edge's source and target were laid out (top-left, in the flow) */
21
+ source?: {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ target?: {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ };
30
+ /** The size a node is laid out at: as rendered, or an estimate for its type */
31
+ declare const getNodeSize: (node: Node) => LayoutSize;
32
+ /**
33
+ * Lays a graph out with ELK (left to right). Nested groups (nodes other nodes
34
+ * have as their `parentId`) are laid out in one pass with their children.
35
+ * Edges are routed at right angles around nodes, each edge with its own
36
+ * connection point so edges don't run on top of each other, and labels are
37
+ * placed on their edge. Each edge keeps its type and gets its route (and label
38
+ * position) in `data.route`, which the visualiser's edges are drawn along.
39
+ *
40
+ * Node positions are top-left corners (nodes get `origin: [0, 0]`), children
41
+ * relative to their group. Groups are sized to fit their children.
42
+ */
43
+ declare const layoutWithElk: ({ nodes, edges }: LayoutGraph, { sizeOf }?: {
44
+ sizeOf?: (node: Node) => LayoutSize;
45
+ }) => Promise<LayoutGraph>;
46
+
47
+ export { type EdgeRoute as E, type LayoutGraph as L, type LayoutSize as a, getNodeSize as g, layoutWithElk as l };
@@ -0,0 +1,47 @@
1
+ import { Node, Edge } from '@xyflow/react';
2
+
3
+ type LayoutGraph = {
4
+ nodes: Node[];
5
+ edges: Edge[];
6
+ };
7
+ type LayoutSize = {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ type EdgeRoute = {
12
+ points: {
13
+ x: number;
14
+ y: number;
15
+ }[];
16
+ label?: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ /** Where the edge's source and target were laid out (top-left, in the flow) */
21
+ source?: {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ target?: {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ };
30
+ /** The size a node is laid out at: as rendered, or an estimate for its type */
31
+ declare const getNodeSize: (node: Node) => LayoutSize;
32
+ /**
33
+ * Lays a graph out with ELK (left to right). Nested groups (nodes other nodes
34
+ * have as their `parentId`) are laid out in one pass with their children.
35
+ * Edges are routed at right angles around nodes, each edge with its own
36
+ * connection point so edges don't run on top of each other, and labels are
37
+ * placed on their edge. Each edge keeps its type and gets its route (and label
38
+ * position) in `data.route`, which the visualiser's edges are drawn along.
39
+ *
40
+ * Node positions are top-left corners (nodes get `origin: [0, 0]`), children
41
+ * relative to their group. Groups are sized to fit their children.
42
+ */
43
+ declare const layoutWithElk: ({ nodes, edges }: LayoutGraph, { sizeOf }?: {
44
+ sizeOf?: (node: Node) => LayoutSize;
45
+ }) => Promise<LayoutGraph>;
46
+
47
+ export { type EdgeRoute as E, type LayoutGraph as L, type LayoutSize as a, getNodeSize as g, layoutWithElk as l };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as _xyflow_react from '@xyflow/react';
2
2
  import { Node, Connection, MarkerType, Edge, NodeTypes, EdgeTypes, NodeProps, EdgeProps, ReactFlowJsonObject } from '@xyflow/react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { E as EdgeRoute } from './elk-layout-BVUJjv6i.mjs';
4
5
  import * as react from 'react';
5
- import react__default from 'react';
6
+ import react__default, { ReactNode, ComponentType } from 'react';
6
7
 
7
8
  /**
8
9
  * EventCatalog resource mode
@@ -334,6 +335,60 @@ type FlowGroupBy = SwimlaneGroupBy | "domain-system";
334
335
  type FlowGroupStyle = "lanes" | "boxes";
335
336
  declare const isFlowGroupBy: (value: unknown) => value is FlowGroupBy;
336
337
 
338
+ /**
339
+ * What a diagram shows, to start a Studio canvas from: its full graph (level 3, whatever level is shown, as Studio
340
+ * shows the other levels itself), its nodes where they are (as on screen when level 3 is shown), and the
341
+ * connections between them
342
+ */
343
+ type VisualiserSnapshot = {
344
+ title?: string;
345
+ /** The level of detail shown (1 to 3), for Studio to open at. Studio gets the full graph (level 3) whatever it is. */
346
+ level: 1 | 2 | 3;
347
+ nodes: {
348
+ id: string;
349
+ type?: string;
350
+ data: Record<string, unknown>;
351
+ /** The container it's shown in */
352
+ parentId?: string;
353
+ /** Its centre on the diagram (not relative to its container) */
354
+ center: {
355
+ x: number;
356
+ y: number;
357
+ };
358
+ /** Its size as shown */
359
+ width: number;
360
+ height: number;
361
+ }[];
362
+ edges: {
363
+ source: string;
364
+ target: string;
365
+ label?: string;
366
+ /** How it's drawn: the points it goes through on the diagram, and where its label is (from the layout) */
367
+ route?: Pick<EdgeRoute, "points" | "label">;
368
+ }[];
369
+ /**
370
+ * Levels 1 and 2 as the diagram shows them (laid out, positions relative to their parents), for Studio to show
371
+ * them the same. Level 1 only when the diagram has an overview.
372
+ */
373
+ levels: {
374
+ 1?: LevelGraph;
375
+ 2?: LevelGraph;
376
+ };
377
+ /** Levels 1 and 2 the diagram doesn't have, and why (as it says on them) */
378
+ unavailableLevels: {
379
+ 1?: string;
380
+ 2?: string;
381
+ };
382
+ };
383
+ type LevelGraph = {
384
+ nodes: Node[];
385
+ edges: Edge[];
386
+ };
387
+ /** Opening a diagram in Studio: its title, and what it shows (taken when asked for, e.g. once the canvas is named) */
388
+ type OpenInStudioRequest = {
389
+ title?: string;
390
+ getSnapshot: () => Promise<VisualiserSnapshot>;
391
+ };
337
392
  interface NodeGraphProps {
338
393
  id: string;
339
394
  title?: string;
@@ -412,8 +467,10 @@ interface NodeGraphProps {
412
467
  y: number;
413
468
  }>) => Promise<boolean>;
414
469
  onResetLayout?: (resourceKey: string) => Promise<boolean>;
470
+ /** Starts a Studio canvas from what the diagram shows (the menu has "Open in Studio" when set) */
471
+ onOpenInStudio?: (request: OpenInStudioRequest) => void;
415
472
  }
416
- declare const NodeGraph: ({ id, nodes: nodesProp, edges: edgesProp, graph, title: titleProp, href, linkTo, hrefLabel, includeKey: includeKeyProp, footerLabel, linksToVisualiser, links, mode, portalId, showFlowWalkthrough, showSearch: showSearchProp, showMenu, compactSearch, hideAttribution, zoomOnScroll, designId, isChatEnabled, maxTextSize, isDevMode, resourceKey, animated: animatedProp, disableMessageAnimation, overviewGraph, hiddenMessagesGraph, preferenceScope, swimlanes, focusNodeId, focusRequestId, fitRequestId, onNodeClick, onBuildUrl, onNavigate, onSaveLayout, onResetLayout, }: NodeGraphProps) => react_jsx_runtime.JSX.Element | null;
473
+ declare const NodeGraph: ({ id, nodes: nodesProp, edges: edgesProp, graph, title: titleProp, href, linkTo, hrefLabel, includeKey: includeKeyProp, footerLabel, linksToVisualiser, links, mode, portalId, showFlowWalkthrough, showSearch: showSearchProp, showMenu, compactSearch, hideAttribution, zoomOnScroll, designId, isChatEnabled, maxTextSize, isDevMode, resourceKey, animated: animatedProp, disableMessageAnimation, overviewGraph, hiddenMessagesGraph, preferenceScope, swimlanes, focusNodeId, focusRequestId, fitRequestId, onNodeClick, onBuildUrl, onNavigate, onSaveLayout, onResetLayout, onOpenInStudio, }: NodeGraphProps) => react_jsx_runtime.JSX.Element | null;
417
474
 
418
475
  interface MermaidViewProps {
419
476
  nodes: Node[];
@@ -422,6 +479,70 @@ interface MermaidViewProps {
422
479
  }
423
480
  declare const MermaidView: ({ nodes, edges, maxTextSize, }: MermaidViewProps) => react_jsx_runtime.JSX.Element;
424
481
 
482
+ /**
483
+ * A diagram's background: dots on the canvas colour (`.react-flow` in styles-core.css), the same wherever a
484
+ * diagram is drawn (the visualiser and Studio)
485
+ */
486
+ declare const DiagramBackground: react.NamedExoticComponent<object>;
487
+
488
+ /**
489
+ * A diagram's legend: how many of each kind of node it shows (and of each domain's, when steps are grouped by
490
+ * domain), with the kind's icon. Clicking an entry hides or shows those nodes. Studio's canvases have the same one.
491
+ */
492
+ type LegendEntry = {
493
+ count: number;
494
+ colorClass: string;
495
+ groupId?: string;
496
+ };
497
+ /** The legend for some nodes: each domain's steps (when grouped by domain), then each kind of node */
498
+ declare const getLegend: (nodes: Node<any>[]) => Record<string, LegendEntry>;
499
+ /** The legend, bottom right */
500
+ declare const LegendPanel: react.NamedExoticComponent<{
501
+ legend: Record<string, LegendEntry>;
502
+ /** Entries whose nodes are hidden, shown faded */
503
+ hiddenKeys: string[];
504
+ showMinimap?: boolean;
505
+ onLegendClick: (key: string) => void;
506
+ }>;
507
+
508
+ /** A button in a toolbar, with its tooltip (what it does, and why it can't be used when it can't) */
509
+ declare const ToolbarButton: ({ label, hint, active, disabled, onClick, children, }: {
510
+ label: string;
511
+ /** Shown under the label on hover */
512
+ hint?: string;
513
+ active?: boolean;
514
+ disabled?: boolean;
515
+ onClick: () => void;
516
+ children: ReactNode;
517
+ }) => react_jsx_runtime.JSX.Element;
518
+ /**
519
+ * How far the canvas is zoomed in, as a percentage. Isolated, so what it's in only re-renders when the zoom changes
520
+ * (not on every pan). Studio's bar shows it too.
521
+ */
522
+ declare const ZoomLevel: react.NamedExoticComponent<{
523
+ className?: string;
524
+ }>;
525
+ declare const ToolbarDivider: () => react_jsx_runtime.JSX.Element;
526
+ /** The frame of a toolbar (e.g. the bar at the bottom of a diagram, or of a Studio canvas), with tooltips */
527
+ declare const Toolbar: ({ children }: {
528
+ children: ReactNode;
529
+ }) => react_jsx_runtime.JSX.Element;
530
+
531
+ /** Tooltips for a group of controls (e.g. a toolbar): shown after a moment, then straight away while moving along */
532
+ declare const TipProvider: ({ children }: {
533
+ children: ReactNode;
534
+ }) => react_jsx_runtime.JSX.Element;
535
+ /**
536
+ * A tooltip above a control: what it does, and optionally why it can't be used (`hint`). The control stays
537
+ * focusable when unavailable (`aria-disabled`, not `disabled`), so it can still say why. Used in a TipProvider.
538
+ */
539
+ declare const Tip: ({ label, hint, children, }: {
540
+ label: string;
541
+ hint?: string;
542
+ /** The control: one element that takes a ref */
543
+ children: ReactNode;
544
+ }) => react_jsx_runtime.JSX.Element;
545
+
425
546
  interface ResourceData {
426
547
  id?: string;
427
548
  name?: string;
@@ -549,6 +670,23 @@ interface NodeContextMenuProps {
549
670
  }
550
671
  declare const _default$w: react.NamedExoticComponent<NodeContextMenuProps>;
551
672
 
673
+ /**
674
+ * How a diagram's menu looks (the button at the top left, with the diagram's title, and the menu it opens). Studio's
675
+ * canvas menu uses the same, so the two feel the same.
676
+ */
677
+ /** The button: the title, then the menu icon (DIAGRAM_MENU_BUTTON_ICON) */
678
+ declare const DIAGRAM_MENU_BUTTON = "py-2.5 px-4 bg-[rgb(var(--ec-card-bg))] hover:bg-[rgb(var(--ec-accent-subtle))] border border-[rgb(var(--ec-page-border))] rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))] flex items-center gap-3 transition-colors duration-150 hover:border-[rgb(var(--ec-accent)/0.3)] group whitespace-nowrap";
679
+ /** The button without a title: just the icon */
680
+ declare const DIAGRAM_MENU_BUTTON_COMPACT = "h-9 w-9 p-0 bg-[rgb(var(--ec-card-bg))] hover:bg-[rgb(var(--ec-accent-subtle))] border border-[rgb(var(--ec-page-border))] rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))] flex items-center justify-center transition-colors duration-150 hover:border-[rgb(var(--ec-accent)/0.3)] group";
681
+ declare const DIAGRAM_MENU_TITLE = "text-base font-medium text-[rgb(var(--ec-page-text))] leading-tight";
682
+ declare const DIAGRAM_MENU_BUTTON_ICON = "h-5 w-5 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0 group-hover:text-[rgb(var(--ec-accent))] transition-colors duration-150";
683
+ declare const DIAGRAM_MENU_BUTTON_ICON_COMPACT = "h-4 w-4 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0 group-hover:text-[rgb(var(--ec-accent))] transition-colors duration-150";
684
+ /** The menu, its items (an icon, then the label), and the lines between groups of them */
685
+ declare const DIAGRAM_MENU = "min-w-56 bg-[rgb(var(--ec-page-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-xl z-50 py-1.5";
686
+ declare const DIAGRAM_MENU_ITEM = "flex items-center px-3 py-2 text-xs text-[rgb(var(--ec-page-text))] hover:bg-[rgb(var(--ec-accent-subtle)/0.3)] cursor-pointer transition-colors gap-2";
687
+ declare const DIAGRAM_MENU_ITEM_ICON = "w-3.5 h-3.5 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0";
688
+ declare const DIAGRAM_MENU_SEPARATOR = "my-1 h-px bg-[rgb(var(--ec-page-border))]";
689
+
552
690
  type MessageGroupNodeData = {
553
691
  mode?: string;
554
692
  groupName: string;
@@ -841,6 +979,12 @@ declare const DATA: string[];
841
979
  declare const VIEW: string[];
842
980
  declare const MESSAGE: string[];
843
981
 
982
+ /**
983
+ * The component a diagram draws each type of node with (types as EventCatalog's node graphs build them, singular
984
+ * and plural). Studio draws diagrams' levels with them too, so they look the same.
985
+ */
986
+ declare const diagramNodeComponents: Record<string, ComponentType<any>>;
987
+
844
988
  declare const nodeComponents: {
845
989
  event: react.NamedExoticComponent<EventNode>;
846
990
  command: react.NamedExoticComponent<CommandNode>;
@@ -894,17 +1038,17 @@ declare const AnimatedMessageEdge: react.MemoExoticComponent<({ id, sourceX, sou
894
1038
 
895
1039
  declare const _default: react.NamedExoticComponent<EdgeProps>;
896
1040
 
897
- declare function LabelledDefaultEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
898
- declare function LabelledSmoothStepEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
899
- declare function LabelledStepEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
1041
+ declare const LabelledDefaultEdge: react.NamedExoticComponent<EdgeProps>;
1042
+ declare const LabelledSmoothStepEdge: react.NamedExoticComponent<EdgeProps>;
1043
+ declare const LabelledStepEdge: react.NamedExoticComponent<EdgeProps>;
900
1044
 
901
1045
  declare const edgeTypes: {
902
1046
  animated: react.MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, source, target, sourceHandleId, targetHandleId, data, label, markerEnd, markerStart, }: any) => react_jsx_runtime.JSX.Element>;
903
1047
  "flow-edge": react.NamedExoticComponent<CustomEdgeProps>;
904
1048
  multiline: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
905
- default: typeof LabelledDefaultEdge;
906
- smoothstep: typeof LabelledSmoothStepEdge;
907
- step: typeof LabelledStepEdge;
1049
+ default: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
1050
+ smoothstep: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
1051
+ step: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
908
1052
  };
909
1053
 
910
1054
  /**
@@ -963,4 +1107,29 @@ declare function layoutGraph(nodes: GraphNode[], edges: GraphEdge[], { style }?:
963
1107
  edges: Edge[];
964
1108
  }>;
965
1109
 
966
- export { ACTOR, AGENT, AGENT_TOOL, _default$p as Actor, type ActorNode, type Agent$1 as Agent, _default$j as AgentNode, type AgentTool$1 as AgentTool, _default$k as AgentToolNode, type AgentToolNode as AgentToolNodeType, AnimatedMessageEdge, type BaseNodeData, CHANNEL, COMMAND, type Channel, type ChannelNode, _default$g as Command, type CommandNode, _default$8 as ContextActorNode, type ContextMenuItem, _default$c as CustomNode, DATA, type Data, type DataNode, _default$t as DataProductNode, _default$a as DomainCardNode, _default$b as DomainNode, type DslGraph, ENTITY_TARGET_HANDLE_ID, EVENT, type EdgeType, _default$d as EntityNode, type EntityProperty, _default$f as Event, type EventCatalogResource, type EventNode, type ExternalSystem, _default$2 as ExternalSystem2Node, type ExternalSystemNode, _default$r as Field, type FieldNode as FieldNodeType, _default$1 as FlowEdge, _default$s as FlowExpandedNode, type FlowGroupBy, type FlowGroupStyle, _default$6 as FlowNode, FocusModeModal, type GraphEdge, type GraphEdgeType, type GraphNode, _default$5 as GroupNode, LabelledDefaultEdge, LabelledSmoothStepEdge, LabelledStepEdge, MESSAGE, type MermaidExportOptions, MermaidView, type Message, _default$u as MessageGroupExpandedNode, type MessageGroupExpandedNodeData, _default$v as MessageGroupNode, type MessageGroupNodeData, type MessageGroupNode as MessageGroupNodeType, _default as MultilineEdgeLabel, type NodeCategory, type NodeConfiguration, _default$w as NodeContextMenu, NodeGraph, type NodeGraphProps, type NodeType, _default$l as Note, type NoteNode, NotesIndicator, OwnerIndicator, QUERY, _default$h as Query, type QueryNode, type RegisteredNode, SERVICE, _default$i as Service, type ServiceNode, type Service as ServiceType, _default$4 as StepNode, _default$x as StepWalkthrough, _default$7 as SystemGroupNode, _default$9 as SystemNode, _default$3 as UserNode, VIEW, type View, type ViewNode, VisualiserSearch, type VisualizerCallbacks, type VisualizerLink, type VisualizerMode, _default$o as actorConfig, buildNodeData, convertToMermaid, createEdge, createNode, _default$n as dataNodeConfig, edgeTypes, _default$e as eventConfig, exportNodeGraphForStudio, _default$m as externalSystemConfig, _default$q as fieldConfig, generateIdForNode, generateIdForNodes, generatedIdForEdge, getColorFromString, getEdgeLabelForMessageAsSource, getEdgeLabelForServiceAsTarget, getEdgeLabelSize, getNestedEntityProperties, getPropertyTypeLabel, isFlowGroupBy, layoutGraph, nodeComponents, nodeConfigs, normalizeOwners };
1110
+ /**
1111
+ * How a diagram is fitted to the screen: all of it, filling the view with the same room around it at any size (clear
1112
+ * of the title and menus at the top, and the bar at the bottom), never zoomed in past full size (e.g. a graph with
1113
+ * one small node). Studio fits its canvases the same way.
1114
+ */
1115
+ declare const DIAGRAM_FIT_VIEW_OPTIONS: {
1116
+ readonly padding: {
1117
+ readonly top: "100px";
1118
+ readonly right: "60px";
1119
+ readonly bottom: "80px";
1120
+ readonly left: "60px";
1121
+ };
1122
+ readonly maxZoom: 1;
1123
+ };
1124
+
1125
+ /** Memoizes a custom node so it renders again only when something besides its position changes. */
1126
+ declare const memoNode: <P extends object>(Component: ComponentType<P>) => react.MemoExoticComponent<ComponentType<P>>;
1127
+
1128
+ /**
1129
+ * Pauses (or resumes) the SMIL animations of a canvas's edges: the message envelopes moving along them. Hiding
1130
+ * them doesn't stop them (SMIL keeps running, with a style recalc and layout every frame), so while the canvas
1131
+ * is panned, zoomed or dragged they're paused. Each edge is its own <svg>, with its own timeline.
1132
+ */
1133
+ declare const pauseEdgeAnimations: (canvas: Element | null, paused: boolean) => void | undefined;
1134
+
1135
+ export { ACTOR, AGENT, AGENT_TOOL, _default$p as Actor, type ActorNode, type Agent$1 as Agent, _default$j as AgentNode, type AgentTool$1 as AgentTool, _default$k as AgentToolNode, type AgentToolNode as AgentToolNodeType, AnimatedMessageEdge, type BaseNodeData, CHANNEL, COMMAND, type Channel, type ChannelNode, _default$g as Command, type CommandNode, _default$8 as ContextActorNode, type ContextMenuItem, _default$c as CustomNode, DATA, DIAGRAM_FIT_VIEW_OPTIONS, DIAGRAM_MENU, DIAGRAM_MENU_BUTTON, DIAGRAM_MENU_BUTTON_COMPACT, DIAGRAM_MENU_BUTTON_ICON, DIAGRAM_MENU_BUTTON_ICON_COMPACT, DIAGRAM_MENU_ITEM, DIAGRAM_MENU_ITEM_ICON, DIAGRAM_MENU_SEPARATOR, DIAGRAM_MENU_TITLE, type Data, type DataNode, _default$t as DataProductNode, DiagramBackground, _default$a as DomainCardNode, _default$b as DomainNode, type DslGraph, ENTITY_TARGET_HANDLE_ID, EVENT, type EdgeType, _default$d as EntityNode, type EntityProperty, _default$f as Event, type EventCatalogResource, type EventNode, type ExternalSystem, _default$2 as ExternalSystem2Node, type ExternalSystemNode, _default$r as Field, type FieldNode as FieldNodeType, _default$1 as FlowEdge, _default$s as FlowExpandedNode, type FlowGroupBy, type FlowGroupStyle, _default$6 as FlowNode, FocusModeModal, type GraphEdge, type GraphEdgeType, type GraphNode, _default$5 as GroupNode, LabelledDefaultEdge, LabelledSmoothStepEdge, LabelledStepEdge, type LegendEntry, LegendPanel, MESSAGE, type MermaidExportOptions, MermaidView, type Message, _default$u as MessageGroupExpandedNode, type MessageGroupExpandedNodeData, _default$v as MessageGroupNode, type MessageGroupNodeData, type MessageGroupNode as MessageGroupNodeType, _default as MultilineEdgeLabel, type NodeCategory, type NodeConfiguration, _default$w as NodeContextMenu, NodeGraph, type NodeGraphProps, type NodeType, _default$l as Note, type NoteNode, NotesIndicator, type OpenInStudioRequest, OwnerIndicator, QUERY, _default$h as Query, type QueryNode, type RegisteredNode, SERVICE, _default$i as Service, type ServiceNode, type Service as ServiceType, _default$4 as StepNode, _default$x as StepWalkthrough, _default$7 as SystemGroupNode, _default$9 as SystemNode, Tip, TipProvider, Toolbar, ToolbarButton, ToolbarDivider, _default$3 as UserNode, VIEW, type View, type ViewNode, VisualiserSearch, type VisualiserSnapshot, type VisualizerCallbacks, type VisualizerLink, type VisualizerMode, ZoomLevel, _default$o as actorConfig, buildNodeData, convertToMermaid, createEdge, createNode, _default$n as dataNodeConfig, diagramNodeComponents, edgeTypes, _default$e as eventConfig, exportNodeGraphForStudio, _default$m as externalSystemConfig, _default$q as fieldConfig, generateIdForNode, generateIdForNodes, generatedIdForEdge, getColorFromString, getEdgeLabelForMessageAsSource, getEdgeLabelForServiceAsTarget, getEdgeLabelSize, getLegend, getNestedEntityProperties, getPropertyTypeLabel, isFlowGroupBy, layoutGraph, memoNode, nodeComponents, nodeConfigs, normalizeOwners, pauseEdgeAnimations };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as _xyflow_react from '@xyflow/react';
2
2
  import { Node, Connection, MarkerType, Edge, NodeTypes, EdgeTypes, NodeProps, EdgeProps, ReactFlowJsonObject } from '@xyflow/react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { E as EdgeRoute } from './elk-layout-BVUJjv6i.js';
4
5
  import * as react from 'react';
5
- import react__default from 'react';
6
+ import react__default, { ReactNode, ComponentType } from 'react';
6
7
 
7
8
  /**
8
9
  * EventCatalog resource mode
@@ -334,6 +335,60 @@ type FlowGroupBy = SwimlaneGroupBy | "domain-system";
334
335
  type FlowGroupStyle = "lanes" | "boxes";
335
336
  declare const isFlowGroupBy: (value: unknown) => value is FlowGroupBy;
336
337
 
338
+ /**
339
+ * What a diagram shows, to start a Studio canvas from: its full graph (level 3, whatever level is shown, as Studio
340
+ * shows the other levels itself), its nodes where they are (as on screen when level 3 is shown), and the
341
+ * connections between them
342
+ */
343
+ type VisualiserSnapshot = {
344
+ title?: string;
345
+ /** The level of detail shown (1 to 3), for Studio to open at. Studio gets the full graph (level 3) whatever it is. */
346
+ level: 1 | 2 | 3;
347
+ nodes: {
348
+ id: string;
349
+ type?: string;
350
+ data: Record<string, unknown>;
351
+ /** The container it's shown in */
352
+ parentId?: string;
353
+ /** Its centre on the diagram (not relative to its container) */
354
+ center: {
355
+ x: number;
356
+ y: number;
357
+ };
358
+ /** Its size as shown */
359
+ width: number;
360
+ height: number;
361
+ }[];
362
+ edges: {
363
+ source: string;
364
+ target: string;
365
+ label?: string;
366
+ /** How it's drawn: the points it goes through on the diagram, and where its label is (from the layout) */
367
+ route?: Pick<EdgeRoute, "points" | "label">;
368
+ }[];
369
+ /**
370
+ * Levels 1 and 2 as the diagram shows them (laid out, positions relative to their parents), for Studio to show
371
+ * them the same. Level 1 only when the diagram has an overview.
372
+ */
373
+ levels: {
374
+ 1?: LevelGraph;
375
+ 2?: LevelGraph;
376
+ };
377
+ /** Levels 1 and 2 the diagram doesn't have, and why (as it says on them) */
378
+ unavailableLevels: {
379
+ 1?: string;
380
+ 2?: string;
381
+ };
382
+ };
383
+ type LevelGraph = {
384
+ nodes: Node[];
385
+ edges: Edge[];
386
+ };
387
+ /** Opening a diagram in Studio: its title, and what it shows (taken when asked for, e.g. once the canvas is named) */
388
+ type OpenInStudioRequest = {
389
+ title?: string;
390
+ getSnapshot: () => Promise<VisualiserSnapshot>;
391
+ };
337
392
  interface NodeGraphProps {
338
393
  id: string;
339
394
  title?: string;
@@ -412,8 +467,10 @@ interface NodeGraphProps {
412
467
  y: number;
413
468
  }>) => Promise<boolean>;
414
469
  onResetLayout?: (resourceKey: string) => Promise<boolean>;
470
+ /** Starts a Studio canvas from what the diagram shows (the menu has "Open in Studio" when set) */
471
+ onOpenInStudio?: (request: OpenInStudioRequest) => void;
415
472
  }
416
- declare const NodeGraph: ({ id, nodes: nodesProp, edges: edgesProp, graph, title: titleProp, href, linkTo, hrefLabel, includeKey: includeKeyProp, footerLabel, linksToVisualiser, links, mode, portalId, showFlowWalkthrough, showSearch: showSearchProp, showMenu, compactSearch, hideAttribution, zoomOnScroll, designId, isChatEnabled, maxTextSize, isDevMode, resourceKey, animated: animatedProp, disableMessageAnimation, overviewGraph, hiddenMessagesGraph, preferenceScope, swimlanes, focusNodeId, focusRequestId, fitRequestId, onNodeClick, onBuildUrl, onNavigate, onSaveLayout, onResetLayout, }: NodeGraphProps) => react_jsx_runtime.JSX.Element | null;
473
+ declare const NodeGraph: ({ id, nodes: nodesProp, edges: edgesProp, graph, title: titleProp, href, linkTo, hrefLabel, includeKey: includeKeyProp, footerLabel, linksToVisualiser, links, mode, portalId, showFlowWalkthrough, showSearch: showSearchProp, showMenu, compactSearch, hideAttribution, zoomOnScroll, designId, isChatEnabled, maxTextSize, isDevMode, resourceKey, animated: animatedProp, disableMessageAnimation, overviewGraph, hiddenMessagesGraph, preferenceScope, swimlanes, focusNodeId, focusRequestId, fitRequestId, onNodeClick, onBuildUrl, onNavigate, onSaveLayout, onResetLayout, onOpenInStudio, }: NodeGraphProps) => react_jsx_runtime.JSX.Element | null;
417
474
 
418
475
  interface MermaidViewProps {
419
476
  nodes: Node[];
@@ -422,6 +479,70 @@ interface MermaidViewProps {
422
479
  }
423
480
  declare const MermaidView: ({ nodes, edges, maxTextSize, }: MermaidViewProps) => react_jsx_runtime.JSX.Element;
424
481
 
482
+ /**
483
+ * A diagram's background: dots on the canvas colour (`.react-flow` in styles-core.css), the same wherever a
484
+ * diagram is drawn (the visualiser and Studio)
485
+ */
486
+ declare const DiagramBackground: react.NamedExoticComponent<object>;
487
+
488
+ /**
489
+ * A diagram's legend: how many of each kind of node it shows (and of each domain's, when steps are grouped by
490
+ * domain), with the kind's icon. Clicking an entry hides or shows those nodes. Studio's canvases have the same one.
491
+ */
492
+ type LegendEntry = {
493
+ count: number;
494
+ colorClass: string;
495
+ groupId?: string;
496
+ };
497
+ /** The legend for some nodes: each domain's steps (when grouped by domain), then each kind of node */
498
+ declare const getLegend: (nodes: Node<any>[]) => Record<string, LegendEntry>;
499
+ /** The legend, bottom right */
500
+ declare const LegendPanel: react.NamedExoticComponent<{
501
+ legend: Record<string, LegendEntry>;
502
+ /** Entries whose nodes are hidden, shown faded */
503
+ hiddenKeys: string[];
504
+ showMinimap?: boolean;
505
+ onLegendClick: (key: string) => void;
506
+ }>;
507
+
508
+ /** A button in a toolbar, with its tooltip (what it does, and why it can't be used when it can't) */
509
+ declare const ToolbarButton: ({ label, hint, active, disabled, onClick, children, }: {
510
+ label: string;
511
+ /** Shown under the label on hover */
512
+ hint?: string;
513
+ active?: boolean;
514
+ disabled?: boolean;
515
+ onClick: () => void;
516
+ children: ReactNode;
517
+ }) => react_jsx_runtime.JSX.Element;
518
+ /**
519
+ * How far the canvas is zoomed in, as a percentage. Isolated, so what it's in only re-renders when the zoom changes
520
+ * (not on every pan). Studio's bar shows it too.
521
+ */
522
+ declare const ZoomLevel: react.NamedExoticComponent<{
523
+ className?: string;
524
+ }>;
525
+ declare const ToolbarDivider: () => react_jsx_runtime.JSX.Element;
526
+ /** The frame of a toolbar (e.g. the bar at the bottom of a diagram, or of a Studio canvas), with tooltips */
527
+ declare const Toolbar: ({ children }: {
528
+ children: ReactNode;
529
+ }) => react_jsx_runtime.JSX.Element;
530
+
531
+ /** Tooltips for a group of controls (e.g. a toolbar): shown after a moment, then straight away while moving along */
532
+ declare const TipProvider: ({ children }: {
533
+ children: ReactNode;
534
+ }) => react_jsx_runtime.JSX.Element;
535
+ /**
536
+ * A tooltip above a control: what it does, and optionally why it can't be used (`hint`). The control stays
537
+ * focusable when unavailable (`aria-disabled`, not `disabled`), so it can still say why. Used in a TipProvider.
538
+ */
539
+ declare const Tip: ({ label, hint, children, }: {
540
+ label: string;
541
+ hint?: string;
542
+ /** The control: one element that takes a ref */
543
+ children: ReactNode;
544
+ }) => react_jsx_runtime.JSX.Element;
545
+
425
546
  interface ResourceData {
426
547
  id?: string;
427
548
  name?: string;
@@ -549,6 +670,23 @@ interface NodeContextMenuProps {
549
670
  }
550
671
  declare const _default$w: react.NamedExoticComponent<NodeContextMenuProps>;
551
672
 
673
+ /**
674
+ * How a diagram's menu looks (the button at the top left, with the diagram's title, and the menu it opens). Studio's
675
+ * canvas menu uses the same, so the two feel the same.
676
+ */
677
+ /** The button: the title, then the menu icon (DIAGRAM_MENU_BUTTON_ICON) */
678
+ declare const DIAGRAM_MENU_BUTTON = "py-2.5 px-4 bg-[rgb(var(--ec-card-bg))] hover:bg-[rgb(var(--ec-accent-subtle))] border border-[rgb(var(--ec-page-border))] rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))] flex items-center gap-3 transition-colors duration-150 hover:border-[rgb(var(--ec-accent)/0.3)] group whitespace-nowrap";
679
+ /** The button without a title: just the icon */
680
+ declare const DIAGRAM_MENU_BUTTON_COMPACT = "h-9 w-9 p-0 bg-[rgb(var(--ec-card-bg))] hover:bg-[rgb(var(--ec-accent-subtle))] border border-[rgb(var(--ec-page-border))] rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))] flex items-center justify-center transition-colors duration-150 hover:border-[rgb(var(--ec-accent)/0.3)] group";
681
+ declare const DIAGRAM_MENU_TITLE = "text-base font-medium text-[rgb(var(--ec-page-text))] leading-tight";
682
+ declare const DIAGRAM_MENU_BUTTON_ICON = "h-5 w-5 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0 group-hover:text-[rgb(var(--ec-accent))] transition-colors duration-150";
683
+ declare const DIAGRAM_MENU_BUTTON_ICON_COMPACT = "h-4 w-4 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0 group-hover:text-[rgb(var(--ec-accent))] transition-colors duration-150";
684
+ /** The menu, its items (an icon, then the label), and the lines between groups of them */
685
+ declare const DIAGRAM_MENU = "min-w-56 bg-[rgb(var(--ec-page-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-xl z-50 py-1.5";
686
+ declare const DIAGRAM_MENU_ITEM = "flex items-center px-3 py-2 text-xs text-[rgb(var(--ec-page-text))] hover:bg-[rgb(var(--ec-accent-subtle)/0.3)] cursor-pointer transition-colors gap-2";
687
+ declare const DIAGRAM_MENU_ITEM_ICON = "w-3.5 h-3.5 text-[rgb(var(--ec-page-text-muted))] flex-shrink-0";
688
+ declare const DIAGRAM_MENU_SEPARATOR = "my-1 h-px bg-[rgb(var(--ec-page-border))]";
689
+
552
690
  type MessageGroupNodeData = {
553
691
  mode?: string;
554
692
  groupName: string;
@@ -841,6 +979,12 @@ declare const DATA: string[];
841
979
  declare const VIEW: string[];
842
980
  declare const MESSAGE: string[];
843
981
 
982
+ /**
983
+ * The component a diagram draws each type of node with (types as EventCatalog's node graphs build them, singular
984
+ * and plural). Studio draws diagrams' levels with them too, so they look the same.
985
+ */
986
+ declare const diagramNodeComponents: Record<string, ComponentType<any>>;
987
+
844
988
  declare const nodeComponents: {
845
989
  event: react.NamedExoticComponent<EventNode>;
846
990
  command: react.NamedExoticComponent<CommandNode>;
@@ -894,17 +1038,17 @@ declare const AnimatedMessageEdge: react.MemoExoticComponent<({ id, sourceX, sou
894
1038
 
895
1039
  declare const _default: react.NamedExoticComponent<EdgeProps>;
896
1040
 
897
- declare function LabelledDefaultEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
898
- declare function LabelledSmoothStepEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
899
- declare function LabelledStepEdge(props: EdgeProps): react_jsx_runtime.JSX.Element;
1041
+ declare const LabelledDefaultEdge: react.NamedExoticComponent<EdgeProps>;
1042
+ declare const LabelledSmoothStepEdge: react.NamedExoticComponent<EdgeProps>;
1043
+ declare const LabelledStepEdge: react.NamedExoticComponent<EdgeProps>;
900
1044
 
901
1045
  declare const edgeTypes: {
902
1046
  animated: react.MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, source, target, sourceHandleId, targetHandleId, data, label, markerEnd, markerStart, }: any) => react_jsx_runtime.JSX.Element>;
903
1047
  "flow-edge": react.NamedExoticComponent<CustomEdgeProps>;
904
1048
  multiline: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
905
- default: typeof LabelledDefaultEdge;
906
- smoothstep: typeof LabelledSmoothStepEdge;
907
- step: typeof LabelledStepEdge;
1049
+ default: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
1050
+ smoothstep: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
1051
+ step: react.NamedExoticComponent<_xyflow_react.EdgeProps>;
908
1052
  };
909
1053
 
910
1054
  /**
@@ -963,4 +1107,29 @@ declare function layoutGraph(nodes: GraphNode[], edges: GraphEdge[], { style }?:
963
1107
  edges: Edge[];
964
1108
  }>;
965
1109
 
966
- export { ACTOR, AGENT, AGENT_TOOL, _default$p as Actor, type ActorNode, type Agent$1 as Agent, _default$j as AgentNode, type AgentTool$1 as AgentTool, _default$k as AgentToolNode, type AgentToolNode as AgentToolNodeType, AnimatedMessageEdge, type BaseNodeData, CHANNEL, COMMAND, type Channel, type ChannelNode, _default$g as Command, type CommandNode, _default$8 as ContextActorNode, type ContextMenuItem, _default$c as CustomNode, DATA, type Data, type DataNode, _default$t as DataProductNode, _default$a as DomainCardNode, _default$b as DomainNode, type DslGraph, ENTITY_TARGET_HANDLE_ID, EVENT, type EdgeType, _default$d as EntityNode, type EntityProperty, _default$f as Event, type EventCatalogResource, type EventNode, type ExternalSystem, _default$2 as ExternalSystem2Node, type ExternalSystemNode, _default$r as Field, type FieldNode as FieldNodeType, _default$1 as FlowEdge, _default$s as FlowExpandedNode, type FlowGroupBy, type FlowGroupStyle, _default$6 as FlowNode, FocusModeModal, type GraphEdge, type GraphEdgeType, type GraphNode, _default$5 as GroupNode, LabelledDefaultEdge, LabelledSmoothStepEdge, LabelledStepEdge, MESSAGE, type MermaidExportOptions, MermaidView, type Message, _default$u as MessageGroupExpandedNode, type MessageGroupExpandedNodeData, _default$v as MessageGroupNode, type MessageGroupNodeData, type MessageGroupNode as MessageGroupNodeType, _default as MultilineEdgeLabel, type NodeCategory, type NodeConfiguration, _default$w as NodeContextMenu, NodeGraph, type NodeGraphProps, type NodeType, _default$l as Note, type NoteNode, NotesIndicator, OwnerIndicator, QUERY, _default$h as Query, type QueryNode, type RegisteredNode, SERVICE, _default$i as Service, type ServiceNode, type Service as ServiceType, _default$4 as StepNode, _default$x as StepWalkthrough, _default$7 as SystemGroupNode, _default$9 as SystemNode, _default$3 as UserNode, VIEW, type View, type ViewNode, VisualiserSearch, type VisualizerCallbacks, type VisualizerLink, type VisualizerMode, _default$o as actorConfig, buildNodeData, convertToMermaid, createEdge, createNode, _default$n as dataNodeConfig, edgeTypes, _default$e as eventConfig, exportNodeGraphForStudio, _default$m as externalSystemConfig, _default$q as fieldConfig, generateIdForNode, generateIdForNodes, generatedIdForEdge, getColorFromString, getEdgeLabelForMessageAsSource, getEdgeLabelForServiceAsTarget, getEdgeLabelSize, getNestedEntityProperties, getPropertyTypeLabel, isFlowGroupBy, layoutGraph, nodeComponents, nodeConfigs, normalizeOwners };
1110
+ /**
1111
+ * How a diagram is fitted to the screen: all of it, filling the view with the same room around it at any size (clear
1112
+ * of the title and menus at the top, and the bar at the bottom), never zoomed in past full size (e.g. a graph with
1113
+ * one small node). Studio fits its canvases the same way.
1114
+ */
1115
+ declare const DIAGRAM_FIT_VIEW_OPTIONS: {
1116
+ readonly padding: {
1117
+ readonly top: "100px";
1118
+ readonly right: "60px";
1119
+ readonly bottom: "80px";
1120
+ readonly left: "60px";
1121
+ };
1122
+ readonly maxZoom: 1;
1123
+ };
1124
+
1125
+ /** Memoizes a custom node so it renders again only when something besides its position changes. */
1126
+ declare const memoNode: <P extends object>(Component: ComponentType<P>) => react.MemoExoticComponent<ComponentType<P>>;
1127
+
1128
+ /**
1129
+ * Pauses (or resumes) the SMIL animations of a canvas's edges: the message envelopes moving along them. Hiding
1130
+ * them doesn't stop them (SMIL keeps running, with a style recalc and layout every frame), so while the canvas
1131
+ * is panned, zoomed or dragged they're paused. Each edge is its own <svg>, with its own timeline.
1132
+ */
1133
+ declare const pauseEdgeAnimations: (canvas: Element | null, paused: boolean) => void | undefined;
1134
+
1135
+ export { ACTOR, AGENT, AGENT_TOOL, _default$p as Actor, type ActorNode, type Agent$1 as Agent, _default$j as AgentNode, type AgentTool$1 as AgentTool, _default$k as AgentToolNode, type AgentToolNode as AgentToolNodeType, AnimatedMessageEdge, type BaseNodeData, CHANNEL, COMMAND, type Channel, type ChannelNode, _default$g as Command, type CommandNode, _default$8 as ContextActorNode, type ContextMenuItem, _default$c as CustomNode, DATA, DIAGRAM_FIT_VIEW_OPTIONS, DIAGRAM_MENU, DIAGRAM_MENU_BUTTON, DIAGRAM_MENU_BUTTON_COMPACT, DIAGRAM_MENU_BUTTON_ICON, DIAGRAM_MENU_BUTTON_ICON_COMPACT, DIAGRAM_MENU_ITEM, DIAGRAM_MENU_ITEM_ICON, DIAGRAM_MENU_SEPARATOR, DIAGRAM_MENU_TITLE, type Data, type DataNode, _default$t as DataProductNode, DiagramBackground, _default$a as DomainCardNode, _default$b as DomainNode, type DslGraph, ENTITY_TARGET_HANDLE_ID, EVENT, type EdgeType, _default$d as EntityNode, type EntityProperty, _default$f as Event, type EventCatalogResource, type EventNode, type ExternalSystem, _default$2 as ExternalSystem2Node, type ExternalSystemNode, _default$r as Field, type FieldNode as FieldNodeType, _default$1 as FlowEdge, _default$s as FlowExpandedNode, type FlowGroupBy, type FlowGroupStyle, _default$6 as FlowNode, FocusModeModal, type GraphEdge, type GraphEdgeType, type GraphNode, _default$5 as GroupNode, LabelledDefaultEdge, LabelledSmoothStepEdge, LabelledStepEdge, type LegendEntry, LegendPanel, MESSAGE, type MermaidExportOptions, MermaidView, type Message, _default$u as MessageGroupExpandedNode, type MessageGroupExpandedNodeData, _default$v as MessageGroupNode, type MessageGroupNodeData, type MessageGroupNode as MessageGroupNodeType, _default as MultilineEdgeLabel, type NodeCategory, type NodeConfiguration, _default$w as NodeContextMenu, NodeGraph, type NodeGraphProps, type NodeType, _default$l as Note, type NoteNode, NotesIndicator, type OpenInStudioRequest, OwnerIndicator, QUERY, _default$h as Query, type QueryNode, type RegisteredNode, SERVICE, _default$i as Service, type ServiceNode, type Service as ServiceType, _default$4 as StepNode, _default$x as StepWalkthrough, _default$7 as SystemGroupNode, _default$9 as SystemNode, Tip, TipProvider, Toolbar, ToolbarButton, ToolbarDivider, _default$3 as UserNode, VIEW, type View, type ViewNode, VisualiserSearch, type VisualiserSnapshot, type VisualizerCallbacks, type VisualizerLink, type VisualizerMode, ZoomLevel, _default$o as actorConfig, buildNodeData, convertToMermaid, createEdge, createNode, _default$n as dataNodeConfig, diagramNodeComponents, edgeTypes, _default$e as eventConfig, exportNodeGraphForStudio, _default$m as externalSystemConfig, _default$q as fieldConfig, generateIdForNode, generateIdForNodes, generatedIdForEdge, getColorFromString, getEdgeLabelForMessageAsSource, getEdgeLabelForServiceAsTarget, getEdgeLabelSize, getLegend, getNestedEntityProperties, getPropertyTypeLabel, isFlowGroupBy, layoutGraph, memoNode, nodeComponents, nodeConfigs, normalizeOwners, pauseEdgeAnimations };