( selectedOutputs: string[] | undefined, blocks: Record<string, any> )
| 172 | } |
| 173 | |
| 174 | function resolveOutputIds( |
| 175 | selectedOutputs: string[] | undefined, |
| 176 | blocks: Record<string, any> |
| 177 | ): string[] | undefined { |
| 178 | if (!selectedOutputs || selectedOutputs.length === 0) { |
| 179 | return selectedOutputs |
| 180 | } |
| 181 | |
| 182 | return selectedOutputs.map((outputId) => { |
| 183 | const underscoreIndex = outputId.indexOf('_') |
| 184 | const dotIndex = outputId.indexOf('.') |
| 185 | if (underscoreIndex > 0) { |
| 186 | const maybeUuid = outputId.substring(0, underscoreIndex) |
| 187 | if (isValidUuid(maybeUuid)) { |
| 188 | return outputId |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | if (dotIndex > 0) { |
| 193 | const maybeUuid = outputId.substring(0, dotIndex) |
| 194 | if (isValidUuid(maybeUuid)) { |
| 195 | return `${outputId.substring(0, dotIndex)}_${outputId.substring(dotIndex + 1)}` |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | if (isValidUuid(outputId)) { |
| 200 | return outputId |
| 201 | } |
| 202 | |
| 203 | if (dotIndex === -1) { |
| 204 | logger.warn(`Invalid output ID format (missing dot): ${outputId}`) |
| 205 | return outputId |
| 206 | } |
| 207 | |
| 208 | const blockName = outputId.substring(0, dotIndex) |
| 209 | const path = outputId.substring(dotIndex + 1) |
| 210 | |
| 211 | const normalizedBlockName = normalizeName(blockName) |
| 212 | const block = Object.values(blocks).find((b: any) => { |
| 213 | return normalizeName(b.name || '') === normalizedBlockName |
| 214 | }) |
| 215 | |
| 216 | if (!block) { |
| 217 | logger.warn(`Block not found for name: ${blockName} (from output ID: ${outputId})`) |
| 218 | return outputId |
| 219 | } |
| 220 | |
| 221 | const resolvedId = `${block.id}_${path}` |
| 222 | logger.debug(`Resolved output ID: ${outputId} -> ${resolvedId}`) |
| 223 | return resolvedId |
| 224 | }) |
| 225 | } |
| 226 | |
| 227 | function bindRequestAbort( |
| 228 | requestSignal: AbortSignal, |
no test coverage detected