@eventcatalog/visualiser 0.0.1

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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @eventcatalog/visualizer
2
+
3
+ EventCatalog Visualizer Package
@@ -0,0 +1,549 @@
1
+ import { Node, Connection, MarkerType, Edge, NodeTypes, EdgeTypes, EdgeProps, ReactFlowJsonObject } from '@xyflow/react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import * as react from 'react';
4
+ import react__default from 'react';
5
+ import dagre from 'dagre';
6
+
7
+ /**
8
+ * EventCatalog resource mode
9
+ */
10
+ type EventCatalogResource = {
11
+ mode: "simple" | "full";
12
+ collection?: string;
13
+ filePath?: string;
14
+ id?: string;
15
+ };
16
+ /**
17
+ * Message types (Events, Commands, Queries)
18
+ */
19
+ type Message = {
20
+ name: string;
21
+ version: string;
22
+ summary: string;
23
+ owners?: string[];
24
+ producers?: string[];
25
+ consumers?: string[];
26
+ };
27
+ /**
28
+ * Service type
29
+ */
30
+ type Service$1 = {
31
+ name: string;
32
+ version: string;
33
+ summary: string;
34
+ owners?: string[];
35
+ sends?: string[];
36
+ receives?: string[];
37
+ };
38
+ /**
39
+ * Channel type
40
+ */
41
+ type Channel$1 = {
42
+ name: string;
43
+ version: string;
44
+ summary: string;
45
+ owners?: string[];
46
+ parameters?: Record<string, string>;
47
+ protocols?: string[];
48
+ address?: string;
49
+ };
50
+ /**
51
+ * External System type
52
+ */
53
+ type ExternalSystem$1 = {
54
+ name: string;
55
+ version: string;
56
+ summary: string;
57
+ };
58
+ /**
59
+ * Data type
60
+ */
61
+ type Data$1 = {
62
+ name: string;
63
+ version: string;
64
+ summary: string;
65
+ owners?: string[];
66
+ type?: string;
67
+ schemas?: string[];
68
+ };
69
+ /**
70
+ * View type
71
+ */
72
+ type View$1 = {
73
+ name: string;
74
+ version: string;
75
+ summary: string;
76
+ owners?: string[];
77
+ screenshot?: string;
78
+ };
79
+ /**
80
+ * Generic node data structure - framework agnostic
81
+ */
82
+ interface BaseNodeData {
83
+ id: string;
84
+ version?: string;
85
+ name?: string;
86
+ summary?: string;
87
+ markdown?: string;
88
+ badges?: Array<{
89
+ content: string;
90
+ textColor?: string;
91
+ backgroundColor?: string;
92
+ }>;
93
+ group?: {
94
+ id: string;
95
+ name: string;
96
+ type: string;
97
+ };
98
+ [key: string]: any;
99
+ }
100
+ /**
101
+ * Node types supported by the visualizer
102
+ */
103
+ type NodeType = "service" | "services" | "event" | "events" | "command" | "commands" | "query" | "queries" | "domain" | "domains" | "flow" | "flows" | "channel" | "channels" | "entity" | "entities" | "step" | "user" | "custom" | "externalSystem" | "external-system" | "data" | "view" | "actor" | "data-product" | "data-products" | "note";
104
+ /**
105
+ * Edge types supported by the visualizer
106
+ */
107
+ type EdgeType = "default" | "animated" | "multiline" | "flow-edge";
108
+ /**
109
+ * Callback types for framework integration
110
+ */
111
+ interface VisualizerCallbacks {
112
+ /** Called when a node is clicked */
113
+ onNodeClick?: (node: Node<BaseNodeData>) => void;
114
+ /** Called to build a URL for a node (for linking) */
115
+ onBuildNodeUrl?: (node: Node<BaseNodeData>) => string;
116
+ /** Called when navigation should occur */
117
+ onNavigate?: (url: string) => void;
118
+ }
119
+ /**
120
+ * Configuration for node registration
121
+ */
122
+ interface NodeConfiguration {
123
+ type: string;
124
+ icon: React.ComponentType;
125
+ color: string;
126
+ targetCanConnectTo?: string[];
127
+ sourceCanConnectTo?: string[];
128
+ validateConnection?: (connection: Connection) => boolean;
129
+ getEdgeOptions?: (connection: Connection) => {
130
+ label: string;
131
+ markerEnd: {
132
+ type: MarkerType;
133
+ color: string;
134
+ };
135
+ };
136
+ defaultData?: any;
137
+ editor?: {
138
+ title: string;
139
+ subtitle: string;
140
+ schema: any;
141
+ };
142
+ }
143
+ /**
144
+ * Registered node type
145
+ */
146
+ type RegisteredNode = {
147
+ type: string;
148
+ category: string;
149
+ component: React.ComponentType<any>;
150
+ configuration: NodeConfiguration;
151
+ };
152
+ /**
153
+ * Node category
154
+ */
155
+ type NodeCategory = {
156
+ type: string;
157
+ label: string;
158
+ icon: React.ComponentType;
159
+ };
160
+ /**
161
+ * Context menu item for node right-click menus
162
+ */
163
+ type ContextMenuItem = {
164
+ label: string;
165
+ href: string;
166
+ download?: string;
167
+ external?: boolean;
168
+ separator?: boolean;
169
+ };
170
+ /**
171
+ * Visualizer mode
172
+ */
173
+ type VisualizerMode = "full" | "simple";
174
+ /**
175
+ * Link to other visualizer views
176
+ */
177
+ interface VisualizerLink {
178
+ label: string;
179
+ url: string;
180
+ }
181
+
182
+ interface NodeGraphProps {
183
+ id: string;
184
+ title?: string;
185
+ href?: string;
186
+ hrefLabel?: string;
187
+ nodes: Node[];
188
+ edges: Edge[];
189
+ linkTo?: "docs" | "visualiser";
190
+ includeKey?: boolean;
191
+ footerLabel?: string;
192
+ linksToVisualiser?: boolean;
193
+ links?: {
194
+ label: string;
195
+ url: string;
196
+ }[];
197
+ mode?: "full" | "simple";
198
+ portalId?: string;
199
+ showFlowWalkthrough?: boolean;
200
+ showSearch?: boolean;
201
+ zoomOnScroll?: boolean;
202
+ designId?: string;
203
+ isChatEnabled?: boolean;
204
+ maxTextSize?: number;
205
+ isDevMode?: boolean;
206
+ resourceKey?: string;
207
+ onNodeClick?: (node: Node) => void;
208
+ onBuildUrl?: (path: string) => string;
209
+ onNavigate?: (url: string) => void;
210
+ onSaveLayout?: (resourceKey: string, positions: Record<string, {
211
+ x: number;
212
+ y: number;
213
+ }>) => Promise<boolean>;
214
+ onResetLayout?: (resourceKey: string) => Promise<boolean>;
215
+ }
216
+ declare const NodeGraph: ({ id, nodes, edges, title, href, linkTo, hrefLabel, includeKey, footerLabel, linksToVisualiser, links, mode, portalId, showFlowWalkthrough, showSearch, zoomOnScroll, designId, isChatEnabled, maxTextSize, isDevMode, resourceKey, onNodeClick, onBuildUrl, onNavigate, onSaveLayout, onResetLayout, }: NodeGraphProps) => react_jsx_runtime.JSX.Element | null;
217
+
218
+ interface MermaidViewProps {
219
+ nodes: Node[];
220
+ edges: Edge[];
221
+ maxTextSize?: number;
222
+ }
223
+ declare const MermaidView: ({ nodes, edges, maxTextSize, }: MermaidViewProps) => react_jsx_runtime.JSX.Element;
224
+
225
+ interface MessageData {
226
+ name: string;
227
+ version?: string;
228
+ }
229
+ interface ServiceData {
230
+ name: string;
231
+ version?: string;
232
+ }
233
+ interface DomainData {
234
+ name: string;
235
+ version?: string;
236
+ }
237
+ interface EntityData {
238
+ name: string;
239
+ version?: string;
240
+ }
241
+ interface NodeDataContent extends Record<string, unknown> {
242
+ message?: {
243
+ data: MessageData;
244
+ };
245
+ service?: {
246
+ data: ServiceData;
247
+ };
248
+ domain?: {
249
+ data: DomainData;
250
+ };
251
+ entity?: {
252
+ data: EntityData;
253
+ };
254
+ name?: string;
255
+ version?: string;
256
+ }
257
+ type CustomNode$1 = Node<NodeDataContent>;
258
+ interface VisualiserSearchProps {
259
+ nodes: CustomNode$1[];
260
+ onNodeSelect: (node: CustomNode$1) => void;
261
+ onClear: () => void;
262
+ onPaneClick?: () => void;
263
+ }
264
+ interface VisualiserSearchRef {
265
+ hideSuggestions: () => void;
266
+ }
267
+ declare const VisualiserSearch: react.ForwardRefExoticComponent<VisualiserSearchProps & react.RefAttributes<VisualiserSearchRef>>;
268
+
269
+ interface NodeData {
270
+ step?: {
271
+ title?: string;
272
+ summary?: string;
273
+ };
274
+ service?: {
275
+ data?: {
276
+ name?: string;
277
+ summary?: string;
278
+ };
279
+ };
280
+ message?: {
281
+ data?: {
282
+ name?: string;
283
+ summary?: string;
284
+ };
285
+ };
286
+ flow?: {
287
+ data?: {
288
+ name?: string;
289
+ };
290
+ };
291
+ custom?: {
292
+ title?: string;
293
+ label?: string;
294
+ summary?: string;
295
+ };
296
+ actor?: {
297
+ label?: string;
298
+ };
299
+ externalSystem?: {
300
+ label?: string;
301
+ };
302
+ }
303
+ interface CustomNode {
304
+ id: string;
305
+ data: NodeData;
306
+ }
307
+ interface StepWalkthroughProps {
308
+ nodes: CustomNode[];
309
+ edges: Edge[];
310
+ isFlowVisualization: boolean;
311
+ onStepChange: (nodeId: string | null, highlightPaths?: string[], shouldZoomOut?: boolean) => void;
312
+ mode?: "full" | "simple";
313
+ }
314
+ declare function StepWalkthrough({ nodes, edges, isFlowVisualization, onStepChange, mode, }: StepWalkthroughProps): react_jsx_runtime.JSX.Element | null;
315
+
316
+ interface FocusModeModalProps {
317
+ isOpen: boolean;
318
+ onClose: () => void;
319
+ initialNodeId: string | null;
320
+ nodes: Node[];
321
+ edges: Edge[];
322
+ nodeTypes: NodeTypes;
323
+ edgeTypes: EdgeTypes;
324
+ }
325
+ declare const FocusModeModal: react__default.FC<FocusModeModalProps>;
326
+
327
+ interface NodeContextMenuProps {
328
+ items: ContextMenuItem[];
329
+ children: React.ReactNode;
330
+ }
331
+ declare function NodeContextMenu({ items, children, }: NodeContextMenuProps): react_jsx_runtime.JSX.Element;
332
+
333
+ type MessageNodeData = EventCatalogResource & {
334
+ message: Message;
335
+ };
336
+ type EventNode = Node<MessageNodeData, "event">;
337
+ declare function Event(props: EventNode): react_jsx_runtime.JSX.Element;
338
+
339
+ declare const _default$3: NodeConfiguration;
340
+
341
+ type CommandNodeData = EventCatalogResource & {
342
+ message: Message;
343
+ };
344
+ type CommandNode = Node<CommandNodeData, "command">;
345
+ declare function Command(props: CommandNode): react_jsx_runtime.JSX.Element;
346
+
347
+ type QueryNodeData = EventCatalogResource & {
348
+ message: Message;
349
+ };
350
+ type QueryNode = Node<QueryNodeData, "query">;
351
+ declare function Query(props: QueryNode): react_jsx_runtime.JSX.Element;
352
+
353
+ type ServiceNodeData = EventCatalogResource & {
354
+ service: Service$1;
355
+ };
356
+ type ServiceNode = Node<ServiceNodeData, "service">;
357
+ declare function Service(props: ServiceNode): react_jsx_runtime.JSX.Element;
358
+
359
+ type ChannelNodeData = EventCatalogResource & {
360
+ channel: Channel$1;
361
+ };
362
+ type ChannelNode = Node<ChannelNodeData, "channel">;
363
+ declare function Channel(props: ChannelNode): react_jsx_runtime.JSX.Element;
364
+
365
+ type NoteNodeData = {
366
+ id: string;
367
+ text: string;
368
+ color?: string;
369
+ readOnly?: boolean;
370
+ };
371
+ type NoteNode = Node<NoteNodeData, "note">;
372
+ interface NoteNodeProps extends NoteNode {
373
+ onTextChange?: (id: string, text: string) => void;
374
+ onColorChange?: (id: string, color: string) => void;
375
+ showResizer?: boolean;
376
+ readOnly?: boolean;
377
+ }
378
+ declare function NoteNodeComponent({ id, data, selected, onTextChange, onColorChange, readOnly, }: NoteNodeProps): react_jsx_runtime.JSX.Element;
379
+
380
+ type DataNodeData = EventCatalogResource & {
381
+ data: Data$1;
382
+ };
383
+ type DataNode = Node<DataNodeData, "data">;
384
+ declare function Data(props: DataNode): react_jsx_runtime.JSX.Element;
385
+
386
+ declare const _default$2: NodeConfiguration;
387
+
388
+ type ViewNodeData = EventCatalogResource & {
389
+ view: View$1;
390
+ };
391
+ type ViewNode = Node<ViewNodeData, "view">;
392
+ declare function View(props: ViewNode): react_jsx_runtime.JSX.Element;
393
+
394
+ type ActorNodeData = EventCatalogResource & {
395
+ name: string;
396
+ summary: string;
397
+ };
398
+ type ActorNode = Node<ActorNodeData, "actor">;
399
+ declare function Actor(props: ActorNode): react_jsx_runtime.JSX.Element;
400
+
401
+ declare const _default$1: NodeConfiguration;
402
+
403
+ type ExternalSystemNodeData = EventCatalogResource & {
404
+ externalSystem: ExternalSystem$1;
405
+ };
406
+ type ExternalSystemNode$1 = Node<ExternalSystemNodeData, "external-system">;
407
+ declare function ExternalSystem(props: ExternalSystemNode$1): react_jsx_runtime.JSX.Element;
408
+
409
+ declare const _default: NodeConfiguration;
410
+
411
+ declare function UserNode$1({ data, sourcePosition, targetPosition, }: any): react_jsx_runtime.JSX.Element;
412
+
413
+ declare function DomainNode({ data, id: nodeId }: any): react_jsx_runtime.JSX.Element;
414
+
415
+ declare function EntityNode({ data, sourcePosition, targetPosition, }: any): react_jsx_runtime.JSX.Element;
416
+
417
+ declare function FlowNode({ data, sourcePosition, targetPosition, }: any): react_jsx_runtime.JSX.Element;
418
+
419
+ declare function StepNode({ data, sourcePosition, targetPosition, }: any): react_jsx_runtime.JSX.Element;
420
+
421
+ declare function UserNode({ data, sourcePosition, targetPosition, }: any): react_jsx_runtime.JSX.Element;
422
+
423
+ interface DataProductNodeProps {
424
+ data: {
425
+ mode: "simple" | "full";
426
+ dataProduct: {
427
+ id: string;
428
+ version: string;
429
+ name: string;
430
+ summary?: string;
431
+ inputs?: any[];
432
+ outputs?: any[];
433
+ owners?: any[];
434
+ };
435
+ };
436
+ selected?: boolean;
437
+ }
438
+ declare function DataProductNode(props: DataProductNodeProps): react_jsx_runtime.JSX.Element;
439
+
440
+ declare function ExternalSystemNode(props: any): react_jsx_runtime.JSX.Element;
441
+
442
+ declare const SERVICE: string[];
443
+ declare const EVENT: string[];
444
+ declare const QUERY: string[];
445
+ declare const COMMAND: string[];
446
+ declare const CHANNEL: string[];
447
+ declare const ACTOR: string[];
448
+ declare const DATA: string[];
449
+ declare const VIEW: string[];
450
+ declare const MESSAGE: string[];
451
+
452
+ declare const nodeComponents: {
453
+ event: typeof Event;
454
+ command: typeof Command;
455
+ query: typeof Query;
456
+ service: typeof Service;
457
+ channel: typeof Channel;
458
+ note: typeof NoteNodeComponent;
459
+ externalSystem: typeof ExternalSystem;
460
+ data: typeof Data;
461
+ view: typeof View;
462
+ actor: typeof Actor;
463
+ custom: typeof UserNode$1;
464
+ domain: typeof DomainNode;
465
+ entity: typeof EntityNode;
466
+ flow: typeof FlowNode;
467
+ step: typeof StepNode;
468
+ user: typeof UserNode;
469
+ dataProduct: typeof DataProductNode;
470
+ externalSystem2: typeof ExternalSystemNode;
471
+ };
472
+ declare const nodeConfigs: {
473
+ event: NodeConfiguration;
474
+ data: NodeConfiguration;
475
+ actor: NodeConfiguration;
476
+ externalSystem: NodeConfiguration;
477
+ };
478
+
479
+ declare const AnimatedMessageEdge: ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, label, markerEnd, markerStart, }: any) => react_jsx_runtime.JSX.Element;
480
+
481
+ interface EdgeData {
482
+ message?: {
483
+ collection?: string;
484
+ };
485
+ opacity?: number;
486
+ animated?: boolean;
487
+ }
488
+ interface CustomEdgeProps extends Omit<EdgeProps, "data"> {
489
+ data?: EdgeData;
490
+ }
491
+ declare function CustomEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style, markerEnd, label, labelStyle, data, }: CustomEdgeProps): react_jsx_runtime.JSX.Element;
492
+
493
+ declare function MultilineEdgeLabel(props: EdgeProps): react_jsx_runtime.JSX.Element;
494
+
495
+ declare const edgeTypes: {
496
+ animated: ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, label, markerEnd, markerStart, }: any) => react_jsx_runtime.JSX.Element;
497
+ "flow-edge": typeof CustomEdge;
498
+ multiline: typeof MultilineEdgeLabel;
499
+ };
500
+
501
+ /**
502
+ * Mermaid Export Utility
503
+ * Converts React Flow nodes and edges to Mermaid flowchart syntax
504
+ */
505
+ interface MermaidExportOptions {
506
+ /** Include class definitions for styling */
507
+ includeStyles?: boolean;
508
+ /** Direction of the flowchart: LR (left-right), TB (top-bottom), etc. */
509
+ direction?: "LR" | "TB" | "RL" | "BT";
510
+ }
511
+ /**
512
+ * Convert React Flow nodes and edges to Mermaid flowchart syntax
513
+ */
514
+ declare function convertToMermaid(nodes: Node[], edges: Edge[], options?: MermaidExportOptions): string;
515
+
516
+ declare const exportNodeGraphForStudio: (data: ReactFlowJsonObject) => ReactFlowJsonObject;
517
+
518
+ interface BaseCollectionData {
519
+ id: string;
520
+ version: string;
521
+ }
522
+ interface CollectionItem {
523
+ collection: string;
524
+ data: BaseCollectionData;
525
+ }
526
+ interface MessageCollectionItem extends CollectionItem {
527
+ collection: "commands" | "events" | "queries";
528
+ }
529
+ declare const generateIdForNode: (node: CollectionItem) => string;
530
+ declare const generateIdForNodes: (nodes: any) => any;
531
+ declare const generatedIdForEdge: (source: CollectionItem, target: CollectionItem) => string;
532
+ declare const getColorFromString: (id: string) => string;
533
+ declare const getEdgeLabelForServiceAsTarget: (data: MessageCollectionItem) => "invokes" | "publishes \nevent" | "requests" | "sends to";
534
+ declare const getEdgeLabelForMessageAsSource: (data: MessageCollectionItem, throughChannel?: boolean) => "sends to" | "accepts" | "subscribed to" | "subscribed by";
535
+ declare const calculatedNodes: (flow: dagre.graphlib.Graph, nodes: Node[]) => any[];
536
+ declare const createDagreGraph: ({ ranksep, nodesep, ...rest }: any) => dagre.graphlib.Graph<{}>;
537
+ declare const createEdge: (edgeOptions: Edge) => Edge;
538
+ declare const createNode: (values: Node) => Node;
539
+ type DagreGraph = any;
540
+ declare const getNodesAndEdgesFromDagre: ({ nodes, edges, defaultFlow, }: {
541
+ nodes: Node[];
542
+ edges: Edge[];
543
+ defaultFlow?: DagreGraph;
544
+ }) => {
545
+ nodes: any[];
546
+ edges: Edge[];
547
+ };
548
+
549
+ export { ACTOR, Actor, type ActorNode, AnimatedMessageEdge, type BaseNodeData, CHANNEL, COMMAND, type Channel$1 as Channel, type ChannelNode, Command, type CommandNode, type ContextMenuItem, UserNode$1 as CustomNode, DATA, type Data$1 as Data, type DataNode, DataProductNode, DomainNode, EVENT, type EdgeType, EntityNode, Event, type EventCatalogResource, type EventNode, type ExternalSystem$1 as ExternalSystem, ExternalSystemNode as ExternalSystem2Node, type ExternalSystemNode$1 as ExternalSystemNode, CustomEdge as FlowEdge, FlowNode, FocusModeModal, MESSAGE, type MermaidExportOptions, MermaidView, type Message, MultilineEdgeLabel, type NodeCategory, type NodeConfiguration, NodeContextMenu, NodeGraph, type NodeType, NoteNodeComponent as Note, type NoteNode, QUERY, Query, type QueryNode, type RegisteredNode, SERVICE, type Service$1 as Service, type ServiceNode, StepNode, StepWalkthrough, UserNode, VIEW, type View$1 as View, type ViewNode, VisualiserSearch, type VisualizerCallbacks, type VisualizerLink, type VisualizerMode, _default$1 as actorConfig, calculatedNodes, convertToMermaid, createDagreGraph, createEdge, createNode, _default$2 as dataNodeConfig, edgeTypes, _default$3 as eventConfig, exportNodeGraphForStudio, _default as externalSystemConfig, generateIdForNode, generateIdForNodes, generatedIdForEdge, getColorFromString, getEdgeLabelForMessageAsSource, getEdgeLabelForServiceAsTarget, getNodesAndEdgesFromDagre, nodeComponents, nodeConfigs };