mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
Validate node def from /object_info endpoint (#159)
* Validate node def * nit * nit * More tests
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
PendingTaskItem,
|
||||
RunningTaskItem,
|
||||
ComfyNodeDef,
|
||||
validateComfyNodeDef,
|
||||
} from "@/types/apiTypes";
|
||||
|
||||
interface QueuePromptRequestBody {
|
||||
@@ -240,7 +241,17 @@ class ComfyApi extends EventTarget {
|
||||
*/
|
||||
async getNodeDefs(): Promise<Record<string, ComfyNodeDef>> {
|
||||
const resp = await this.fetchApi("/object_info", { cache: "no-store" });
|
||||
return await resp.json();
|
||||
const objectInfoUnsafe = await resp.json();
|
||||
const objectInfo: Record<string, ComfyNodeDef> = {};
|
||||
for (const key in objectInfoUnsafe) {
|
||||
try {
|
||||
objectInfo[key] = validateComfyNodeDef(objectInfoUnsafe[key]);
|
||||
} catch (e) {
|
||||
console.warn("Ignore node definition: ", key);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
return objectInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user