/** * API Variable Service * Handles fetching template variable schemas from REST endpoints at runtime. * Enables dynamic variable suggestions from backend APIs for template editors. * * @module services/apiVariableService */ import type { VariableSchema, ApiVariablesConfig, AuthProvider } from '../types/index.js'; /** * Context for variable API requests */ interface VariableContext { /** Workflow ID */ workflowId?: string; /** Node instance ID */ nodeId: string; } /** * Result of a variable schema fetch operation */ export interface ApiVariableResult { /** Whether the fetch was successful */ success: boolean; /** The fetched variable schema (if successful) */ schema?: VariableSchema; /** Error message (if failed) */ error?: string; /** Whether the schema was loaded from cache */ fromCache?: boolean; } /** Default cache TTL for variable data */ export declare const DEFAULT_VARIABLE_CACHE_TTL: number; /** * Replaces {workflowId} and {nodeId} placeholders in URL template. * * @param template - The URL template string * @param context - The variable context with workflowId and nodeId * @returns The resolved URL with placeholders replaced * * @example * ```typescript * const url = "/api/variables/{workflowId}/{nodeId}"; * const context = { workflowId: "wf-123", nodeId: "node-456" }; * resolveEndpointUrl(url, context); * // Returns "/api/variables/wf-123/node-456" * ``` */ export declare function resolveEndpointUrl(template: string, context: VariableContext): string; /** * Fetches variable schema from a backend API endpoint. * * @param workflowId - The workflow ID (optional) * @param nodeId - The node instance ID * @param config - The API variables configuration * @param authProvider - Optional auth provider for auth headers * @returns A promise that resolves to the variable schema result * * @example * ```typescript * const config: ApiVariablesConfig = { * endpoint: { * url: "/api/variables/{workflowId}/{nodeId}", * method: "GET" * }, * cacheTtl: 300000 * }; * * const result = await fetchVariableSchema("wf-123", "node-456", config); * if (result.success && result.schema) { * // Use the fetched variable schema * } * ``` */ export declare function fetchVariableSchema(workflowId: string | undefined, nodeId: string, config: ApiVariablesConfig, authProvider?: AuthProvider): Promise; /** * Clears the variable schema cache. * Can optionally clear only entries matching a specific pattern. * * @param pattern - Optional pattern to match cache keys (e.g., workflow ID or node ID) * * @example * ```typescript * // Clear all cache * clearVariableCache(); * * // Clear cache for a specific workflow * clearVariableCache("wf-123"); * * // Clear cache for a specific node * clearVariableCache("node-456"); * ``` */ export declare function clearVariableCache(pattern?: string): void; /** * Invalidates a specific variable cache entry. * * @param workflowId - The workflow ID (optional) * @param nodeId - The node instance ID */ export declare function invalidateVariableCache(workflowId: string | undefined, nodeId: string): void; /** * Gets the current cache size (number of entries). * * @returns The number of cached variable schemas */ export declare function getVariableCacheSize(): number; /** * Gets all cache keys currently stored. * Useful for debugging and monitoring. * * @returns Array of cache keys */ export declare function getVariableCacheKeys(): string[]; export {};