Skip to content

Commit

Permalink
Last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
karurochari committed Aug 18, 2024
1 parent 8df2653 commit 6e24404
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/comfy-code-gen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Code generation from the workflow JSON file.
// Code generation from the workflow JSON file. This code is very messy and hopefully it will never be touched again.

import type { Static } from "@sinclair/typebox"
import type { WorkflowSchema } from "./comfy-types-base"

Expand Down Expand Up @@ -26,12 +27,12 @@ export function GenerateTSFromJson(json: Static<typeof WorkflowSchema>, base = '
done.add(nodeN)
}

function resolveArc(value: number | string | boolean | [string, number]) {
if (typeof value !== 'object') return JSON.stringify(value)
function resolveArc(value: number | string | boolean | null | undefined | [string, number]) {
if (typeof value !== 'object' || value === null || value === undefined) return JSON.stringify(value)
else {
const val = json.extra_data?.extra_pnginfo.workflow.nodes.find(x => x.id === Number.parseInt(value[0]))?.outputs[value[1]]
resolveNode(Number.parseInt(value[0]))
return `node_${value[0]}[${JSON.stringify(val.name)}]`;
return `node_${value[0]}[${JSON.stringify(val?.name)}]`;
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/comfy-types-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ export const WorkflowSchema = t.Object({
workflow: t.Object({
last_node_id: t.Optional(t.Integer()),
last_link_id: t.Optional(t.Integer()),
nodes: t.Array(t.Object({})),
nodes: t.Array(t.Object({
id: t.Integer(),
type: t.String(),
inputs: t.Array(t.Object({})),
outputs: t.Array(t.Object({
name: t.String(),
type: t.String(),
links: t.Array(t.Integer()),
}))
})),
links: t.Array(
t.Tuple([
t.Integer({ description: "ID" }),
Expand Down

0 comments on commit 6e24404

Please sign in to comment.