()
| 121 | * the operation to its corresponding tool. |
| 122 | */ |
| 123 | export function buildToolOperationsIndex(): ToolOperationItem[] { |
| 124 | const operations: ToolOperationItem[] = [] |
| 125 | const allBlocks = getAllBlocks() |
| 126 | |
| 127 | for (const block of allBlocks) { |
| 128 | if (!block.tools?.access?.length || block.hideFromToolbar) { |
| 129 | continue |
| 130 | } |
| 131 | |
| 132 | if (block.category !== 'tools') { |
| 133 | continue |
| 134 | } |
| 135 | |
| 136 | const operationDropdown = findOperationDropdown(block) |
| 137 | if (!operationDropdown) { |
| 138 | continue |
| 139 | } |
| 140 | |
| 141 | const options = |
| 142 | typeof operationDropdown.options === 'function' |
| 143 | ? operationDropdown.options() |
| 144 | : operationDropdown.options |
| 145 | |
| 146 | if (!options) continue |
| 147 | |
| 148 | for (const option of options) { |
| 149 | if (!resolveToolId(block, option.id)) continue |
| 150 | |
| 151 | const operationName = option.label |
| 152 | const aliases = generateAliases(operationName) |
| 153 | |
| 154 | operations.push({ |
| 155 | id: `${block.type}_${option.id}`, |
| 156 | blockType: block.type, |
| 157 | operationId: option.id, |
| 158 | serviceName: block.name, |
| 159 | operationName, |
| 160 | icon: block.icon, |
| 161 | bgColor: block.bgColor, |
| 162 | aliases, |
| 163 | }) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | return operations |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Cached operations index to avoid rebuilding on every search. |
no test coverage detected