Skip to content

[Schema] Add api_node flag to node def schema #3586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
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
3 changes: 2 additions & 1 deletion src/schemas/nodeDef/nodeDefSchemaV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const zComfyNodeDef = z.object({
output_node: z.boolean(),
python_module: z.string(),
deprecated: z.boolean().optional(),
experimental: z.boolean().optional()
experimental: z.boolean().optional(),
api_node: z.boolean().optional()
})

// Export types
Expand Down
8 changes: 7 additions & 1 deletion src/schemas/nodeDefSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ export const zComfyNodeDef = z.object({
output_node: z.boolean(),
python_module: z.string(),
deprecated: z.boolean().optional(),
experimental: z.boolean().optional()
experimental: z.boolean().optional(),
/**
* Whether the node is an API node. Running API nodes requires login to
* Comfy Org account.
* https://www.comfy.org/faq
*/
api_node: z.boolean().optional()
})

// `/object_info`
Expand Down
2 changes: 2 additions & 0 deletions src/stores/nodeDefStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ComfyNodeDefImpl
readonly deprecated: boolean
readonly experimental: boolean
readonly output_node: boolean
readonly api_node: boolean
/**
* @deprecated Use `inputs` instead
*/
Expand Down Expand Up @@ -121,6 +122,7 @@ export class ComfyNodeDefImpl
this.experimental =
obj.experimental ?? obj.category.startsWith('_for_testing')
this.output_node = obj.output_node
this.api_node = !!obj.api_node
this.input = obj.input ?? {}
this.output = obj.output ?? []
this.output_is_list = obj.output_is_list
Expand Down
19 changes: 19 additions & 0 deletions tests-ui/tests/nodeDef.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,23 @@ describe('ComfyNodeDefImpl', () => {
expect(result.inputs['booleanInput']).toBeDefined()
expect(result.inputs['floatInput']).toBeDefined()
})

it.each([
{ api_node: true, expected: true },
{ api_node: false, expected: false },
{ api_node: undefined, expected: false }
] as { api_node: boolean | undefined; expected: boolean }[])(
'should handle api_node field: $api_node',
({ api_node, expected }) => {
const result = new ComfyNodeDefImpl({
name: 'ApiNode',
display_name: 'API Node',
category: 'Test',
python_module: 'test_module',
description: 'A node with API',
api_node
} as ComfyNodeDefV1)
expect(result.api_node).toBe(expected)
}
)
})