forked from idootop/reactflow-auto-layout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
100 lines (89 loc) · 2.18 KB
/
types.ts
File metadata and controls
100 lines (89 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import type { Edge, Node, XYPosition } from '@xyflow/react';
import type { ControlPoint } from '../layout/edge/point';
interface WorkflowNode extends Record<string, unknown> {
id: string;
type: 'base' | 'start';
}
interface WorkflowEdge {
id: string;
source: string;
target: string;
sourceHandle: string;
targetHandle: string;
}
export interface Workflow {
nodes: WorkflowNode[];
edges: WorkflowEdge[];
}
export type ReactflowNodeData = WorkflowNode & {
/**
* The output ports of the current node.
*
* Format of Port ID: `nodeID#source#idx`
*/
sourceHandles: string[];
/**
* The input port of the current node (only one).
*
* Format of Port ID: `nodeID#target#idx`
*/
targetHandles: string[];
};
export interface ReactflowEdgePort {
/**
* Total number of edges in this direction (source or target).
*/
edges: number;
/**
* Number of ports
*/
portCount: number;
/**
* Port's index.
*/
portIndex: number;
/**
* Total number of Edges under the current port.
*/
edgeCount: number;
/**
* Index of the Edge under the current port.
*/
edgeIndex: number;
}
export interface EdgeLayout {
/**
* SVG path for edge rendering
*/
path: string;
/**
* Control points on the edge.
*/
points: ControlPoint[];
labelPosition: XYPosition;
/**
* Current layout dependent variables (re-layout when changed).
*/
deps?: any;
/**
* Potential control points on the edge, for debugging purposes only.
*/
inputPoints: ControlPoint[];
}
export interface ReactflowEdgeData extends Record<string, unknown> {
/**
* Data related to the current edge's layout, such as control points.
*/
layout?: EdgeLayout;
sourcePort: ReactflowEdgePort;
targetPort: ReactflowEdgePort;
}
export type ReactflowBaseNode = Node<ReactflowNodeData, 'base'>;
export type ReactflowStartNode = Node<ReactflowNodeData, 'start'>;
export type ReactflowNodeWithData = ReactflowBaseNode | ReactflowStartNode;
export type ReactflowBaseEdge = Edge<ReactflowEdgeData, 'base'>;
export type ReactflowEdgeWithData = ReactflowBaseEdge;
export interface Reactflow {
nodes: ReactflowNodeWithData[];
edges: ReactflowEdgeWithData[];
}