Skip to content

Commit 9e10e55

Browse files
authored
[Schema] Add api_node flag to node def schema (#3586)
1 parent 59cbe90 commit 9e10e55

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/schemas/nodeDef/nodeDefSchemaV2.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export const zComfyNodeDef = z.object({
7777
output_node: z.boolean(),
7878
python_module: z.string(),
7979
deprecated: z.boolean().optional(),
80-
experimental: z.boolean().optional()
80+
experimental: z.boolean().optional(),
81+
api_node: z.boolean().optional()
8182
})
8283

8384
// Export types

src/schemas/nodeDefSchema.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ export const zComfyNodeDef = z.object({
222222
output_node: z.boolean(),
223223
python_module: z.string(),
224224
deprecated: z.boolean().optional(),
225-
experimental: z.boolean().optional()
225+
experimental: z.boolean().optional(),
226+
/**
227+
* Whether the node is an API node. Running API nodes requires login to
228+
* Comfy Org account.
229+
* https://www.comfy.org/faq
230+
*/
231+
api_node: z.boolean().optional()
226232
})
227233

228234
// `/object_info`

src/stores/nodeDefStore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ComfyNodeDefImpl
4141
readonly deprecated: boolean
4242
readonly experimental: boolean
4343
readonly output_node: boolean
44+
readonly api_node: boolean
4445
/**
4546
* @deprecated Use `inputs` instead
4647
*/
@@ -121,6 +122,7 @@ export class ComfyNodeDefImpl
121122
this.experimental =
122123
obj.experimental ?? obj.category.startsWith('_for_testing')
123124
this.output_node = obj.output_node
125+
this.api_node = !!obj.api_node
124126
this.input = obj.input ?? {}
125127
this.output = obj.output ?? []
126128
this.output_is_list = obj.output_is_list

tests-ui/tests/nodeDef.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,23 @@ describe('ComfyNodeDefImpl', () => {
518518
expect(result.inputs['booleanInput']).toBeDefined()
519519
expect(result.inputs['floatInput']).toBeDefined()
520520
})
521+
522+
it.each([
523+
{ api_node: true, expected: true },
524+
{ api_node: false, expected: false },
525+
{ api_node: undefined, expected: false }
526+
] as { api_node: boolean | undefined; expected: boolean }[])(
527+
'should handle api_node field: $api_node',
528+
({ api_node, expected }) => {
529+
const result = new ComfyNodeDefImpl({
530+
name: 'ApiNode',
531+
display_name: 'API Node',
532+
category: 'Test',
533+
python_module: 'test_module',
534+
description: 'A node with API',
535+
api_node
536+
} as ComfyNodeDefV1)
537+
expect(result.api_node).toBe(expected)
538+
}
539+
)
521540
})

0 commit comments

Comments
 (0)