Line data Source code
1 : import type { ComfyWorkflowJSON } from '@comfyorg/graph-model/workflowSchema'
2 : import type { AugmentedResultItem } from '@/utils/resultItem'
3 :
4 : /**
5 : * Metadata for output assets from queue store
6 : * Extends Record<string, unknown> for compatibility with AssetItem schema
7 : */
8 : export interface OutputAssetMetadata extends Record<string, unknown> {
9 : jobId: string
10 : nodeId?: string | number
11 : subfolder: string
12 : executionTimeInSeconds?: number
13 : format?: string
14 : workflow?: ComfyWorkflowJSON
15 : outputCount?: number
16 : allOutputs?: AugmentedResultItem[]
17 : assetId?: string
18 : }
19 :
20 : /**
21 : * Type guard to check if metadata is OutputAssetMetadata
22 : */
23 4889 : function isOutputAssetMetadata(
24 : metadata: Record<string, unknown> | undefined
25 : ): metadata is OutputAssetMetadata {
26 4889 : return (
27 : !!metadata &&
28 : typeof metadata.jobId === 'string' &&
29 : typeof metadata.subfolder === 'string'
30 : )
31 : }
32 :
33 : /**
34 : * Safely extract output asset metadata
35 : */
36 4889 : export function getOutputAssetMetadata(
37 : userMetadata: Record<string, unknown> | undefined
38 : ): OutputAssetMetadata | null {
39 4889 : if (isOutputAssetMetadata(userMetadata)) {
40 4866 : return userMetadata
41 : }
42 23 : return null
43 : }
|