@@ -20,29 +20,31 @@ export class NodesService {
2020 input : Record < string , unknown > ,
2121 executionId : string ,
2222 ) : Promise < unknown > {
23- switch ( node . type ) {
24- case 'ai-llm' : return this . runAiLlm ( node , input ) ;
25- case 'web-scraper' : return this . runWebScraper ( node , input ) ;
26- case 'api-caller' : return this . runApiCaller ( node , input ) ;
27- case 'code-runner' : return this . runCodeRunner ( node , input ) ;
28- case 'email-sender' : return this . runEmailSender ( node , input ) ;
23+ const nodeType = ( ( node . data as Record < string , unknown > ) ?. type as string ) || node . type ;
24+ switch ( nodeType ) {
25+ case 'ai-llm' : return this . runAiLlm ( node , input ) ;
26+ case 'web-scraper' : return this . runWebScraper ( node , input ) ;
27+ case 'api-caller' : return this . runApiCaller ( node , input ) ;
28+ case 'code-runner' : return this . runCodeRunner ( node , input ) ;
29+ case 'email-sender' : return this . runEmailSender ( node , input ) ;
2930 case 'data-transform' : return this . runDataTransform ( node , input ) ;
3031 case 'webhook-output' : return this . runWebhookOutput ( node , input ) ;
31- case 'condition' : return this . runCondition ( node , input ) ;
32+ case 'condition' : return this . runCondition ( node , input ) ;
3233 default :
33- throw new BadRequestException ( `Unknown node type: ${ node . type } ` ) ;
34+ throw new BadRequestException ( `Unknown node type: ${ nodeType } ` ) ;
3435 }
3536 }
3637
3738 // ─── AI LLM Node ──────────────────────────────────────────
3839 private async runAiLlm ( node : FlowNode , input : Record < string , unknown > ) : Promise < unknown > {
39- const { prompt, model = 'gpt-4o' , systemPrompt } = node . data . config as {
40+ const { prompt, model = 'gpt-4o' , systemPrompt } = ( node . data . config || { } ) as {
4041 prompt : string ;
4142 model ?: string ;
4243 systemPrompt ?: string ;
4344 } ;
4445
45- // Allow prompt to reference upstream data with {{key}} syntax
46+ if ( ! prompt ) return { text : '[no prompt configured]' , usage : null } ;
47+
4648 const resolvedPrompt = this . interpolate ( prompt , input ) ;
4749
4850 const messages : OpenAI . ChatCompletionMessageParam [ ] = [ ] ;
@@ -81,13 +83,15 @@ export class NodesService {
8183
8284 // ─── API Caller Node ──────────────────────────────────────
8385 private async runApiCaller ( node : FlowNode , input : Record < string , unknown > ) : Promise < unknown > {
84- const { url, method = 'GET' , headers = { } , body } = node . data . config as {
86+ const { url, method = 'GET' , headers = { } , body } = ( node . data . config || { } ) as {
8587 url : string ;
8688 method ?: string ;
8789 headers ?: Record < string , string > ;
8890 body ?: string ;
8991 } ;
9092
93+ if ( ! url ) return { statusCode : 0 , data : '[no url configured]' , headers : { } } ;
94+
9195 const resolvedUrl = this . interpolate ( url , input ) ;
9296 const resolvedBody = body ? this . interpolate ( body , input ) : undefined ;
9397
0 commit comments