Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/validation/getFlowValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/flowValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('getFlowValidation - Integrationstest', () => {
it('1', () => {

const flow: Flow = {
startingNodeId: "gid://sagittarius/NodeFunction/1",
nodes: {
nodes: [
{
Expand Down Expand Up @@ -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"}]
}
},
Expand Down Expand Up @@ -149,6 +150,7 @@ describe('getFlowValidation - Integrationstest', () => {
it('4', () => {

const flow: Flow = {
startingNodeId: "gid://sagittarius/NodeFunction/1",
nodes: {
nodes: [
{
Expand Down Expand Up @@ -198,6 +200,7 @@ describe('getFlowValidation - Integrationstest', () => {
it('5', () => {

const flow: Flow = {
startingNodeId: "gid://sagittarius/NodeFunction/2",
nodes: {
nodes: [
{
Expand Down