diff --git a/src/validation/getFlowValidation.ts b/src/validation/getFlowValidation.ts index 90fd67a..67fc36d 100644 --- a/src/validation/getFlowValidation.ts +++ b/src/validation/getFlowValidation.ts @@ -12,6 +12,34 @@ export const getFlowValidation = ( ): ValidationResult => { + if (!flow?.startingNodeId) { + return { + isValid: false, + returnType: "void", + diagnostics: [{ + nodeId: null, + parameterIndex: null, + code: 0, + message: "You need to provide a starting node to be able to execute this flow.", + severity: "error", + }] + } + } + + if (!flow.nodes?.nodes?.find(n => n?.id == flow.startingNodeId)) { + return { + isValid: false, + returnType: "void", + diagnostics: [{ + nodeId: null, + parameterIndex: null, + code: 0, + message: "The starting node is not linked within the flow. Please make sure the starting node is connected to the rest of the flow.", + severity: "error", + }] + } + } + const sourceCode = generateFlowSourceCode(flow, functions, dataTypes); // 3. Virtual TypeScript Compilation diff --git a/test/flowValidation.test.ts b/test/flowValidation.test.ts index 772c7ea..f0394f7 100644 --- a/test/flowValidation.test.ts +++ b/test/flowValidation.test.ts @@ -8,6 +8,7 @@ describe('getFlowValidation - Integrationstest', () => { it('1', () => { const flow: Flow = { + startingNodeId: "gid://sagittarius/NodeFunction/1", nodes: { nodes: [ { @@ -51,7 +52,7 @@ describe('getFlowValidation - Integrationstest', () => { __typename: "ReferenceValue", nodeFunctionId: "gid://sagittarius/NodeFunction/2", parameterIndex: 1, - inputIndex: 0, //TODO: Das wird gerade einfach nicht berücksichtigt + inputIndex: 0, referencePath: [{path: "test"}] } }, @@ -149,6 +150,7 @@ describe('getFlowValidation - Integrationstest', () => { it('4', () => { const flow: Flow = { + startingNodeId: "gid://sagittarius/NodeFunction/1", nodes: { nodes: [ { @@ -198,6 +200,7 @@ describe('getFlowValidation - Integrationstest', () => { it('5', () => { const flow: Flow = { + startingNodeId: "gid://sagittarius/NodeFunction/2", nodes: { nodes: [ {