/** * Core Types for n8n Workflow Transformer * * Bidirectional transformation: n8n JSON ↔ TypeScript */ /** * Intermediate AST representation of a workflow * Used as bridge between JSON and TypeScript */ export interface WorkflowAST { metadata: WorkflowMetadata; nodes: NodeAST[]; connections: ConnectionAST[]; } /** * Workflow metadata (from @workflow decorator) */ export interface WorkflowMetadata { id: string; name: string; active: boolean; description?: string; tags?: string[]; settings?: WorkflowSettings; projectId?: string; projectName?: string; homeProject?: { id: string; name: string; type: string; }; isArchived?: boolean; } /** * Workflow settings */ export interface WorkflowSettings { executionOrder?: 'v0' | 'v1' | 'v2'; timeSavedMode?: 'fixed' | 'calculated'; errorWorkflow?: string; timezone?: string; saveManualExecutions?: boolean; saveDataErrorExecution?: 'all' | 'none'; saveExecutionProgress?: boolean; availableInMCP?: boolean; callerPolicy?: string; } /** * Node in AST representation */ export interface NodeAST { propertyName: string; id?: string; webhookId?: string; displayName: string; type: string; version: number; position: [number, number]; credentials?: Record; onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow'; alwaysOutputData?: boolean; executeOnce?: boolean; retryOnFail?: boolean; maxTries?: number; waitBetweenTries?: number; parameters: Record; aiDependencies?: AIDependencies; } /** * Credential reference */ export interface CredentialReference { id: string; name: string; } /** * AI node dependencies (langchain sub-nodes) */ export interface AIDependencies { ai_languageModel?: string; ai_memory?: string; ai_outputParser?: string; ai_tool?: string[]; ai_agent?: string; ai_chain?: string; ai_document?: string[]; ai_textSplitter?: string; ai_embedding?: string; ai_retriever?: string; ai_reranker?: string; ai_vectorStore?: string; } /** * Connection between nodes */ export interface ConnectionAST { from: { node: string; output: number; isError?: boolean; }; to: { node: string; input: number; }; } /** * n8n workflow JSON structure */ export interface N8nWorkflow { id: string; name: string; active: boolean; description?: string; nodes: N8nNode[]; connections: N8nConnections; settings?: WorkflowSettings; tags?: N8nWorkflowTag[]; projectId?: string; projectName?: string; homeProject?: { id: string; name: string; type: string; }; isArchived?: boolean; versionId?: string; activeVersionId?: string; versionCounter?: number; pinData?: any; } export type N8nWorkflowTag = string | { id?: string; name?: string; }; /** * n8n node JSON structure */ export interface N8nNode { id?: string; webhookId?: string; name: string; type: string; typeVersion?: number; position: [number, number]; parameters: Record; credentials?: Record; onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow'; alwaysOutputData?: boolean; executeOnce?: boolean; retryOnFail?: boolean; maxTries?: number; waitBetweenTries?: number; } /** * n8n connections structure * * Format: { [sourceNodeName]: { [outputType]: [ [{ node, type, index }] ] } } */ export interface N8nConnections { [sourceNodeName: string]: { [outputType: string]: Array>; }; } /** * Options for JSON → TypeScript transformation */ export interface JsonToTypeScriptOptions { /** Apply Prettier formatting to generated code */ format?: boolean; /** Comment style for generated code */ commentStyle?: 'minimal' | 'verbose'; /** Group nodes by type in comments */ groupNodes?: boolean; /** Auto-layout positions (for AI-generated workflows) */ autoLayout?: boolean; /** Class name (if not derived from workflow name) */ className?: string; } /** * Options for TypeScript → JSON transformation */ export interface TypeScriptToJsonOptions { /** Validate against n8n schema */ validate?: boolean; /** Generate deterministic node IDs (for testing) */ deterministicIds?: boolean; } /** * Validation result */ export interface ValidationResult { valid: boolean; errors: ValidationError[]; warnings?: ValidationWarning[]; } /** * Validation error */ export interface ValidationError { type: 'syntax' | 'structure' | 'reference' | 'schema'; message: string; location?: { file?: string; line?: number; column?: number; node?: string; }; } /** * Validation warning */ export interface ValidationWarning { type: 'deprecated' | 'performance' | 'best-practice'; message: string; location?: { node?: string; }; } /** * Property name generation context * Tracks used names to avoid collisions */ export interface PropertyNameContext { usedNames: Set; collisionCounter: Map; } /** * Position for auto-layout */ export interface LayoutPosition { x: number; y: number; } /** * Auto-layout configuration */ export interface AutoLayoutConfig { startX: number; startY: number; horizontalSpacing: number; verticalSpacing: number; columnWidth: number; } //# sourceMappingURL=types.d.ts.map