@mp70/react-networks 0.1.0-alpha
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 +332 -0
- package/dist/index.css +23 -0
- package/dist/index.d.mts +656 -0
- package/dist/index.d.ts +656 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import { NodeProps, EdgeProps } from 'reactflow';
|
|
3
|
+
|
|
4
|
+
interface NetBoxDevice {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
device_type: {
|
|
8
|
+
id: number;
|
|
9
|
+
model: string;
|
|
10
|
+
manufacturer: {
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
device_role: {
|
|
15
|
+
name: string;
|
|
16
|
+
color: string;
|
|
17
|
+
};
|
|
18
|
+
site: {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
rack: {
|
|
22
|
+
id: number;
|
|
23
|
+
name: string;
|
|
24
|
+
} | null;
|
|
25
|
+
position: number | null;
|
|
26
|
+
face: 'front' | 'rear' | null;
|
|
27
|
+
status: {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
color: string;
|
|
31
|
+
};
|
|
32
|
+
primary_ip4?: {
|
|
33
|
+
address: string;
|
|
34
|
+
};
|
|
35
|
+
primary_ip6?: {
|
|
36
|
+
address: string;
|
|
37
|
+
};
|
|
38
|
+
interfaces: NetBoxInterface[];
|
|
39
|
+
}
|
|
40
|
+
interface NetBoxInterface {
|
|
41
|
+
id: number;
|
|
42
|
+
name: string;
|
|
43
|
+
type: {
|
|
44
|
+
label: string;
|
|
45
|
+
value: string;
|
|
46
|
+
};
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
mac_address: string | null;
|
|
49
|
+
mtu: number | null;
|
|
50
|
+
connected_endpoint_type: string | null;
|
|
51
|
+
connected_endpoint: {
|
|
52
|
+
device: {
|
|
53
|
+
name: string;
|
|
54
|
+
};
|
|
55
|
+
name: string;
|
|
56
|
+
} | null;
|
|
57
|
+
cable: {
|
|
58
|
+
id: number;
|
|
59
|
+
label: string;
|
|
60
|
+
type: string;
|
|
61
|
+
color: string;
|
|
62
|
+
} | null;
|
|
63
|
+
}
|
|
64
|
+
interface NetBoxRack {
|
|
65
|
+
id: number;
|
|
66
|
+
name: string;
|
|
67
|
+
site: {
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
70
|
+
group: {
|
|
71
|
+
name: string;
|
|
72
|
+
} | null;
|
|
73
|
+
tenant: {
|
|
74
|
+
name: string;
|
|
75
|
+
} | null;
|
|
76
|
+
role: {
|
|
77
|
+
name: string;
|
|
78
|
+
color: string;
|
|
79
|
+
} | null;
|
|
80
|
+
status: {
|
|
81
|
+
label: string;
|
|
82
|
+
value: string;
|
|
83
|
+
color: string;
|
|
84
|
+
};
|
|
85
|
+
facility_id: string | null;
|
|
86
|
+
serial: string | null;
|
|
87
|
+
asset_tag: string | null;
|
|
88
|
+
type: {
|
|
89
|
+
label: string;
|
|
90
|
+
value: string;
|
|
91
|
+
};
|
|
92
|
+
width: {
|
|
93
|
+
label: string;
|
|
94
|
+
value: number;
|
|
95
|
+
};
|
|
96
|
+
u_height: number;
|
|
97
|
+
desc_units: boolean;
|
|
98
|
+
outer_width: number | null;
|
|
99
|
+
outer_depth: number | null;
|
|
100
|
+
weight: number | null;
|
|
101
|
+
max_weight: number | null;
|
|
102
|
+
weight_unit: string;
|
|
103
|
+
mounting_depth: number | null;
|
|
104
|
+
devices: NetBoxDevice[];
|
|
105
|
+
}
|
|
106
|
+
interface NetBoxCable {
|
|
107
|
+
id: number;
|
|
108
|
+
label: string;
|
|
109
|
+
type: {
|
|
110
|
+
label: string;
|
|
111
|
+
value: string;
|
|
112
|
+
};
|
|
113
|
+
status: {
|
|
114
|
+
label: string;
|
|
115
|
+
value: string;
|
|
116
|
+
color: string;
|
|
117
|
+
};
|
|
118
|
+
color: string;
|
|
119
|
+
length: number | null;
|
|
120
|
+
length_unit: string;
|
|
121
|
+
termination_a_type: string;
|
|
122
|
+
termination_a: {
|
|
123
|
+
device: {
|
|
124
|
+
name: string;
|
|
125
|
+
};
|
|
126
|
+
name: string;
|
|
127
|
+
};
|
|
128
|
+
termination_b_type: string;
|
|
129
|
+
termination_b: {
|
|
130
|
+
device: {
|
|
131
|
+
name: string;
|
|
132
|
+
};
|
|
133
|
+
name: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
interface NetBoxConnection {
|
|
137
|
+
id: string;
|
|
138
|
+
source: {
|
|
139
|
+
device: string;
|
|
140
|
+
interface: string;
|
|
141
|
+
};
|
|
142
|
+
target: {
|
|
143
|
+
device: string;
|
|
144
|
+
interface: string;
|
|
145
|
+
};
|
|
146
|
+
cable: NetBoxCable;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Rack device width configuration
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
declare enum Width {
|
|
154
|
+
/** Full width device (19" rack width) */
|
|
155
|
+
FULL = "full",
|
|
156
|
+
/** Half width device (9.5" rack width) */
|
|
157
|
+
HALF = "half"
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Port configuration for network devices
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
interface Port {
|
|
164
|
+
/** Display label for the port */
|
|
165
|
+
label: string;
|
|
166
|
+
/** Whether the port is currently connected */
|
|
167
|
+
connected: boolean;
|
|
168
|
+
/** Type of port for styling and validation */
|
|
169
|
+
type?: 'ethernet' | 'fiber' | 'console' | 'mgmt' | 'usb' | 'power_ac' | 'power_c13' | 'power_c19';
|
|
170
|
+
/** Cable type for connection validation */
|
|
171
|
+
cableType?: 'smf' | 'cat6' | 'om3' | 'om4' | 'om5' | 'cat5e' | 'cat6a' | 'cat7' | 'fiber' | 'ethernet';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Group of related ports on a device
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
interface PortBlock {
|
|
178
|
+
/** Name of the port group */
|
|
179
|
+
name: string;
|
|
180
|
+
/** Array of ports in this group */
|
|
181
|
+
ports: Port[];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Network node types supported by the diagram
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
type NetworkNodeType = 'rack' | 'switch' | 'router' | 'server' | 'fiber' | 'patch-panel' | 'device' | 'vertical-pdu';
|
|
188
|
+
/**
|
|
189
|
+
* Device status states
|
|
190
|
+
* @public
|
|
191
|
+
*/
|
|
192
|
+
type DeviceStatus = 'active' | 'inactive' | 'maintenance';
|
|
193
|
+
/**
|
|
194
|
+
* Device view orientations
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
197
|
+
type DeviceView = 'front' | 'rear';
|
|
198
|
+
/**
|
|
199
|
+
* Power port side configuration
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
type PowerSide = 'left' | 'right';
|
|
203
|
+
/**
|
|
204
|
+
* Network node data structure
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
interface NetworkNode {
|
|
208
|
+
/** Unique identifier for the node */
|
|
209
|
+
id: string;
|
|
210
|
+
/** Type of network node */
|
|
211
|
+
type: NetworkNodeType;
|
|
212
|
+
/** Position coordinates in the diagram */
|
|
213
|
+
position: {
|
|
214
|
+
x: number;
|
|
215
|
+
y: number;
|
|
216
|
+
};
|
|
217
|
+
/** Parent node ID for React Flow sub-flows */
|
|
218
|
+
parentId?: string;
|
|
219
|
+
/** Node extent for sub-flows */
|
|
220
|
+
extent?: 'parent' | [[number, number], [number, number]];
|
|
221
|
+
/** Node data and configuration */
|
|
222
|
+
data: {
|
|
223
|
+
/** Display label for the node */
|
|
224
|
+
label: string;
|
|
225
|
+
/** Port configurations for the device */
|
|
226
|
+
ports?: PortBlock[];
|
|
227
|
+
/** List of connected node IDs */
|
|
228
|
+
connections?: string[];
|
|
229
|
+
/** Current status of the device */
|
|
230
|
+
status?: DeviceStatus;
|
|
231
|
+
/** NetBox integration ID */
|
|
232
|
+
netboxId?: number;
|
|
233
|
+
/** NetBox object type */
|
|
234
|
+
netboxType?: 'device' | 'rack' | 'interface' | 'cable';
|
|
235
|
+
/** Rack height in U units */
|
|
236
|
+
uHeight?: number;
|
|
237
|
+
/** Device position within rack in U units */
|
|
238
|
+
uPosition?: number;
|
|
239
|
+
/** Current view orientation */
|
|
240
|
+
view?: DeviceView;
|
|
241
|
+
/** Device type specification */
|
|
242
|
+
deviceType?: string;
|
|
243
|
+
/** Device manufacturer */
|
|
244
|
+
manufacturer?: string;
|
|
245
|
+
/** Device role in network */
|
|
246
|
+
role?: string;
|
|
247
|
+
/** Device width configuration */
|
|
248
|
+
width?: Width;
|
|
249
|
+
/** Rear port configurations */
|
|
250
|
+
rearPorts?: PortBlock[];
|
|
251
|
+
/** Power port side for rear view */
|
|
252
|
+
powerSide?: PowerSide;
|
|
253
|
+
/** Vertical PDU height in centimeters */
|
|
254
|
+
heightCm?: number;
|
|
255
|
+
/** Number of AC power ports */
|
|
256
|
+
powerPorts?: number;
|
|
257
|
+
/** Additional custom properties */
|
|
258
|
+
[key: string]: any;
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Network edge types
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
type NetworkEdgeType = 'fiber' | 'ethernet' | 'power';
|
|
266
|
+
/**
|
|
267
|
+
* Network edge data structure
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
interface NetworkEdge {
|
|
271
|
+
/** Unique identifier for the edge */
|
|
272
|
+
id: string;
|
|
273
|
+
/** Source node ID */
|
|
274
|
+
source: string;
|
|
275
|
+
/** Target node ID */
|
|
276
|
+
target: string;
|
|
277
|
+
/** Source handle/port ID */
|
|
278
|
+
sourceHandle?: string;
|
|
279
|
+
/** Target handle/port ID */
|
|
280
|
+
targetHandle?: string;
|
|
281
|
+
/** Type of network connection */
|
|
282
|
+
type?: NetworkEdgeType;
|
|
283
|
+
/** Edge data and configuration */
|
|
284
|
+
data?: {
|
|
285
|
+
/** Connection bandwidth */
|
|
286
|
+
bandwidth?: string;
|
|
287
|
+
/** Cable length */
|
|
288
|
+
length?: number;
|
|
289
|
+
/** Edge color for styling */
|
|
290
|
+
color?: string;
|
|
291
|
+
/** Edge kind for styling/validation */
|
|
292
|
+
kind?: 'fiber' | 'power' | 'network';
|
|
293
|
+
/** Additional custom properties */
|
|
294
|
+
[key: string]: any;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Rack device types
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
type RackDeviceType = 'server' | 'switch' | 'router' | 'patch-panel' | 'ups';
|
|
302
|
+
/**
|
|
303
|
+
* Rack configuration structure
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
interface RackConfig {
|
|
307
|
+
/** Unique rack identifier */
|
|
308
|
+
id: string;
|
|
309
|
+
/** Rack display name */
|
|
310
|
+
name: string;
|
|
311
|
+
/** Rack position coordinates */
|
|
312
|
+
position: {
|
|
313
|
+
x: number;
|
|
314
|
+
y: number;
|
|
315
|
+
};
|
|
316
|
+
/** Rack height in U units */
|
|
317
|
+
units: number;
|
|
318
|
+
/** Devices mounted in the rack */
|
|
319
|
+
devices: RackDevice[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Device mounted in a rack
|
|
323
|
+
* @public
|
|
324
|
+
*/
|
|
325
|
+
interface RackDevice {
|
|
326
|
+
/** Unique device identifier */
|
|
327
|
+
id: string;
|
|
328
|
+
/** Device display name */
|
|
329
|
+
name: string;
|
|
330
|
+
/** Starting U position in rack */
|
|
331
|
+
unit: number;
|
|
332
|
+
/** Device height in U units */
|
|
333
|
+
height: number;
|
|
334
|
+
/** Device type */
|
|
335
|
+
type: RackDeviceType;
|
|
336
|
+
/** Device width configuration */
|
|
337
|
+
width?: Width;
|
|
338
|
+
/** Device role in network */
|
|
339
|
+
role?: string;
|
|
340
|
+
/** Front port configurations */
|
|
341
|
+
ports?: PortBlock[];
|
|
342
|
+
/** Rear port configurations */
|
|
343
|
+
rearPorts?: PortBlock[];
|
|
344
|
+
/** Power port side for rear view */
|
|
345
|
+
powerSide?: PowerSide;
|
|
346
|
+
/** Connected device IDs */
|
|
347
|
+
connections?: string[];
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Fiber cable types
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
type FiberCableType = 'single-mode' | 'multi-mode';
|
|
354
|
+
/**
|
|
355
|
+
* Fiber cable configuration
|
|
356
|
+
* @public
|
|
357
|
+
*/
|
|
358
|
+
interface FiberCable {
|
|
359
|
+
/** Unique cable identifier */
|
|
360
|
+
id: string;
|
|
361
|
+
/** Cable display name */
|
|
362
|
+
name: string;
|
|
363
|
+
/** Fiber cable type */
|
|
364
|
+
type: FiberCableType;
|
|
365
|
+
/** Cable length */
|
|
366
|
+
length: number;
|
|
367
|
+
/** Cable color for visualization */
|
|
368
|
+
color: string;
|
|
369
|
+
/** Connection endpoints */
|
|
370
|
+
connections: {
|
|
371
|
+
/** Source connection point */
|
|
372
|
+
from: string;
|
|
373
|
+
/** Target connection point */
|
|
374
|
+
to: string;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Network diagram component props
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
interface NetworkDiagramProps {
|
|
383
|
+
/** Controlled nodes array */
|
|
384
|
+
nodes?: NetworkNode[];
|
|
385
|
+
/** Controlled edges array */
|
|
386
|
+
edges?: NetworkEdge[];
|
|
387
|
+
/** Callback when nodes change (controlled mode) */
|
|
388
|
+
onNodesChange?: (nodes: NetworkNode[]) => void;
|
|
389
|
+
/** Callback when edges change (controlled mode) */
|
|
390
|
+
onEdgesChange?: (edges: NetworkEdge[]) => void;
|
|
391
|
+
/** Initial nodes for uncontrolled mode */
|
|
392
|
+
initialNodes?: NetworkNode[];
|
|
393
|
+
/** Initial edges for uncontrolled mode */
|
|
394
|
+
initialEdges?: NetworkEdge[];
|
|
395
|
+
/** Headless store injection */
|
|
396
|
+
store?: any;
|
|
397
|
+
/** Enable debug mode */
|
|
398
|
+
debug?: boolean;
|
|
399
|
+
/** Callback when a node is clicked */
|
|
400
|
+
onNodeClick?: (node: NetworkNode) => void;
|
|
401
|
+
/** Callback when an edge is clicked */
|
|
402
|
+
onEdgeClick?: (edge: NetworkEdge) => void;
|
|
403
|
+
/** Callback when device view changes */
|
|
404
|
+
onViewChange?: (nodeId: string, view: DeviceView) => void;
|
|
405
|
+
/** Callback when rack face changes */
|
|
406
|
+
onRackFaceChange?: (rackId: string, face: DeviceView) => void;
|
|
407
|
+
/** CSS class name */
|
|
408
|
+
className?: string;
|
|
409
|
+
/** Inline styles */
|
|
410
|
+
style?: React.CSSProperties;
|
|
411
|
+
/** If true, vertically align rack bottoms to the same baseline */
|
|
412
|
+
alignRacksToBottom?: boolean;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* NetBox integration props
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
interface NetBoxNetworkDiagramProps extends NetworkDiagramProps {
|
|
419
|
+
/** NetBox data for integration */
|
|
420
|
+
netboxData?: {
|
|
421
|
+
/** NetBox racks */
|
|
422
|
+
racks: NetBoxRack[];
|
|
423
|
+
/** NetBox devices */
|
|
424
|
+
devices: NetBoxDevice[];
|
|
425
|
+
/** NetBox cables */
|
|
426
|
+
cables: NetBoxCable[];
|
|
427
|
+
};
|
|
428
|
+
/** Callback when NetBox data is updated */
|
|
429
|
+
onNetBoxUpdate?: (data: any) => void;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare const NetworkDiagram: React$1.FC<NetworkDiagramProps>;
|
|
433
|
+
|
|
434
|
+
interface RackNodeProps extends NodeProps<NetworkNode['data']> {
|
|
435
|
+
onViewChange?: (nodeId: string, view: 'front' | 'rear') => void;
|
|
436
|
+
onRackFaceChange?: (rackId: string, face: 'front' | 'rear') => void;
|
|
437
|
+
}
|
|
438
|
+
declare const RackNode: React$1.FC<RackNodeProps>;
|
|
439
|
+
|
|
440
|
+
declare const FiberNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
441
|
+
|
|
442
|
+
declare const FiberEdge: React$1.FC<EdgeProps<NetworkEdge['data']>>;
|
|
443
|
+
|
|
444
|
+
declare const PowerEdge: React$1.FC<EdgeProps>;
|
|
445
|
+
|
|
446
|
+
declare const DeviceNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
447
|
+
|
|
448
|
+
declare const VerticalPDU: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Convert NetBox rack data to NetworkNode
|
|
452
|
+
*/
|
|
453
|
+
declare const netboxRackToNetworkNode: (rack: NetBoxRack) => NetworkNode;
|
|
454
|
+
/**
|
|
455
|
+
* Convert NetBox device data to NetworkNode
|
|
456
|
+
*/
|
|
457
|
+
declare const netboxDeviceToNetworkNode: (device: NetBoxDevice) => NetworkNode;
|
|
458
|
+
/**
|
|
459
|
+
* Convert NetBox cable data to NetworkEdge
|
|
460
|
+
*/
|
|
461
|
+
declare const netboxCableToNetworkEdge: (cable: NetBoxCable) => NetworkEdge;
|
|
462
|
+
/**
|
|
463
|
+
* Convert NetBox data to network diagram format
|
|
464
|
+
*/
|
|
465
|
+
declare const netboxToNetworkDiagram: (data: {
|
|
466
|
+
racks: NetBoxRack[];
|
|
467
|
+
devices: NetBoxDevice[];
|
|
468
|
+
cables: NetBoxCable[];
|
|
469
|
+
}) => {
|
|
470
|
+
nodes: NetworkNode[];
|
|
471
|
+
edges: NetworkEdge[];
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Calculate U position for devices in a rack
|
|
475
|
+
*/
|
|
476
|
+
declare const calculateUPositions: (devices: NetBoxDevice[], rackHeight: number) => Map<number, number>;
|
|
477
|
+
/**
|
|
478
|
+
* Generate layout positions for nodes
|
|
479
|
+
*/
|
|
480
|
+
declare const generateLayout: (nodes: NetworkNode[]) => NetworkNode[];
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Snap a device position to the nearest U position within a rack
|
|
484
|
+
*/
|
|
485
|
+
declare const snapToUPosition: (device: NetworkNode, rack: NetworkNode, newPosition: {
|
|
486
|
+
x: number;
|
|
487
|
+
y: number;
|
|
488
|
+
}, allNodes: NetworkNode[]) => {
|
|
489
|
+
x: number;
|
|
490
|
+
y: number;
|
|
491
|
+
uPosition?: number;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Check if a U position is available in a rack
|
|
495
|
+
*/
|
|
496
|
+
declare const isUPositionAvailable: (rack: NetworkNode, device: NetworkNode, uPosition: number, allNodes: NetworkNode[]) => boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Find the next available U position in a rack
|
|
499
|
+
*/
|
|
500
|
+
declare const findNextAvailableUPosition: (rack: NetworkNode, device: NetworkNode, allNodes: NetworkNode[], startFrom?: number) => number;
|
|
501
|
+
/**
|
|
502
|
+
* Calculate device position based on U position within a rack
|
|
503
|
+
*/
|
|
504
|
+
declare const calculateDevicePositionFromU: (rack: NetworkNode, uPosition: number) => {
|
|
505
|
+
x: number;
|
|
506
|
+
y: number;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Update device U position and recalculate position
|
|
510
|
+
*/
|
|
511
|
+
declare const updateDeviceUPosition$1: (device: NetworkNode, rack: NetworkNode, newUPosition: number) => NetworkNode;
|
|
512
|
+
/**
|
|
513
|
+
* Validate and snap device to valid U position
|
|
514
|
+
*/
|
|
515
|
+
declare const validateAndSnapDevice: (device: NetworkNode, rack: NetworkNode) => NetworkNode;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Configuration options for building nodes from rack schema
|
|
519
|
+
*/
|
|
520
|
+
interface RackSchemaOptions {
|
|
521
|
+
/** How to handle device placement conflicts */
|
|
522
|
+
conflictPolicy?: 'strict' | 'nearest';
|
|
523
|
+
/** Whether to validate all placements before creating nodes */
|
|
524
|
+
validatePlacements?: boolean;
|
|
525
|
+
/** Custom device type mapping from schema to NetworkNode type */
|
|
526
|
+
deviceTypeMapping?: Record<string, NetworkNode['type']>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Error thrown when device placement conflicts occur in strict mode
|
|
530
|
+
*/
|
|
531
|
+
declare class DevicePlacementError extends Error {
|
|
532
|
+
rackId: string;
|
|
533
|
+
deviceId: string;
|
|
534
|
+
uPosition: number;
|
|
535
|
+
uHeight: number;
|
|
536
|
+
conflictWith?: string | undefined;
|
|
537
|
+
constructor(rackId: string, deviceId: string, uPosition: number, uHeight: number, conflictWith?: string | undefined);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Validation result for device placement
|
|
541
|
+
*/
|
|
542
|
+
interface DevicePlacementValidation {
|
|
543
|
+
isValid: boolean;
|
|
544
|
+
conflicts: Array<{
|
|
545
|
+
deviceId: string;
|
|
546
|
+
uPosition: number;
|
|
547
|
+
uHeight: number;
|
|
548
|
+
conflictWith: string;
|
|
549
|
+
}>;
|
|
550
|
+
outOfBounds: Array<{
|
|
551
|
+
deviceId: string;
|
|
552
|
+
uPosition: number;
|
|
553
|
+
uHeight: number;
|
|
554
|
+
rackUHeight: number;
|
|
555
|
+
}>;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Validate device placements within a rack schema
|
|
559
|
+
*/
|
|
560
|
+
declare function validateRackDevicePlacements(rack: RackConfig, options?: RackSchemaOptions): DevicePlacementValidation;
|
|
561
|
+
/**
|
|
562
|
+
* Build NetworkNode array from RackConfig array with comprehensive validation
|
|
563
|
+
*/
|
|
564
|
+
declare function buildNodesFromRackConfig(racks: RackConfig[], options?: RackSchemaOptions): NetworkNode[];
|
|
565
|
+
/**
|
|
566
|
+
* Create a RackConfig from existing NetworkNode data (reverse operation)
|
|
567
|
+
*/
|
|
568
|
+
declare function createRackConfigFromNodes(nodes: NetworkNode[]): RackConfig[];
|
|
569
|
+
/**
|
|
570
|
+
* Update device U position in a rack schema
|
|
571
|
+
*/
|
|
572
|
+
declare function updateDeviceUPosition(racks: RackConfig[], rackId: string, deviceId: string, newUPosition: number): RackConfig[];
|
|
573
|
+
/**
|
|
574
|
+
* Add a device to a rack schema
|
|
575
|
+
*/
|
|
576
|
+
declare function addDeviceToRack(racks: RackConfig[], rackId: string, device: RackDevice, options?: RackSchemaOptions): RackConfig[];
|
|
577
|
+
/**
|
|
578
|
+
* Remove a device from a rack schema
|
|
579
|
+
*/
|
|
580
|
+
declare function removeDeviceFromRack(racks: RackConfig[], rackId: string, deviceId: string): RackConfig[];
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Power connector utilities for consistent styling across devices and PDUs
|
|
584
|
+
*/
|
|
585
|
+
interface PowerConnectorConfig {
|
|
586
|
+
type: 'C13' | 'C14' | 'C19' | 'C20';
|
|
587
|
+
color: string;
|
|
588
|
+
borderColor: string;
|
|
589
|
+
amperage: number;
|
|
590
|
+
voltage: number;
|
|
591
|
+
phases: number;
|
|
592
|
+
}
|
|
593
|
+
declare const POWER_CONNECTORS: Record<string, PowerConnectorConfig>;
|
|
594
|
+
interface PowerPortStyle {
|
|
595
|
+
width: number;
|
|
596
|
+
height: number;
|
|
597
|
+
borderRadius?: string;
|
|
598
|
+
clipPath?: string;
|
|
599
|
+
color: string;
|
|
600
|
+
borderColor: string;
|
|
601
|
+
fontSize: string;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Get consistent power port styling for any connector type
|
|
605
|
+
*/
|
|
606
|
+
declare function getPowerPortStyle(connectorType: string): PowerPortStyle;
|
|
607
|
+
/**
|
|
608
|
+
* Get connector configuration by type
|
|
609
|
+
*/
|
|
610
|
+
declare function getConnectorConfig(connectorType: string): PowerConnectorConfig;
|
|
611
|
+
/**
|
|
612
|
+
* Determine if a connector is high power (16A)
|
|
613
|
+
*/
|
|
614
|
+
declare function isHighPowerConnector(connectorType: string): boolean;
|
|
615
|
+
/**
|
|
616
|
+
* Get PDU port type based on position in cycle
|
|
617
|
+
* PDU cycle: [8xC13, 2xC19] = 10 ports per cycle
|
|
618
|
+
*/
|
|
619
|
+
declare function getPDUPortType(portIndex: number): string;
|
|
620
|
+
/**
|
|
621
|
+
* Get device connector type based on device name
|
|
622
|
+
*/
|
|
623
|
+
declare function getDeviceConnectorType(deviceName: string): string;
|
|
624
|
+
|
|
625
|
+
interface NetworkDiagramState {
|
|
626
|
+
nodes: NetworkNode[];
|
|
627
|
+
edges: NetworkEdge[];
|
|
628
|
+
debug?: boolean;
|
|
629
|
+
}
|
|
630
|
+
interface ValidateConnectionParams {
|
|
631
|
+
source: string | null;
|
|
632
|
+
target: string | null;
|
|
633
|
+
sourceHandle?: string | null;
|
|
634
|
+
targetHandle?: string | null;
|
|
635
|
+
}
|
|
636
|
+
interface ValidationResult {
|
|
637
|
+
valid: boolean;
|
|
638
|
+
reason?: string;
|
|
639
|
+
}
|
|
640
|
+
interface NetworkDiagramOptions {
|
|
641
|
+
validateConnection?: (params: ValidateConnectionParams, ctx: NetworkDiagramState) => ValidationResult;
|
|
642
|
+
}
|
|
643
|
+
interface NetworkDiagramStore {
|
|
644
|
+
getState: () => NetworkDiagramState;
|
|
645
|
+
setState: (partial: Partial<NetworkDiagramState>) => void;
|
|
646
|
+
subscribe: (listener: (state: NetworkDiagramState) => void) => () => void;
|
|
647
|
+
selectEdgeZIndex: (edge: NetworkEdge) => number;
|
|
648
|
+
validateConnection: (params: ValidateConnectionParams) => ValidationResult;
|
|
649
|
+
}
|
|
650
|
+
declare function createNetworkDiagramStore(initial?: Partial<NetworkDiagramState>, options?: NetworkDiagramOptions): NetworkDiagramStore;
|
|
651
|
+
|
|
652
|
+
declare function useNetworkDiagram(store: NetworkDiagramStore): NetworkDiagramState;
|
|
653
|
+
declare function useNodes(store: NetworkDiagramStore): NetworkNode[];
|
|
654
|
+
declare function useEdges(store: NetworkDiagramStore): NetworkEdge[];
|
|
655
|
+
|
|
656
|
+
export { DeviceNode, DevicePlacementError, type DevicePlacementValidation, type FiberCable, FiberEdge, FiberNode, type NetBoxCable, type NetBoxConnection, type NetBoxDevice, type NetBoxInterface, type NetBoxNetworkDiagramProps, type NetBoxRack, NetworkDiagram, type NetworkDiagramProps, type NetworkEdge, type NetworkNode, POWER_CONNECTORS, PowerEdge, type RackConfig, type RackDevice, RackNode, type RackSchemaOptions, VerticalPDU, Width, addDeviceToRack, buildNodesFromRackConfig, calculateDevicePositionFromU, calculateUPositions, createNetworkDiagramStore, createRackConfigFromNodes, findNextAvailableUPosition, generateLayout, getConnectorConfig, getDeviceConnectorType, getPDUPortType, getPowerPortStyle, isHighPowerConnector, isUPositionAvailable, netboxCableToNetworkEdge, netboxDeviceToNetworkNode, netboxRackToNetworkNode, netboxToNetworkDiagram, removeDeviceFromRack, snapToUPosition, updateDeviceUPosition$1 as updateDeviceUPosition, updateDeviceUPosition as updateDeviceUPositionInSchema, useEdges as useDiagramEdges, useNodes as useDiagramNodes, useNetworkDiagram, validateAndSnapDevice, validateRackDevicePlacements };
|