@@ -30,6 +30,25 @@ const zPreviewOutput = z
3030 } )
3131 . passthrough ( ) // Allow extra fields like nodeId, mediaType
3232
33+ /**
34+ * Execution error details for error jobs.
35+ * Contains the same structure as ExecutionErrorWsMessage from WebSocket.
36+ */
37+ const zExecutionError = z
38+ . object ( {
39+ node_id : z . string ( ) ,
40+ node_type : z . string ( ) ,
41+ executed : z . array ( z . string ( ) ) . optional ( ) ,
42+ exception_message : z . string ( ) ,
43+ exception_type : z . string ( ) ,
44+ traceback : z . array ( z . string ( ) ) ,
45+ current_inputs : z . unknown ( ) ,
46+ current_outputs : z . unknown ( )
47+ } )
48+ . passthrough ( )
49+
50+ export type ExecutionError = z . infer < typeof zExecutionError >
51+
3352/**
3453 * Raw job from API - uses passthrough to allow extra fields
3554 */
@@ -41,9 +60,11 @@ const zRawJobListItem = z
4160 preview_output : zPreviewOutput . nullable ( ) . optional ( ) ,
4261 outputs_count : z . number ( ) . optional ( ) ,
4362 error_message : z . string ( ) . nullable ( ) . optional ( ) ,
63+ execution_error : zExecutionError . nullable ( ) . optional ( ) ,
64+ workflow_id : z . string ( ) . nullable ( ) . optional ( ) ,
4465 priority : z . number ( ) . optional ( )
4566 } )
46- . passthrough ( ) // Allow extra fields like execution_time, workflow_id, update_time
67+ . passthrough ( )
4768
4869/**
4970 * Job list item with priority always set (either from server or synthetic)
@@ -52,61 +73,41 @@ const zJobListItem = zRawJobListItem.extend({
5273 priority : z . number ( ) // Always set: server-provided or synthetic (total - offset - index)
5374} )
5475
55- /**
56- * Extra data structure containing workflow
57- * Note: workflow is z.unknown() because it goes through validateComfyWorkflow separately
58- */
59- const zExtraData = z
60- . object ( {
61- extra_pnginfo : z
62- . object ( {
63- workflow : z . unknown ( )
64- } )
65- . optional ( )
66- } )
67- . passthrough ( )
68-
69- /**
70- * Execution error details for failed jobs.
71- * Contains the same structure as ExecutionErrorWsMessage from WebSocket.
72- */
73- const zExecutionError = z . object ( {
74- node_id : z . string ( ) ,
75- node_type : z . string ( ) ,
76- executed : z . array ( z . string ( ) ) ,
77- exception_message : z . string ( ) ,
78- exception_type : z . string ( ) ,
79- traceback : z . array ( z . string ( ) ) ,
80- current_inputs : z . unknown ( ) ,
81- current_outputs : z . unknown ( )
82- } )
83-
8476/**
8577 * Job detail - returned by GET /api/jobs/{job_id} (detail endpoint)
8678 * Includes full workflow and outputs for re-execution and downloads
87- *
88- * Note: workflow is at extra_data.extra_pnginfo.workflow (not in a separate workflow object)
8979 */
9080export const zJobDetail = zRawJobListItem
9181 . extend ( {
92- extra_data : zExtraData . optional ( ) ,
93- prompt : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
82+ workflow : z . unknown ( ) . optional ( ) ,
9483 outputs : zTaskOutput . optional ( ) ,
95- execution_time : z . number ( ) . optional ( ) ,
96- workflow_id : z . string ( ) . nullable ( ) . optional ( ) ,
97- execution_error : zExecutionError . nullable ( ) . optional ( )
84+ update_time : z . number ( ) . optional ( ) ,
85+ execution_status : z . unknown ( ) . optional ( ) ,
86+ execution_meta : z . unknown ( ) . optional ( )
9887 } )
9988 . passthrough ( )
10089
10190/**
102- * Jobs list response structure - raw from API (before synthetic priority)
91+ * Pagination info from API
92+ */
93+ const zPaginationInfo = z
94+ . object ( {
95+ offset : z . number ( ) ,
96+ limit : z . number ( ) ,
97+ total : z . number ( ) ,
98+ has_more : z . boolean ( )
99+ } )
100+ . passthrough ( )
101+
102+ /**
103+ * Jobs list response structure
103104 */
104105export const zJobsListResponse = z
105106 . object ( {
106107 jobs : z . array ( zRawJobListItem ) ,
107- total : z . number ( )
108+ pagination : zPaginationInfo
108109 } )
109- . passthrough ( ) // Allow extra fields like has_more, offset, limit
110+ . passthrough ( )
110111
111112// ============================================================================
112113// TypeScript Types (derived from Zod schemas)
0 commit comments