refactor: nodes as builder pattern

This commit is contained in:
2026-03-12 11:01:35 +01:00
parent 302107e710
commit 86238b7efc
28 changed files with 1130 additions and 611 deletions

View File

@@ -0,0 +1,42 @@
import React from 'react'
import { ScrollText } from 'lucide-react'
import { createNodeTypeBuilder } from '@/lib/nodeTypeBuilder'
import { NODE_HELP } from '@/lib/nodeHelp'
import { getResolvedContentForConfig } from './renderingLogic'
import type { NodeTypeDescriptor } from '@/lib/nodeRegistry'
import ConfigNode from './ConfigNode'
const ICON_CLASS = 'mr-2 h-4 w-4'
export function getConfigNodeDescriptor(): NodeTypeDescriptor {
return createNodeTypeBuilder(
'config',
ConfigNode,
{ width: 320, height: 320 },
{ configType: 'plantuml', content: '@startuml\n\n@enduml\n', title: '' }
)
.idPrefix('cfg_')
.withInputOutput(true, true)
.classification('psyche')
.allowedSourceTypes(['config', 'variable', 'function', 'data'])
.allowedTargetTypes(['config', 'render', 'agent'])
.help(NODE_HELP.config)
.menu('Config', <ScrollText className={ICON_CLASS} />)
.getDefaultData((newId) => ({
configType: 'plantuml',
content: '@startuml\n\n@enduml\n',
title: newId ?? '',
}))
.getResetData((nodeId) => ({
configType: 'plantuml',
content: '@startuml\n\n@enduml\n',
title: nodeId ?? '',
}))
.connectionLabel('adding input')
.withFullscreen()
.sourceRenderingLogic({
defaultUpdateMode: 'auto',
getResolvedContent: getResolvedContentForConfig,
})
.build()
}