/** * WorkflowAdapter - Abstracts SvelteFlow internals for external systems * * This adapter provides a clean interface for working with workflows without * needing to understand SvelteFlow's internal structure. It handles: * - Converting between standard workflow format and SvelteFlow format * - CRUD operations on workflows, nodes, and edges * - Validation and error checking * - Import/export functionality * * The adapter is designed to be used by: * - Backend systems that need to process workflows * - External applications that want to integrate with FlowDrop * - Systems that need to generate or modify workflows programmatically */ import type { Workflow, NodeMetadata, WorkflowFormat } from '../types/index.js'; /** * Standard workflow node interface (SvelteFlow-agnostic) */ export interface StandardNode { id: string; type: string; position: { x: number; y: number; }; data: { label: string; config: Record; metadata: NodeMetadata; }; } /** * Standard workflow edge interface (SvelteFlow-agnostic) */ export interface StandardEdge { id: string; source: string; target: string; sourceHandle?: string; targetHandle?: string; } /** * Standard workflow interface (SvelteFlow-agnostic) */ export interface StandardWorkflow { id: string; name: string; description?: string; nodes: StandardNode[]; edges: StandardEdge[]; metadata?: { version: string; createdAt: string; updatedAt: string; author?: string; tags?: string[]; format?: WorkflowFormat; }; } /** * Workflow execution result */ export interface WorkflowExecutionResult { success: boolean; data?: unknown; error?: string; executionTime?: number; nodeResults?: Record; } /** * Workflow validation result */ export interface WorkflowValidationResult { valid: boolean; errors: string[]; warnings: string[]; } /** * Workflow Adapter Class * Provides a clean API for workflow operations without exposing SvelteFlow internals */ export declare class WorkflowAdapter { private nodeTypes; constructor(nodeTypes?: NodeMetadata[]); /** * Create a new workflow */ createWorkflow(name: string, description?: string): StandardWorkflow; /** * Add a node to a workflow */ addNode(workflow: StandardWorkflow, nodeType: string, position: { x: number; y: number; }, config?: Record): StandardNode; /** * Remove a node from a workflow */ removeNode(workflow: StandardWorkflow, nodeId: string): boolean; /** * Update node position */ updateNodePosition(workflow: StandardWorkflow, nodeId: string, position: { x: number; y: number; }): boolean; /** * Update node configuration */ updateNodeConfig(workflow: StandardWorkflow, nodeId: string, config: Record): boolean; /** * Add an edge between nodes */ addEdge(workflow: StandardWorkflow, sourceNodeId: string, targetNodeId: string, sourceHandle?: string, targetHandle?: string): StandardEdge; /** * Remove an edge from a workflow */ removeEdge(workflow: StandardWorkflow, edgeId: string): boolean; /** * Get all nodes of a specific type */ getNodesByType(workflow: StandardWorkflow, nodeType: string): StandardNode[]; /** * Get all edges connected to a node */ getNodeEdges(workflow: StandardWorkflow, nodeId: string): StandardEdge[]; /** * Get connected nodes (both incoming and outgoing) */ getConnectedNodes(workflow: StandardWorkflow, nodeId: string): StandardNode[]; /** * Validate workflow structure */ validateWorkflow(workflow: StandardWorkflow): WorkflowValidationResult; /** * Export workflow to JSON */ exportWorkflow(workflow: StandardWorkflow): string; /** * Import workflow from JSON */ importWorkflow(json: string): StandardWorkflow; /** * Convert SvelteFlow workflow to standard format */ fromSvelteFlow(svelteFlowWorkflow: Workflow): StandardWorkflow; /** * Convert standard workflow to SvelteFlow format */ toSvelteFlow(workflow: StandardWorkflow): Workflow; /** * Get workflow statistics */ getWorkflowStats(workflow: StandardWorkflow): { totalNodes: number; totalEdges: number; nodeTypeCounts: { [k: string]: number; }; lastModified: string | undefined; }; /** * Clone a workflow */ cloneWorkflow(workflow: StandardWorkflow, newName?: string): StandardWorkflow; }