/** * Enhanced API Client for FlowDrop * * Uses configurable endpoints and supports pluggable authentication providers. * * @module api/enhanced-client */ import type { NodeMetadata, Workflow, ExecutionResult } from '../types/index.js'; import type { EndpointConfig } from '../config/endpoints.js'; import type { AuthProvider } from '../types/auth.js'; /** * API error with additional context */ export declare class ApiError extends Error { /** HTTP status code */ readonly status: number; /** Original error data from API */ readonly errorData: Record; /** Operation that was being performed */ readonly operation: string; constructor(message: string, status: number, operation: string, errorData?: Record); } /** * Enhanced HTTP API client for FlowDrop with configurable endpoints * * Supports pluggable authentication via AuthProvider interface. * * @example * ```typescript * // With AuthProvider * const client = new EnhancedFlowDropApiClient(config, authProvider); * * // Without authentication * const client = new EnhancedFlowDropApiClient(config); * ``` */ export interface PipelineDataResponse { status: string; jobs: Array>; node_statuses: Record; job_status_summary: { total: number; pending: number; running: number; completed: number; failed: number; cancelled: number; skipped?: number; paused?: number; interrupted?: number; }; kanban_config?: { columns: Array<{ key: string; label: string; statuses: string[]; icon?: string; color?: string; }>; }; } export declare class EnhancedFlowDropApiClient { private config; private authProvider; /** * Create a new EnhancedFlowDropApiClient * * @param config - Endpoint configuration * @param authProvider - Optional authentication provider (defaults to NoAuthProvider) */ constructor(config: EndpointConfig, authProvider?: AuthProvider); /** * Make HTTP request with error handling, retry logic, timeout, and auth support * * Uses apiSettings for timeout and retry configuration, falling back to EndpointConfig values. * * @param endpointKey - Key identifying the endpoint (for method/header lookup) * @param endpointPath - The endpoint path template * @param params - URL parameters to substitute * @param options - Additional fetch options * @param operation - Description of the operation (for error messages) */ private request; /** * Update the auth provider * * Useful for updating auth after token refresh in parent application. * Note: Per specification, this should rarely be needed as auth is typically * set at mount time and requires remount to change. * * @param authProvider - New authentication provider */ setAuthProvider(authProvider: AuthProvider): void; /** * Get current auth provider * * @returns The current AuthProvider instance */ getAuthProvider(): AuthProvider; /** * Fetch all available node types */ getAvailableNodes(): Promise; /** * Fetch nodes filtered by category */ getNodesByCategory(category: string): Promise; /** * Fetch metadata for a specific node type */ getNodeMetadata(nodeId: string): Promise; /** * Save a new workflow */ saveWorkflow(workflow: Workflow): Promise; /** * Update an existing workflow */ updateWorkflow(workflowId: string, workflow: Partial): Promise; /** * Load a workflow by ID */ loadWorkflow(workflowId: string): Promise; /** * List all workflows */ listWorkflows(): Promise; /** * Delete a workflow */ deleteWorkflow(workflowId: string): Promise; /** * Validate a workflow */ validateWorkflow(workflow: Workflow): Promise<{ valid: boolean; errors: string[]; }>; /** * Export a workflow as JSON string */ exportWorkflow(workflowId: string): Promise; /** * Import a workflow from JSON */ importWorkflow(workflowJson: string): Promise; /** * Execute a workflow */ executeWorkflow(workflowId: string, inputs?: Record): Promise; /** * Get execution status */ getExecutionStatus(executionId: string): Promise; /** * Cancel a running execution */ cancelExecution(executionId: string): Promise; /** * Get execution logs */ getExecutionLogs(executionId: string): Promise; /** * List available templates */ listTemplates(): Promise; /** * Get a template by ID */ getTemplate(templateId: string): Promise; /** * Get system health status */ getSystemHealth(): Promise<{ status: string; timestamp: number; }>; /** * Get system configuration */ getSystemConfig(): Promise>; /** * Get system version information */ getSystemVersion(): Promise<{ version: string; build: string; }>; /** * Fetch pipeline data including job information and status */ getPipelineData(pipelineId: string): Promise; }