Fix node def handling of undefined fields (#1199)

* Fix node def handling

* nit

* Add test
This commit is contained in:
Chenlei Hu
2024-10-09 22:11:27 -04:00
committed by GitHub
parent 59a5f5f5d0
commit f71595fcc9
3 changed files with 22 additions and 8 deletions

View File

@@ -169,21 +169,21 @@ export class ComfyNodeDefImpl {
this.deprecated = obj.deprecated ?? obj.category === ''
this.experimental =
obj.experimental ?? obj.category.startsWith('_for_testing')
this.input = new ComfyInputsSpec(obj.input)
this.input = new ComfyInputsSpec(obj.input ?? {})
this.output = ComfyNodeDefImpl.transformOutputSpec(obj)
this.nodeSource = getNodeSource(obj.python_module)
}
private static transformOutputSpec(obj: any): ComfyOutputsSpec {
const { output, output_is_list, output_name, output_tooltips } = obj
const result = output.map((type: string | any[], index: number) => {
const result = (output ?? []).map((type: string | any[], index: number) => {
const typeString = Array.isArray(type) ? 'COMBO' : type
return new ComfyOutputSpec(
index,
output_name[index],
output_name?.[index],
typeString,
output_is_list[index],
output_is_list?.[index],
Array.isArray(type) ? type : undefined,
output_tooltips?.[index]
)