Line data Source code
1 : import { useFeatureFlags } from '@/composables/useFeatureFlags'
2 : import type { MissingNodeType } from '@/platform/workflowErrors/nodeReplacement/types'
3 : import { reportError } from '@comfyorg/telemetry/reportError'
4 : import { workflowNodeTypes } from '@/platform/workspace/composables/useDeploymentCompatibility'
5 : import { missingNodeTypeName } from '@/platform/workspace/missingForDeployment'
6 : import type { CheckedWorkflow } from '@/platform/workspace/workflowDeploymentOffer'
7 : import { app, sanitizeNodeName } from '@/scripts/app'
8 :
9 0 : function graphNodeTypes(): string[] {
10 0 : if (!useFeatureFlags().flags.deploymentCompatibilityMarksEnabled) return []
11 0 : if (!app.isGraphReady) return []
12 0 : try {
13 0 : return workflowNodeTypes(app.rootGraph)
14 : } catch (error) {
15 0 : reportError(error, {
16 : errorType: 'error_reading_workflow_node_types',
17 : surface: 'workspace',
18 : level: 'warning'
19 : })
20 0 : return []
21 : }
22 : }
23 :
24 : /** The open workflow as the compatibility check names its nodes: the types it sends, none while the check is off or the graph cannot be read, and these missing ones as the graph spells them. */
25 0 : export function openWorkflowForCheck(
26 : missingNodes: readonly MissingNodeType[]
27 : ): CheckedWorkflow {
28 0 : return {
29 : nodeTypes: graphNodeTypes(),
30 : missingNodeTypes: missingNodes.map((node) =>
31 : sanitizeNodeName(missingNodeTypeName(node))
32 : )
33 : }
34 : }
|