From 1474f9bbfa10ca5ff1f61f14cfdb66e057765f9e Mon Sep 17 00:00:00 2001 From: Jin Yi Date: Thu, 31 Jul 2025 15:42:32 +0900 Subject: [PATCH] feat: Add getImportFailInfoBulk function to comfyManagerService - Added new bulk API endpoint route for v2/customnode/import_fail_info_bulk - Implemented getImportFailInfoBulk function with proper validation and error handling - Added temporary type definitions (to be replaced with generated types after ComfyUI-Manager PR merge) - Includes JSDoc documentation and follows existing service patterns - Validates that either cnr_ids or urls arrays are provided This prepares the frontend for the new bulk import failure info API endpoint. Once the ComfyUI-Manager PR is merged and types are generated, the temporary types will be replaced with the auto-generated ones from the OpenAPI specification. --- src/services/comfyManagerService.ts | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/services/comfyManagerService.ts b/src/services/comfyManagerService.ts index b98be5958..a4c3fa415 100644 --- a/src/services/comfyManagerService.ts +++ b/src/services/comfyManagerService.ts @@ -15,6 +15,20 @@ import { isAbortError } from '@/utils/typeGuardUtil' const GENERIC_SECURITY_ERR_MSG = 'Forbidden: A security error has occurred. Please check the terminal logs' +// TODO: These types will be auto-generated once ComfyUI-Manager types are updated +// After the ComfyUI-Manager PR is merged and types are generated, replace these with the generated types +interface ImportFailInfoBulkRequest { + cnr_ids?: string[] + urls?: string[] +} + +interface ImportFailInfoItem { + error?: string | null + traceback?: string | null +} + +type ImportFailInfoBulkResponse = Record + /** * API routes for ComfyUI Manager */ @@ -32,6 +46,7 @@ enum ManagerRoute { GET_NODES = 'customnode/getmappings', GET_PACKS = 'customnode/getlist', IMPORT_FAIL_INFO = 'customnode/import_fail_info', + IMPORT_FAIL_INFO_BULK = 'v2/customnode/import_fail_info_bulk', REBOOT = 'manager/reboot' } @@ -154,6 +169,35 @@ export const useComfyManagerService = () => { ) } + /** + * Retrieves import failure information for multiple custom nodes in bulk + * @param params - Object containing arrays of cnr_ids or urls to check + * @param signal - Optional AbortSignal for request cancellation + * @returns Dictionary mapping each cnr_id/url to its import failure info (or null if no failure) + */ + const getImportFailInfoBulk = async ( + params: ImportFailInfoBulkRequest, + signal?: AbortSignal + ) => { + const errorContext = 'Fetching bulk import failure information' + const routeSpecificErrors = { + 400: 'Bad Request: Either cnr_ids or urls field is required' + } + + // Validate that at least one field is provided + if (!params.cnr_ids?.length && !params.urls?.length) { + throw new Error('Either cnr_ids or urls field is required') + } + + return executeRequest( + () => + managerApiClient.post(ManagerRoute.IMPORT_FAIL_INFO_BULK, params, { + signal + }), + { errorContext, routeSpecificErrors } + ) + } + const installPack = async ( params: InstallPackParams, signal?: AbortSignal @@ -260,6 +304,7 @@ export const useComfyManagerService = () => { // Pack management listInstalledPacks, getImportFailInfo, + getImportFailInfoBulk, installPack, uninstallPack, enablePack: installPack, // enable is done via install