import { X as PowerConnectorType, a as NetworkEdge, N as NetworkNode, D as DiagramDocument } from './index-CD1VEhzs.mjs'; import '@xyflow/react'; /** * A NetBox choice field. NetBox serializes choices as `{ value, label }`; older * payloads and hand-built fixtures often carry the bare value string. */ type NetBoxChoice = TValue | { value: TValue; label?: string; color?: string; }; interface NetBoxPortPosition { side?: 'top' | 'right' | 'bottom' | 'left'; offsetPercent?: number; offsetPx?: number; xPercent?: number; yPercent?: number; } interface NetBoxMappedPort { id?: string; label?: string; face?: 'front' | 'rear'; group?: string; type?: string; cableType?: string; connected?: boolean; connectorType?: PowerConnectorType; position?: NetBoxPortPosition; } interface NetBoxDeviceTransformOptions { /** * Include interface arrays as flat `ports` in generated nodes. * * Cable edges only carry a `sourceHandle` / `targetHandle` when the device * node actually mounts a port with that id (i.e. with this option on and the * termination is one of the device's interfaces). Otherwise the edge is * emitted handle-less so it attaches to the device's fallback anchors and * stays visible; the termination name is kept in `data.terminationA/B`. */ includeInterfacePorts?: boolean; /** Include per-port position metadata when provided */ includePortPositions?: boolean; /** Optional mapper for full control over interface-to-port mapping */ mapInterfaceToPort?: (args: { device: NetBoxDevice; iface: NetBoxInterface; index: number; }) => NetBoxMappedPort | null | undefined; } /** A nested `{ name }` reference (site, manufacturer, role, tenant, …). */ interface NetBoxNamedRef { id?: number; name: string; slug?: string; color?: string; } interface NetBoxDevice { id: number; name: string; device_type: { id?: number; model: string; /** Rack units; NetBox allows half-U steps (e.g. `0.5`), `0` for 0U. */ u_height?: number | null; manufacturer?: NetBoxNamedRef | null; }; /** Device role (NetBox ≥ 3.6 / 4.x). */ role?: NetBoxNamedRef | null; /** Legacy device role field (NetBox before 4.0); used when `role` is absent. */ device_role?: NetBoxNamedRef | null; site?: NetBoxNamedRef | null; rack?: { id: number; name: string; } | null; /** Lowest occupied U (may be fractional); `null` for unracked / 0U devices. */ position?: number | null; face?: NetBoxChoice<'front' | 'rear'> | null; status?: NetBoxChoice | null; primary_ip4?: { address: string; } | null; primary_ip6?: { address: string; } | null; interfaces?: NetBoxInterface[]; } /** * A device type from `GET /api/dcim/device-types/`. NetBox 4.5 nests device * types inside a device as a *brief* object without `u_height`, so pass the * device-type list to {@link netboxToNetworkDiagram} to size devices. */ interface NetBoxDeviceType { id: number; model?: string; slug?: string; /** Rack units; NetBox allows half-U steps (e.g. `0.5`), `0` for 0U. */ u_height?: number | null; manufacturer?: NetBoxNamedRef | null; } interface NetBoxInterface { id: number; name: string; /** * Owning device. Present on interfaces from `GET /api/dcim/interfaces/`, * which is how NetBox 4.5 serves them (they are not nested in the device). */ device?: { id?: number; name?: string; } | null; type?: { label: string; value: string; } | null; enabled?: boolean; mac_address?: string | null; mtu?: number | null; connected_endpoint_type?: string | null; connected_endpoint?: { device: { id?: number; name: string; }; name: string; } | null; cable?: { id: number; label?: string; type?: string; color?: string; } | null; /** Optional face hint used by UI transforms */ face?: 'front' | 'rear' | null; /** Optional display/ordering position from external enrichments */ position?: number | null; /** Optional grouping hint used by UI transforms */ port_group?: string | null; /** Optional explicit connector hint (e.g., C13/C19 for PDUs) */ connector_type?: 'C13' | 'C19' | 'C14' | 'C20' | null; /** Optional transform layout metadata */ layout?: NetBoxMappedPort; /** Optional custom fields payload from NetBox */ custom_fields?: Record; } interface NetBoxRack { id: number; name: string; site?: NetBoxNamedRef | null; group?: { name: string; } | null; tenant?: NetBoxNamedRef | null; role?: NetBoxNamedRef | null; status?: NetBoxChoice | null; facility_id?: string | null; serial?: string | null; asset_tag?: string | null; type?: NetBoxChoice | null; width?: NetBoxChoice | null; u_height: number; desc_units?: boolean; outer_width?: number | null; outer_depth?: number | null; weight?: number | null; max_weight?: number | null; weight_unit?: NetBoxChoice | null; mounting_depth?: number | null; devices?: NetBoxDevice[]; } /** The terminating object of a legacy (pre-3.3) cable end. */ interface NetBoxLegacyCableTermination { device?: { id?: number; name: string; } | null; name: string; } /** * One termination of a NetBox ≥ 3.3 multi-termination cable * (`a_terminations[]` / `b_terminations[]`). */ interface NetBoxCableTermination { /** e.g. `dcim.interface`, `dcim.frontport`, `dcim.powerport`. */ object_type?: string; object_id?: number; object?: { id?: number; name?: string; device?: { id?: number; name: string; } | null; } | null; } interface NetBoxCable { id: number; label?: string; /** Cable type, e.g. `cat6`, `smf-os2`, `power` (blank when unset). */ type?: NetBoxChoice | null; status?: NetBoxChoice | null; color?: string | null; length?: number | null; /** `m`, `cm`, `ft`, `in`, `km`, `mi` (blank / null when unset). */ length_unit?: NetBoxChoice | null; /** NetBox ≥ 3.3 A-side terminations. The first device-bound one is used. */ a_terminations?: NetBoxCableTermination[]; /** NetBox ≥ 3.3 B-side terminations. The first device-bound one is used. */ b_terminations?: NetBoxCableTermination[]; /** Legacy (pre-3.3) A-side termination type. */ termination_a_type?: string; /** Legacy (pre-3.3) A-side termination; used when `a_terminations` is absent. */ termination_a?: NetBoxLegacyCableTermination | null; /** Legacy (pre-3.3) B-side termination type. */ termination_b_type?: string; /** Legacy (pre-3.3) B-side termination; used when `b_terminations` is absent. */ termination_b?: NetBoxLegacyCableTermination | null; } /** * Convert NetBox rack data to NetworkNode */ declare const netboxRackToNetworkNode: (rack: NetBoxRack) => NetworkNode; /** * Convert NetBox device data to NetworkNode. * * Accepts NetBox 4.x (`role`) and legacy (`device_role`) payloads. `uPosition` * is only set for a racked device with a real position: an unracked or 0U * device (`position: null`) carries no `uPosition` rather than a fabricated U1. */ declare const netboxDeviceToNetworkNode: (device: NetBoxDevice, options?: NetBoxDeviceTransformOptions) => NetworkNode; /** * Convert NetBox cable data to NetworkEdge. * * Accepts NetBox ≥ 3.3 `a_terminations`/`b_terminations` and the legacy * `termination_a`/`termination_b`. The edge `type` follows the cable type * (`power` → `power`, fibre/AOC → `fiber`, any other named type → `ethernet`; * a blank type keeps the historical `fiber`). Lengths with a known * `length_unit` also carry `data.lengthCm` / `data.lengthUnit`. * * This standalone form cannot see the device nodes, so it sets * `sourceHandle`/`targetHandle` to the termination names verbatim — those only * resolve when the devices mount ports with those ids * (`includeInterfacePorts`). {@link netboxToNetworkDiagram} emits handles only * when the port exists. A cable with no device termination on a side gets an * empty `source`/`target`; `netboxToNetworkDiagram` drops such cables. */ declare const netboxCableToNetworkEdge: (cable: NetBoxCable) => NetworkEdge; /** * Input to {@link netboxToNetworkDiagram} / {@link netboxToDiagramDocument}: * the NetBox 4.5 REST lists, as returned by `GET /api/dcim//`. */ interface NetBoxDiagramInput { /** `GET /api/dcim/racks/` */ racks: NetBoxRack[]; /** `GET /api/dcim/devices/` */ devices: NetBoxDevice[]; /** `GET /api/dcim/cables/` */ cables: NetBoxCable[]; /** * `GET /api/dcim/device-types/`. A device listing only carries a brief * device type (no `u_height`), so without this every device is drawn 1U. */ deviceTypes?: NetBoxDeviceType[]; /** * `GET /api/dcim/interfaces/`. Grouped onto their devices by * `interface.device.id`; used with `includeInterfacePorts`. Interfaces * already nested in `device.interfaces` take precedence. */ interfaces?: NetBoxInterface[]; } /** * Convert NetBox data to network diagram format. * * Cable ends resolve by device id first, then by device name. A cable whose * either end has no device (circuit termination, power feed) or names a device * that is not in `devices` is dropped rather than left dangling. Handles are * only emitted for terminations the device node actually mounts as a port, so * cables stay visible (on the device's fallback anchors) when * `includeInterfacePorts` is off or the termination is not an interface. */ declare const netboxToNetworkDiagram: (data: NetBoxDiagramInput, options?: NetBoxDeviceTransformOptions) => { nodes: NetworkNode[]; edges: NetworkEdge[]; }; /** * Convert NetBox data directly into the canonical DiagramDocument model. */ declare const netboxToDiagramDocument: (data: NetBoxDiagramInput, options?: NetBoxDeviceTransformOptions) => DiagramDocument; /** * Calculate U position for devices in a rack */ declare const calculateUPositions: (devices: NetBoxDevice[], _rackHeight: number) => Map; export { DiagramDocument, type NetBoxCable, type NetBoxCableTermination, type NetBoxChoice, type NetBoxDevice, type NetBoxDeviceTransformOptions, type NetBoxDeviceType, type NetBoxDiagramInput, type NetBoxInterface, type NetBoxLegacyCableTermination, type NetBoxMappedPort, type NetBoxNamedRef, type NetBoxPortPosition, type NetBoxRack, NetworkEdge, NetworkNode, calculateUPositions, netboxCableToNetworkEdge, netboxDeviceToNetworkNode, netboxRackToNetworkNode, netboxToDiagramDocument, netboxToNetworkDiagram };