/** @param {string} [title] @returns {Graph} */ export function createGraph(title?: string): Graph; export function createGraphId(): string; /** * @param {string} type * @param {{ x?: number, y?: number, width?: number, height?: number, id?: string, title?: string, data?: Record, graph?: Graph }} [options] * @param {NodeTypes} [nodeTypes] * @returns {GraphNode} */ export function createGraphNode(type: string, options?: { x?: number; y?: number; width?: number; height?: number; id?: string; title?: string; data?: Record; graph?: Graph; }, nodeTypes?: NodeTypes): GraphNode; /** @param {Graph} graph @param {GraphConnection} connection @param {NodeTypes} [nodeTypes] @returns {Graph} */ export function connectGraphNodes(graph: Graph, connection: GraphConnection, nodeTypes?: NodeTypes): Graph; /** @param {Graph} graph @param {NodeTypes} [nodeTypes] @returns {Graph} */ export function pruneGraphEdges(graph: Graph, nodeTypes?: NodeTypes): Graph; /** * Parse and validate a JSON graph, including all nested levels and port references. * @param {string} json * @param {NodeTypes} [nodeTypes] * @returns {Graph} */ export function parseGraph(json: string, nodeTypes?: NodeTypes): Graph; /** * Run a graph once in dependency order. Graph input and output values are keyed by * their boundary node IDs. Flowchart links are used for diagram layout. * @param {Graph} graph * @param {{ inputs?: Record, nodeTypes?: NodeTypes }} [options] * @returns {{ outputs: Record, values: Map> }} */ export function runGraph(graph: Graph, { inputs, nodeTypes }?: { inputs?: Record; nodeTypes?: NodeTypes; }): { outputs: Record; values: Map>; }; export { graphNodeTypes }; export { orientFlowGraph } from "./geometry.js"; /** @typedef {{ id: string, label: string, type: string, defaultValue?: unknown }} GraphPort */ /** @typedef {{ key: string, label: string, type: "number" | "text" | "boolean" }} GraphField */ /** @typedef {{ title: string, category?: string, tone?: string, inputs?: GraphPort[], outputs?: GraphPort[], data?: Record, fields?: GraphField[], run?: (inputs: Record, data: Record) => Record }} NodeDefinition */ /** @typedef {Record} NodeTypes */ /** @typedef {"horizontal" | "vertical"} FlowDirection */ /** @typedef {{ version: 1, title: string, direction?: FlowDirection, nodes: GraphNode[], edges: GraphEdge[] }} Graph */ /** @typedef {{ id: string, type: string, title: string, x: number, y: number, width?: number, height?: number, data: Record, graph?: Graph }} GraphNode */ /** @typedef {"straight" | "curve" | "orthogonal"} GraphEdgeStyle */ /** @typedef {{ source: string, sourcePort: string, target: string, targetPort: string, style?: GraphEdgeStyle }} GraphConnection */ /** @typedef {GraphConnection & { id: string }} GraphEdge */ /** @type {Record} */ export const edgeStyles: Record; export type GraphPort = { id: string; label: string; type: string; defaultValue?: unknown; }; export type GraphField = { key: string; label: string; type: "number" | "text" | "boolean"; }; export type NodeDefinition = { title: string; category?: string; tone?: string; inputs?: GraphPort[]; outputs?: GraphPort[]; data?: Record; fields?: GraphField[]; run?: (inputs: Record, data: Record) => Record; }; export type NodeTypes = Record; export type FlowDirection = "horizontal" | "vertical"; export type Graph = { version: 1; title: string; direction?: FlowDirection; nodes: GraphNode[]; edges: GraphEdge[]; }; export type GraphNode = { id: string; type: string; title: string; x: number; y: number; width?: number; height?: number; data: Record; graph?: Graph; }; export type GraphEdgeStyle = "straight" | "curve" | "orthogonal"; export type GraphConnection = { source: string; sourcePort: string; target: string; targetPort: string; style?: GraphEdgeStyle; }; export type GraphEdge = GraphConnection & { id: string; }; import { graphNodeTypes } from "./node-types.js";