export type CreateApiComfyNodesBackfillArgs = {max_node?: number | undefined}; export type CreateApiComfyNodesBackfillOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * trigger comfy nodes backfill * * POST /comfy-nodes/backfill */ export const createApiComfyNodesBackfill = async (args: CreateApiComfyNodesBackfillArgs, options?: CreateApiComfyNodesBackfillOptions) => { const {baseUrl = "https://api.comfy.org", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.max_node != null) query.append("max_node", String(args.max_node)) const url = `${baseUrl.replace(/\/+$/, '')}/comfy-nodes/backfill${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };