Line data Source code
1 : import type { MissingNodeType } from '@/platform/workflowErrors/nodeReplacement/types'
2 :
3 : import type { MissingNodePack } from '@comfyorg/telemetry/types'
4 :
5 2356 : const UNKNOWN_PACK_ID = 'unknown'
6 :
7 3881 : export function groupMissingNodesByPack(
8 : missingNodes: readonly MissingNodeType[]
9 : ): MissingNodePack[] {
10 3881 : const byPack = new Map<string, Set<string>>()
11 :
12 3881 : for (const node of missingNodes) {
13 95 : const type = typeof node === 'string' ? node : node.type
14 95 : const packId =
15 : typeof node === 'string' ? UNKNOWN_PACK_ID : node.cnrId || UNKNOWN_PACK_ID
16 :
17 95 : const existing = byPack.get(packId)
18 95 : if (existing) {
19 40 : existing.add(type)
20 : } else {
21 55 : byPack.set(packId, new Set([type]))
22 : }
23 : }
24 :
25 3881 : return Array.from(byPack, ([pack_id, types]) => ({
26 : pack_id,
27 : node_types: Array.from(types)
28 : }))
29 : }
|