A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix(frontend): type GraphNode.nodeProperties/nodeMetadata/neighbors/links
dextmorgn203d6c1363ab
diff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsxindex 0bf42a78..a0ce21ee 100644--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx@@ -604,10 +604,14 @@ const DetailsPanel = memo(() => {) : getNodePropertyType(key) === 'list' ? (canEdit ? (<TagsInput- value={value || []}+ value={(value as string[] | undefined) || []}onChange={(tags) => handlePropertyBlur(key, tags)}orientation="vertical"- placeholder={value?.length === 0 ? 'Empty' : `Enter ${key.toLowerCase()}`}+ placeholder={+ (value as string[] | undefined)?.length === 0+ ? 'Empty'+ : `Enter ${key.toLowerCase()}`+ }/>) : (<span className="text-muted-foreground truncate">diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-highlight-state.ts b/flowsint-app/src/components/sketches/graph/hooks/use-highlight-state.tsindex 397e43eb..b3a8b3b6 100644--- a/flowsint-app/src/components/sketches/graph/hooks/use-highlight-state.ts+++ b/flowsint-app/src/components/sketches/graph/hooks/use-highlight-state.ts@@ -1,4 +1,15 @@import { useState, useCallback, useRef, useEffect } from 'react'+import type { GraphNode } from '@/types'++// react-force-graph's own onLinkHover/edge.source/edge.target types are+// `string | number | NodeObject` — the library mutates a plain edge's+// source/target from an id string into the actual node object once it's+// resolved the graph, and callers see whichever form depending on timing.+// Same duality already reflected on GraphNode.links in types/graph.ts.+type HoveredLink = { source: string | { id: string }; target: string | { id: string } }++const linkEndpointId = (endpoint: string | { id: string }): string =>+ typeof endpoint === 'object' ? endpoint.id : endpointexport const useHighlightState = () => {const [highlightNodes, setHighlightNodes] = useState<Set<string>>(new Set())@@ -6,7 +17,7 @@ export const useHighlightState = () => {const [hoverNode, setHoverNode] = useState<string | null>(null)const hoverFrameRef = useRef<number | null>(null)- const handleNodeHover = useCallback((node: any) => {+ const handleNodeHover = useCallback((node: GraphNode | null) => {if (hoverFrameRef.current) {cancelAnimationFrame(hoverFrameRef.current)}@@ -18,13 +29,13 @@ export const useHighlightState = () => {if (node) {newHighlightNodes.add(node.id)if (node.neighbors) {- node.neighbors.forEach((neighbor: any) => {+ node.neighbors.forEach((neighbor) => {newHighlightNodes.add(neighbor.id)})}if (node.links) {- node.links.forEach((link: any) => {- newHighlightLinks.add(`${link.source.id}-${link.target.id}`)+ node.links.forEach((link) => {+ newHighlightLinks.add(`${linkEndpointId(link.source)}-${linkEndpointId(link.target)}`)})}setHoverNode(node.id)@@ -38,7 +49,7 @@ export const useHighlightState = () => {})}, [])- const handleLinkHover = useCallback((link: any) => {+ const handleLinkHover = useCallback((link: HoveredLink | null) => {if (hoverFrameRef.current) {cancelAnimationFrame(hoverFrameRef.current)}@@ -48,8 +59,8 @@ export const useHighlightState = () => {const newHighlightLinks = new Set<string>()if (link) {- const sourceId = typeof link.source === 'object' ? link.source.id : link.source- const targetId = typeof link.target === 'object' ? link.target.id : link.target+ const sourceId = linkEndpointId(link.source)+ const targetId = linkEndpointId(link.target)newHighlightLinks.add(`${sourceId}-${targetId}`)newHighlightNodes.add(sourceId)newHighlightNodes.add(targetId)diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsxindex 18b55353..a9bcb43e 100644--- a/flowsint-app/src/components/table/nodes-view.tsx+++ b/flowsint-app/src/components/table/nodes-view.tsx@@ -128,7 +128,7 @@ const NodeItem = memo(function NodeItem({<Calendar className="h-3 w-3" /><span className="truncate">{node.nodeMetadata?.created_at- ? formatCreatedAt(node.nodeMetadata?.created_at)+ ? formatCreatedAt(node.nodeMetadata.created_at as string): 'Unknown'}</span></div>diff --git a/flowsint-app/src/lib/tools.test.ts b/flowsint-app/src/lib/tools.test.tsindex cfaa7a16..21ea6a07 100644--- a/flowsint-app/src/lib/tools.test.ts+++ b/flowsint-app/src/lib/tools.test.ts@@ -40,7 +40,14 @@ describe('getListOfAllChildrenFromNodes', () => {})it('should handle nodes with links', () => {- const nodes = [makeNode('node-1', { links: [{ target: 'node-2' }, { target: 'node-3' }] })]+ const nodes = [+ makeNode('node-1', {+ links: [+ { source: 'node-1', target: 'node-2' },+ { source: 'node-1', target: 'node-3' }+ ]+ })+ ]expect(getListOfAllChildrenFromNodes(nodes)).toEqual(undefined)})})diff --git a/flowsint-app/src/types/graph.ts b/flowsint-app/src/types/graph.tsindex 5e8cfb36..73fd3757 100644--- a/flowsint-app/src/types/graph.ts+++ b/flowsint-app/src/types/graph.ts@@ -1,7 +1,11 @@import type * as LucideIcons from 'lucide-react'+// Field shape is genuinely dynamic — driven by whichever custom type schema+// the backend defines for this node's nodeType, not a fixed TS shape. Callers+// narrow with typeof/Array.isArray/an explicit cast at the point they read a+// specific field, same as any other JSON-from-the-backend value.export type NodeProperties = {- [key: string]: any+ [key: string]: unknown}export const flagColors = {@@ -14,8 +18,9 @@ export const flagColors = {type flagColor = keyof typeof flagColors+// Same as NodeProperties above — backend-defined, not statically shaped.export type NodeMetadata = {- [key: string]: any+ [key: string]: unknown}export type NodeShape = 'circle' | 'square' | 'hexagon' | 'triangle'@@ -35,8 +40,19 @@ export type GraphNode = {x: numbery: numberval?: number- neighbors?: any[]- links?: any[]+ // Populated by transformGraphData (graph-data-transformer.ts) after the+ // initial fetch — every consumer only ever reads .id off a neighbor and+ // .source.id/.target.id off a link, so that's all this declares. Not+ // GraphNode[]/GraphEdge[]: neighbors briefly holds react-force-graph's+ // own runtime node objects mid-transform, and a fully accurate type would+ // have to be self-referential for no benefit nothing here reads.+ neighbors?: { id: string }[]+ // source/target start as plain id strings on the raw edge and get mutated+ // into node-object references by react-force-graph after it renders —+ // both forms show up here depending on when a consumer reads it (see the+ // `typeof x === 'object' ? x.id : x` guard used elsewhere for the edge+ // itself).+ links?: { source: string | { id: string }; target: string | { id: string } }[]}export type GraphEdge = {