export interface Graph { nodes: GraphNode[]; nextId: number; } export interface GraphNode { id: number; name: string; description: string; } export interface GraphNodePayload extends GraphNode { ref: string; } export function toPayload(node: GraphNode): GraphNodePayload { return { ...node, ref: `/nodes/${node.id}`, } } export function findSingle(graph: Graph, id: number) { return graph.nodes.find(n => n.id === id); }