mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 14:54:12 +00:00
Fix node def handling of undefined fields (#1199)
* Fix node def handling * nit * Add test
This commit is contained in:
@@ -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]
|
||||
)
|
||||
|
||||
@@ -346,10 +346,10 @@ const zComfyOutputTypesSpec = z.array(
|
||||
)
|
||||
|
||||
const zComfyNodeDef = z.object({
|
||||
input: zComfyInputsSpec,
|
||||
output: zComfyOutputTypesSpec,
|
||||
output_is_list: z.array(z.boolean()),
|
||||
output_name: z.array(z.string()),
|
||||
input: zComfyInputsSpec.optional(),
|
||||
output: zComfyOutputTypesSpec.optional(),
|
||||
output_is_list: z.array(z.boolean()).optional(),
|
||||
output_name: z.array(z.string()).optional(),
|
||||
output_tooltips: z.array(z.string()).optional(),
|
||||
name: z.string(),
|
||||
display_name: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user