From d3cd952715c93a917ef0fc19b3b6e285792ee241 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 19:42:53 +0200 Subject: [PATCH 1/7] feat: update sagittarius-graphql-types version in package.json and package-lock.json --- package-lock.json | 10 +++++----- package.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index be3579c..bcd0409 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "@code0-tech/triangulum", "version": "0.1.0", "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", "@types/node": "^25.6.0", "@typescript/vfs": "^1.6.4", "lossless-json": "^4.3.0", @@ -18,7 +18,7 @@ "vitest": "^4.1.4" }, "peerDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", "@typescript/vfs": "^1.6.4", "lossless-json": "^4.3.0", "typescript": "^5.9.3 || ^6.0.2" @@ -75,9 +75,9 @@ } }, "node_modules/@code0-tech/sagittarius-graphql-types": { - "version": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9", - "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9.tgz", - "integrity": "sha512-ajb7VywS4z5GSkzhVBmM7wM+bIzxqeSo48SnS8QRLQbew6v62RedMM1uawe/CES9ZKbaHgXQC54XxekwfhbQsw==", + "version": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", + "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44.tgz", + "integrity": "sha512-UbkKnBeBVRFcB33JZBbuLjCLh2O7LCsxX76a0LNDfMW0bUJ9cwNYjN17YnRq9/zYn2clfDA0l6kya8DPGz46eg==", "dev": true }, "node_modules/@emnapi/core": { diff --git a/package.json b/package.json index 60acf97..c01e2b7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "build": "vite build" }, "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", "@types/node": "^25.6.0", "@typescript/vfs": "^1.6.4", "typescript": "^6.0.3", @@ -33,7 +33,7 @@ "lossless-json": "^4.3.0" }, "peerDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", "@typescript/vfs": "^1.6.4", "typescript": "^5.9.3 || ^6.0.2", "lossless-json": "^4.3.0" From 657e21f8f87e791990ec12a4cac1c136abd432d9 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 22:46:12 +0200 Subject: [PATCH 2/7] feat: refactor flow validation tests and update NodeFunctionIdWrapper to SubFlowValue --- src/utils.ts | 50 ++++++++++++++++++------------------- test/flowValidation.test.ts | 32 ++++++++++++------------ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 4dc207f..72d3b7d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,9 +4,9 @@ import { Flow, FunctionDefinition, NodeFunction, - NodeFunctionIdWrapper, + SubFlowValue, NodeParameter, - ReferenceValue + ReferenceValue, Maybe } from "@code0-tech/sagittarius-graphql-types"; import ts from "typescript"; import {createSystem, createVirtualTypeScriptEnvironment, VirtualTypeScriptEnvironment} from "@typescript/vfs" @@ -109,12 +109,12 @@ export function generateFlowSourceCode( ): string { const nodes = flow?.nodes?.nodes || []; const funcMap = new Map(functions?.map(f => [f.identifier, f])); - const visited = new Set(); + const visited = new Set(); - const generateNodeCode = (nodeId: string, indent: string = ""): string => { - const node = nodes.find(n => n?.id === nodeId); + const generateNodeCode = (id: NodeFunction['id'] | FunctionDefinition['id'], indent: string = ""): string => { + const node = nodes.find(n => n?.id === id); if (!node || !node.functionDefinition) return ""; - visited.add(nodeId); + visited.add(id); const funcDef = funcMap.get(node.functionDefinition.identifier); if (!funcDef) return `${indent}// Error: Function ${node.functionDefinition.identifier} not found\n`; @@ -122,7 +122,7 @@ export function generateFlowSourceCode( const params = (node.parameters?.nodes as NodeParameter[]) || []; const args = params.map((p, index) => { const val = p.value; - if (!val) return isForInference ? `/* @pos ${nodeId} ${index} */ {}` : `/* @pos ${nodeId} ${index} */ undefined`; + if (!val) return isForInference ? `/* @pos ${id} ${index} */ {}` : `/* @pos ${id} ${index} */ undefined`; if (val.__typename === "ReferenceValue") { const ref = val as ReferenceValue; let refCode = typeof ref.inputIndex === "number" @@ -131,19 +131,19 @@ export function generateFlowSourceCode( ref.referencePath?.forEach(pathObj => { refCode += `?.${pathObj.path}`; }); - return `/* @pos ${nodeId} ${index} */ ${refCode}`; + return `/* @pos ${id} ${index} */ ${refCode}`; } if (val.__typename === "LiteralValue") { const jsonString = stringify(val?.value) - return `/* @pos ${nodeId} ${index} */ ${jsonString}`; + return `/* @pos ${id} ${index} */ ${jsonString}`; } - if (val.__typename === "NodeFunctionIdWrapper") { - const wrapper = val as NodeFunctionIdWrapper; - const lambdaArgName = `p_${sanitizeId(nodeId)}_${index}`; - const subTreeCode = generateNodeCode(wrapper.id!, indent + " "); - return `/* @pos ${nodeId} ${index} */ (...${lambdaArgName}) => {\n${subTreeCode}${indent}}`; + if (val.__typename === "SubFlowValue") { + const wrapper = val as SubFlowValue; + const lambdaArgName = `p_${sanitizeId(id as string)}_${index}`; + const subTreeCode = generateNodeCode(wrapper.startingNodeId || wrapper.functionDefinition?.id!, indent + " "); + return `/* @pos ${id} ${index} */ (...${lambdaArgName}) => {\n${subTreeCode}${indent}}`; } - return isForInference ? `/* @pos ${nodeId} ${index} */ {}` : `/* @pos ${nodeId} ${index} */ undefined`; + return isForInference ? `/* @pos ${id} ${index} */ {}` : `/* @pos ${id} ${index} */ undefined`; }); const varName = `node_${sanitizeId(node.id!)}`; @@ -155,21 +155,21 @@ export function generateFlowSourceCode( let code = `${indent}`; if (node.functionDefinition.identifier === "std::control::return") { - code += `return /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `return /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` } else if (node.functionDefinition.identifier === "std::control::if") { - code += `const ${varName} = /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` code += `if(${args[0]}) { - ${generateNodeCode((node.parameters?.nodes?.[1]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} }` } else if (node.functionDefinition.identifier === "std::control::if_else") { - code += `const ${varName} = /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` code += `if(${args[0]}) { - ${generateNodeCode((node.parameters?.nodes?.[1]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} } else { - ${generateNodeCode((node.parameters?.nodes?.[2]?.value as NodeFunctionIdWrapper)?.id!, indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[2]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[2]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} }` } else { - code += `const ${varName} = /* @pos ${nodeId} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` + code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` } if (node.nextNodeId) code += generateNodeCode(node.nextNodeId, indent); @@ -181,9 +181,9 @@ export function generateFlowSourceCode( const funcDeclarations = functions?.map(f => `declare function fn_${f.identifier?.replace(/::/g, '_')}${f.signature}`).join('\n'); const nextNodeIds = new Set(nodes.map(n => n?.nextNodeId).filter(id => !!id)); - const subTreeIds = new Set(); - nodes.forEach(n => n?.parameters?.nodes?.forEach((p: any) => { - if (p?.value?.__typename === "NodeFunctionIdWrapper" && p.value.id) subTreeIds.add(p.value.id); + const subTreeIds = new Set(); + nodes.forEach(n => n?.parameters?.nodes?.forEach((p: Maybe) => { + if (p?.value?.__typename === "SubFlowValue" && (p.value.startingNodeId || p.value.functionDefinition?.id)) subTreeIds.add(p.value.startingNodeId || p.value.functionDefinition?.id); })); const flowCode = flow ? `const flow_${sanitizeId(flow.id ?? "")} = /* @pos null null */ flow(${flow.settings?.nodes?.map((setting, index) => `/* @pos null ${index} */ ${stringify(setting?.value)}`).join(", ") ?? ""});` : "" diff --git a/test/flowValidation.test.ts b/test/flowValidation.test.ts index 74a5372..978be32 100644 --- a/test/flowValidation.test.ts +++ b/test/flowValidation.test.ts @@ -35,8 +35,8 @@ describe('getFlowValidation - Integrationstest', () => { }, { value: { - __typename: "NodeFunctionIdWrapper", - id: "gid://sagittarius/NodeFunction/3" + __typename: "SubFlowValue", + startingNodeId: "gid://sagittarius/NodeFunction/3" } } ] @@ -234,8 +234,8 @@ describe('getFlowValidation - Integrationstest', () => { }, { value: { - __typename: "NodeFunctionIdWrapper", - id: "gid://sagittarius/NodeFunction/1" + __typename: "SubFlowValue", + startingNodeId: "gid://sagittarius/NodeFunction/1" } } ] @@ -284,8 +284,8 @@ describe('getFlowValidation - Integrationstest', () => { "identifier": "value" }, "value": { - "id": "gid://sagittarius/NodeFunction/2", - "__typename": "NodeFunctionIdWrapper" + "startingNodeId": "gid://sagittarius/NodeFunction/2", + "__typename": "SubFlowValue" } } ] @@ -434,8 +434,8 @@ describe('getFlowValidation - Integrationstest', () => { "identifier": "first" }, "value": { - "id": "gid://sagittarius/NodeFunction/4", - "__typename": "NodeFunctionIdWrapper" + "startingNodeId": "gid://sagittarius/NodeFunction/4", + "__typename": "SubFlowValue" } }, { @@ -843,8 +843,8 @@ describe('getFlowValidation - Integrationstest', () => { "identifier": "runnable" }, "value": { - "id": "gid://sagittarius/NodeFunction/4", - "__typename": "NodeFunctionIdWrapper" + "startingNodeId": "gid://sagittarius/NodeFunction/4", + "__typename": "SubFlowValue" } } ] @@ -1013,8 +1013,8 @@ describe('getFlowValidation - Integrationstest', () => { "updatedAt": "2026-04-13T19:45:26Z" }, "value": { - "__typename": "NodeFunctionIdWrapper", - "id": "gid://sagittarius/NodeFunction/19" + "__typename": "SubFlowValue", + "startingNodeId": "gid://sagittarius/NodeFunction/19" } }, { @@ -1030,8 +1030,8 @@ describe('getFlowValidation - Integrationstest', () => { "updatedAt": "2026-04-13T19:45:26Z" }, "value": { - "__typename": "NodeFunctionIdWrapper", - "id": "gid://sagittarius/NodeFunction/17" + "__typename": "SubFlowValue", + "startingNodeId": "gid://sagittarius/NodeFunction/17" } } ], @@ -1613,8 +1613,8 @@ describe('getFlowValidation - Integrationstest', () => { }, { value: { - __typename: "NodeFunctionIdWrapper", - id: "gid://sagittarius/NodeFunction/2" + __typename: "SubFlowValue", + startingNodeId: "gid://sagittarius/NodeFunction/2" } } ] From e8a386ee898c1c02fe22ea97d0d1ea0ce9d4f507 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 22:52:26 +0200 Subject: [PATCH 3/7] feat: update node_function_value to initialize SubFlow with starting_node_id --- gem/spec/support/protobuf_factories.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gem/spec/support/protobuf_factories.rb b/gem/spec/support/protobuf_factories.rb index fa7f247..36906e8 100644 --- a/gem/spec/support/protobuf_factories.rb +++ b/gem/spec/support/protobuf_factories.rb @@ -29,7 +29,11 @@ def reference_node(node_id:, paths: []) end def node_function_value(node_id) - Tucana::Shared::NodeValue.new(node_function_id: node_id) + Tucana::Shared::NodeValue.new( + sub_flow: Tucana::Shared::SubFlow.new( + starting_node_id: node_id + ) + ) end def node(id:, function_id:, parameters: [], next_node_id: nil) From 42b3c775c8b9b967f87ce875e023ba3fca13bc05 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 22:55:39 +0200 Subject: [PATCH 4/7] feat: update tucana dependency version to 0.0.72 in Gemfile.lock and triangulum.gemspec --- gem/Gemfile.lock | 2 +- gem/triangulum.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gem/Gemfile.lock b/gem/Gemfile.lock index 701d864..a9aa056 100644 --- a/gem/Gemfile.lock +++ b/gem/Gemfile.lock @@ -101,7 +101,7 @@ GEM rubyzip (2.4.1) stringio (3.2.0) tsort (0.2.0) - tucana (0.0.67) + tucana (0.0.72) grpc (~> 1.64) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) diff --git a/gem/triangulum.gemspec b/gem/triangulum.gemspec index fd63697..2239c23 100644 --- a/gem/triangulum.gemspec +++ b/gem/triangulum.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'base64', '~> 0.3' spec.add_dependency 'json', '~> 2.19' spec.add_dependency 'open3', '~> 0.2' - spec.add_dependency 'tucana', '~> 0.0', '>= 0.0.67' + spec.add_dependency 'tucana', '~> 0.0', '>= 0.0.72' spec.add_development_dependency 'irb', '~> 1.17' spec.add_development_dependency 'rake', '~> 13.0' From d5995f9c2f0ac21cb3228b24812aa01d251440e7 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 22:57:32 +0200 Subject: [PATCH 5/7] feat: update tucana dependency version to 0.0.72 in package.json and package-lock.json --- entrypoint/package-lock.json | 22 +++++++++++----------- entrypoint/package.json | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/entrypoint/package-lock.json b/entrypoint/package-lock.json index 1843344..1f92bd1 100644 --- a/entrypoint/package-lock.json +++ b/entrypoint/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "dependencies": { "@code0-tech/triangulum": "file:../", - "@code0-tech/tucana": "0.0.68", + "@code0-tech/tucana": "0.0.72", "@protobuf-ts/runtime": "^2.11.1" }, "devDependencies": { @@ -20,17 +20,17 @@ "name": "@code0-tech/triangulum", "version": "0.1.0", "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2432054881-32575715299651daa0758c145b8773a8f547330b", - "@types/node": "^25.5.0", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", + "@types/node": "^25.6.0", "@typescript/vfs": "^1.6.4", "lossless-json": "^4.3.0", - "typescript": "^6.0.2", - "vite": "^8.0.3", + "typescript": "^6.0.3", + "vite": "^8.0.8", "vite-plugin-dts": "^4.5.4", - "vitest": "^4.1.2" + "vitest": "^4.1.4" }, "peerDependencies": { - "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2432054881-32575715299651daa0758c145b8773a8f547330b", + "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44", "@typescript/vfs": "^1.6.4", "lossless-json": "^4.3.0", "typescript": "^5.9.3 || ^6.0.2" @@ -41,10 +41,10 @@ "link": true }, "node_modules/@code0-tech/tucana": { - "version": "0.0.68", - "resolved": "https://registry.npmjs.org/@code0-tech/tucana/-/tucana-0.0.68.tgz", - "integrity": "sha512-kbjLiKjJyZLnPmNi5JabWRNZcWZyXnfnld8jCFrUkvKbGj77CAwggR0uH8SqaxwWNWqQZlavYzCZWO/ob3+uKA==", - "license": "Apache-2.0" + "version": "0.0.72", + "resolved": "https://registry.npmjs.org/@code0-tech/tucana/-/tucana-0.0.72.tgz", + "integrity": "sha512-7H18wVWXlDU6rmRzOsOhcXp2MJBA5s/a6MCDqhlGQniMvp+nt1xDZHyAdHn6u2WuS/mST+T8eaHOurLib9861Q==", + "license": "MIT" }, "node_modules/@protobuf-ts/runtime": { "version": "2.11.1", diff --git a/entrypoint/package.json b/entrypoint/package.json index 5219e57..e53b0ab 100644 --- a/entrypoint/package.json +++ b/entrypoint/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@code0-tech/triangulum": "file:../", - "@code0-tech/tucana": "0.0.68", + "@code0-tech/tucana": "0.0.72", "@protobuf-ts/runtime": "^2.11.1" }, "devDependencies": { From 9c1e80aba51595e3d690c97833b08b5bdaf63a21 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 23:05:14 +0200 Subject: [PATCH 6/7] feat: add mapping functions for SubFlow and SubFlowValueSetting in mapper.ts --- entrypoint/mapper.ts | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/entrypoint/mapper.ts b/entrypoint/mapper.ts index 44695b8..11dbb45 100644 --- a/entrypoint/mapper.ts +++ b/entrypoint/mapper.ts @@ -7,6 +7,8 @@ import { NodeParameter, NodeParameterValue, ParameterDefinition, + SubFlowValue, + SubFlowValueSetting, } from "@code0-tech/sagittarius-graphql-types"; import { DefinitionDataType, @@ -16,6 +18,8 @@ import { ParameterDefinition as TucanaParameterDefinition, FlowSetting as TucanaFlowSetting, ValidationFlow, + SubFlow as TucanaSubFlow, + SubFlowSetting as TucanaSubFlowSetting, } from "@code0-tech/tucana/shared"; import {toAllowedValue} from "@code0-tech/tucana/helpers"; @@ -55,7 +59,7 @@ function mapFlow(flow: ValidationFlow): Flow { function mapFlowSetting(flowSetting: TucanaFlowSetting): FlowSetting { return { __typename: "FlowSetting", - id: gid('FlowSetting', flowSetting.databaseId) as FlowSetting['id'], + id: gid('FlowSetting', flowSetting.databaseId!) as FlowSetting['id'], flowSettingIdentifier: flowSetting.flowSettingId, value: flowSetting.value ? toAllowedValue(flowSetting.value) : null, } @@ -63,7 +67,7 @@ function mapFlowSetting(flowSetting: TucanaFlowSetting): FlowSetting { function mapNodeFunction(nodeFunction: TucanaNodeFunction): NodeFunction { return { - id: gid('NodeFunction', nodeFunction.databaseId) as NodeFunction['id'], + id: gid('NodeFunction', nodeFunction.databaseId!) as NodeFunction['id'], functionDefinition: { identifier: nodeFunction.runtimeFunctionId }, @@ -102,11 +106,8 @@ function mapNodeParameter(nodeParameter: TucanaNodeParameter): NodeParameter { value.parameterIndex = Number(target.inputType.parameterIndex) value.inputIndex = Number(target.inputType.inputIndex) } - } else if (nodeParameterValue?.oneofKind === 'nodeFunctionId') { - value = { - __typename: 'NodeFunctionIdWrapper', - id: gid('NodeFunction', nodeParameterValue.nodeFunctionId) as NodeFunction['id'] - } + } else if (nodeParameterValue?.oneofKind === 'subFlow') { + value = mapSubFlow(nodeParameterValue.subFlow); } return { @@ -131,6 +132,34 @@ function mapParameterDefinition(parameterDefinition: TucanaParameterDefinition): } } +function mapSubFlow(subFlow: TucanaSubFlow): SubFlowValue { + const value: SubFlowValue = { + __typename: 'SubFlowValue', + signature: subFlow.signature, + settings: subFlow.settings.map(mapSubFlowSetting) + }; + + if (subFlow.executionReference.oneofKind === 'startingNodeId') { + value.startingNodeId = gid('NodeFunction', subFlow.executionReference.startingNodeId) as NodeFunction['id']; + } else if (subFlow.executionReference.oneofKind === 'functionIdentifier') { + value.functionDefinition = { + identifier: subFlow.executionReference.functionIdentifier + } as FunctionDefinition; + } + + return value; +} + +function mapSubFlowSetting(setting: TucanaSubFlowSetting): SubFlowValueSetting { + return { + __typename: 'SubFlowValueSetting', + identifier: setting.identifier, + defaultValue: setting.defaultValue ? toAllowedValue(setting.defaultValue) : null, + optional: setting.optional, + hidden: setting.hidden + }; +} + function mapDataType(dataType: DefinitionDataType): DataType { return { identifier: dataType.identifier, From 1811be3a5438007b0b778643b983ff199b868401 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 28 May 2026 23:07:40 +0200 Subject: [PATCH 7/7] feat: update generateNodeCode to use identifier instead of id for SubFlowValue --- src/utils.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 72d3b7d..890281b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -109,12 +109,12 @@ export function generateFlowSourceCode( ): string { const nodes = flow?.nodes?.nodes || []; const funcMap = new Map(functions?.map(f => [f.identifier, f])); - const visited = new Set(); + const visited = new Set(); - const generateNodeCode = (id: NodeFunction['id'] | FunctionDefinition['id'], indent: string = ""): string => { + const generateNodeCode = (id: NodeFunction['id'] | FunctionDefinition['identifier'], indent: string = ""): string => { const node = nodes.find(n => n?.id === id); if (!node || !node.functionDefinition) return ""; - visited.add(id); + if (id?.includes("NodeFunction")) visited.add(id as NodeFunction['id']); const funcDef = funcMap.get(node.functionDefinition.identifier); if (!funcDef) return `${indent}// Error: Function ${node.functionDefinition.identifier} not found\n`; @@ -159,14 +159,14 @@ export function generateFlowSourceCode( } else if (node.functionDefinition.identifier === "std::control::if") { code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` code += `if(${args[0]}) { - ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.identifier), indent + " ")} }` } else if (node.functionDefinition.identifier === "std::control::if_else") { code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n` code += `if(${args[0]}) { - ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[1]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[1]?.value as SubFlowValue)?.functionDefinition?.identifier), indent + " ")} } else { - ${generateNodeCode(((node.parameters?.nodes?.[2]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[2]?.value as SubFlowValue)?.functionDefinition?.id), indent + " ")} + ${generateNodeCode(((node.parameters?.nodes?.[2]?.value as SubFlowValue)?.startingNodeId || (node.parameters?.nodes?.[2]?.value as SubFlowValue)?.functionDefinition?.identifier), indent + " ")} }` } else { code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n`