mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
[feat] Add Jobs API infrastructure (PR 1 of 3)
Adds Jobs API types, fetchers, and new API methods without breaking existing code. This is the foundation for migrating from legacy /history and /queue endpoints to the unified /jobs endpoint. New files: - src/platform/remote/comfyui/jobs/types/jobTypes.ts - Zod schemas for Jobs API - src/platform/remote/comfyui/jobs/fetchers/fetchJobs.ts - Fetchers for /jobs endpoint - src/platform/remote/comfyui/jobs/index.ts - Barrel exports - tests-ui/tests/platform/remote/comfyui/jobs/fetchers/fetchJobs.test.ts API additions (non-breaking): - api.getQueueFromJobsApi() - Queue from /jobs endpoint - api.getHistoryFromJobsApi() - History from /jobs endpoint - api.getJobDetail() - Full job details including workflow and outputs Part of Jobs API migration. See docs/JOBS_API_MIGRATION_PLAN.md for details. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,12 @@ import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
|||||||
import type { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
import type { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||||
import type { AuthHeader } from '@/types/authTypes'
|
import type { AuthHeader } from '@/types/authTypes'
|
||||||
import type { NodeExecutionId } from '@/types/nodeIdentification'
|
import type { NodeExecutionId } from '@/types/nodeIdentification'
|
||||||
import { fetchHistory } from '@/platform/remote/comfyui/history'
|
import { fetchHistory as fetchHistoryLegacy } from '@/platform/remote/comfyui/history'
|
||||||
|
import {
|
||||||
|
fetchHistory as fetchHistoryFromJobsApi,
|
||||||
|
fetchQueue as fetchQueueFromJobsApi,
|
||||||
|
type JobListItem
|
||||||
|
} from '@/platform/remote/comfyui/jobs'
|
||||||
|
|
||||||
interface QueuePromptRequestBody {
|
interface QueuePromptRequestBody {
|
||||||
client_id: string
|
client_id: string
|
||||||
@@ -930,7 +935,7 @@ export class ComfyApi extends EventTarget {
|
|||||||
options?: { offset?: number }
|
options?: { offset?: number }
|
||||||
): Promise<{ History: HistoryTaskItem[] }> {
|
): Promise<{ History: HistoryTaskItem[] }> {
|
||||||
try {
|
try {
|
||||||
return await fetchHistory(
|
return await fetchHistoryLegacy(
|
||||||
this.fetchApi.bind(this),
|
this.fetchApi.bind(this),
|
||||||
max_items,
|
max_items,
|
||||||
options?.offset
|
options?.offset
|
||||||
@@ -1284,6 +1289,48 @@ export class ComfyApi extends EventTarget {
|
|||||||
getServerFeatures(): Record<string, unknown> {
|
getServerFeatures(): Record<string, unknown> {
|
||||||
return { ...this.serverFeatureFlags }
|
return { ...this.serverFeatureFlags }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Jobs API Methods (new unified /jobs endpoint)
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets queue from the unified Jobs API (/jobs endpoint)
|
||||||
|
* @returns Running and pending jobs with synthetic priorities
|
||||||
|
*/
|
||||||
|
async getQueueFromJobsApi(): Promise<{
|
||||||
|
Running: JobListItem[]
|
||||||
|
Pending: JobListItem[]
|
||||||
|
}> {
|
||||||
|
try {
|
||||||
|
return await fetchQueueFromJobsApi(this.fetchApi.bind(this))
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return { Running: [], Pending: [] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets history from the unified Jobs API (/jobs endpoint)
|
||||||
|
* @param maxItems Maximum number of items to fetch
|
||||||
|
* @param offset Offset for pagination
|
||||||
|
* @returns Array of completed jobs with synthetic priorities
|
||||||
|
*/
|
||||||
|
async getHistoryFromJobsApi(
|
||||||
|
maxItems: number = 200,
|
||||||
|
offset: number = 0
|
||||||
|
): Promise<JobListItem[]> {
|
||||||
|
try {
|
||||||
|
return await fetchHistoryFromJobsApi(
|
||||||
|
this.fetchApi.bind(this),
|
||||||
|
maxItems,
|
||||||
|
offset
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const api = new ComfyApi()
|
export const api = new ComfyApi()
|
||||||
|
|||||||
Reference in New Issue
Block a user